     }
 }
 
-/// Creates a URL such as `{portalURL}/sharing/rest/content/items/{itemIdentifier}/data`
+/// Creates a URL such as
+/// `{portalURL}/sharing/rest/content/items/{itemIdentifier}/data`
 /// for the given item in the given portal.
 ///
 /// - Parameters:

    let downloadDirectory: URL
    let fileTypes: [String: [String]]
    
    /// Make a full path for a file based on the mapping between its filename and file type.
    ///
    /// - Parameter filename: The filename of the file.
    /// - Returns: A URL to the file.
    func makeURL(filename: String) -> URL {
        var url = downloadDirectory
        if let subdirectory = fileTypes.first(
            where: { $0.value.contains((filename as NSString).pathExtension) }
            )?.key {
            url.appendPathComponent(subdirectory, isDirectory: true)
        }
        url.appendPathComponent(filename, isDirectory: false)

///
/// - Parameters:
///   - sourceURL: The portal URL to the resource.
///   - destinationURLProvider: A helper struct to make destination URL with filename.
///   - completion: A closure to handle the results.
func downloadFile(at sourceURL: URL, destinationURLProvider: URLProvider, completion: @escaping (Result<URL, Error>) -> Void) {
    let downloadTask = URLSession.shared.downloadTask(with: sourceURL) { (temporaryURL, response, error) in
