BoxRequest

public class BoxRequest

Represents Box SDK API request.

  • Defines body type of a request

    See more

    Declaration

    Swift

    public enum BodyType
  • Additional information to be passed in the HTTP headers of the request.

    Declaration

    Swift

    public internal(set) var httpHeaders: BoxHTTPHeaders { get }
  • The HTTP request method (e.g. get, post, delete)

    Declaration

    Swift

    public let httpMethod: HTTPMethod
  • url

    The URL of the API endpoint to call.

    Declaration

    Swift

    public let url: URL
  • Additional parameters to be passed in the URL that is called.

    Declaration

    Swift

    public let queryParams: QueryParameters
  • Body of the request.

    Declaration

    Swift

    public let body: BodyType
  • The closure that should add URLSessionTask to BoxNetworkTask store, in order to be able to cancel upload or download request during execution.

    Declaration

    Swift

    public let task: (URLSessionTask) -> Void
  • The closure where progress of the request will be reported

    Declaration

    Swift

    public let progress: (Progress) -> Void
  • The URL on the local FileSystem where a download request will write the data

    Declaration

    Swift

    public let downloadDestination: URL?
  • Initializer.

    Declaration

    Swift

    public init(
        httpMethod: HTTPMethod,
        url: URL,
        httpHeaders: BoxHTTPHeaders = [:],
        queryParams: QueryParameters = [:],
        body: BodyType = .empty,
        downloadDestination: URL? = nil,
        task: @escaping (URLSessionTask) -> Void = { _ in },
        progress: @escaping (Progress) -> Void = { _ in }
    )

    Parameters

    httpMethod

    The HTTP request method (e.g. get, post, delete)

    url

    The URL of the API endpoint to call.

    httpHeaders

    Additional information to be passed in the HTTP headers of the request.

    queryParams

    Additional parameters to be passed in the URL that is called.

    body

    Body of the request.

    downloadDestination

    The URL on disk where a download request will write the data Please omit this parameter when not downloading a file.

    task

    The closure that should add URLSessionTask to BoxNetworkTask store, in order to be able to cancel upload or download request during execution. You should use here receiveTask either from BoxDownloadTask or BoxUploadTask instance. Then in order to cancel the request, call cancel method on this instance. Please omit this parameter when you not intent to cancel upload or download a file.

    progress

    Closure where progress of the request will be reported