def get_box_folder_files_details(
    box_client: BoxClient, folder_id: str, is_recursive: bool = False
) -> List[File]:
    """
    Retrieves details for all files within a Box folder, optionally including nested sub-folders.

    This function takes a Box client, a folder ID, and an optional recursion flag as input. It retrieves details for all files within the specified folder and returns a list of File objects containing details for each file.

    Args:
        box_client (BoxClient): An authenticated Box client object.
        folder_id (str): The ID of the Box folder to retrieve files from.
        is_recursive (bool, optional): A flag indicating whether to recursively traverse sub-folders within the target folder. Defaults to False.

    Returns:
        List[File]: A list of File objects containing details for all files found within the specified folder and its sub-folders (if recursion is enabled).

    Raises:
        BoxAPIError: If an error occurs while retrieving folder or file details from the Box API.

    """
    box_files_details: List[File] = []
    try:
        folder = box_client.folders.get_folder_by_id(folder_id)
    except BoxAPIError as e:
        logger.error(
            f"An error occurred while getting folder: {e.message}", exc_info=True
        )
        raise

    for item in box_client.folders.get_folder_items(folder.id).entries:
        if item.type == "file":
            box_files_details.extend(get_box_files_details(box_client, [item.id]))
        elif item.type == "folder":
            if is_recursive:
                box_files_details.extend(
                    get_box_folder_files_details(box_client, item.id, is_recursive)
                )
    return box_files_details

    Retrieves details for all files within a Box folder, optionally including nested sub-folders.

    This function takes a Box client, a folder ID, and an optional recursion flag as input. It retrieves details for all files within the specified folder and returns a list of File objects containing details for each file.

    Args:
        box_client (BoxClient): An authenticated Box client object.
        folder_id (str): The ID of the Box folder to retrieve files from.
        is_recursive (bool, optional): A flag indicating whether to recursively traverse sub-folders within the target folder. Defaults to False.

    Returns:
        List[File]: A list of File objects containing details for all files found within the specified folder and its sub-folders (if recursion is enabled).

    Raises:
        BoxAPIError: If an error occurs while retrieving folder or file details from the Box API.

    
llama-index-integrations/readers/llama-index-readers-box/llama_index/readers/box/BoxAPI/box_api.py