BoxClient

public class BoxClient
extension BoxClient: BoxClientProtocol

Provides communication with Box APIs. Defines methods for communication with Box APIs

BoxClientProtocol methods

  • Performs an HTTP GET method call on an API endpoint and returns a response.

    Declaration

    Swift

    public func get(
        url: URL,
        httpHeaders: BoxHTTPHeaders = [:],
        queryParameters: QueryParameters = [:],
        completion: @escaping Callback<BoxResponse>
    )

    Parameters

    url

    The URL of the API endpoint to call.

    httpHeaders

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

    queryParameters

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

    completion

    Returns a BoxResponse object or an error if request fails

  • Performs an HTTP POST method call on an API endpoint and returns a response.

    Declaration

    Swift

    public func post(
        url: URL,
        httpHeaders: BoxHTTPHeaders = [:],
        queryParameters: QueryParameters = [:],
        json: Any? = nil,
        completion: @escaping Callback<BoxResponse>
    )

    Parameters

    url

    The URL of the API endpoint to call.

    httpHeaders

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

    queryParameters

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

    json

    The JSON body of the request

    completion

    Returns a BoxResponse object or an error if request fails

  • Performs an HTTP POST method call on an API endpoint and returns a response.

    Declaration

    Swift

    @discardableResult
    public func post(
        url: URL,
        httpHeaders: BoxHTTPHeaders = [:],
        queryParameters: QueryParameters = [:],
        multipartBody: MultipartForm,
        progress: @escaping (Progress) -> Void = { _ in },
        completion: @escaping Callback<BoxResponse>
    ) -> BoxUploadTask

    Parameters

    url

    The URL of the API endpoint to call.

    httpHeaders

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

    queryParameters

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

    multipartBody

    The multipart body of the request

    completion

    Returns a BoxResponse object or an error if request fails

    Return Value

    BoxUploadTask

  • Performs an HTTP PUT method call on an API endpoint and returns a response.

    Declaration

    Swift

    public func put(
        url: URL,
        httpHeaders: BoxHTTPHeaders = [:],
        queryParameters: QueryParameters = [:],
        json: Any? = nil,
        completion: @escaping Callback<BoxResponse>
    )

    Parameters

    url

    The URL of the API endpoint to call.

    httpHeaders

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

    queryParameters

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

    json

    The JSON body of the request

    completion

    Returns a BoxResponse object or an error if request fails

  • Performs an HTTP PUT method call on an API endpoint and returns a response.

    Declaration

    Swift

    @discardableResult
    public func put(
        url: URL,
        httpHeaders: BoxHTTPHeaders = [:],
        queryParameters: QueryParameters = [:],
        multipartBody: MultipartForm,
        progress: @escaping (Progress) -> Void = { _ in },
        completion: @escaping Callback<BoxResponse>
    ) -> BoxUploadTask

    Parameters

    url

    The URL of the API endpoint to call.

    httpHeaders

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

    queryParameters

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

    multipartBody

    The multipart body of the request

    completion

    Returns a BoxResponse object or an error if request fails

    Return Value

    BoxUploadTask

  • Performs an HTTP PUT method call on an API endpoint and returns a response - variant for chunked upload.

    Declaration

    Swift

    @discardableResult
    public func put(
        url: URL,
        httpHeaders: BoxHTTPHeaders = [:],
        queryParameters: QueryParameters = [:],
        data: Data,
        progress: @escaping (Progress) -> Void = { _ in },
        completion: @escaping Callback<BoxResponse>
    ) -> BoxUploadTask

    Parameters

    url

    The URL of the API endpoint to call.

    httpHeaders

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

    queryParameters

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

    data

    Binary body of the request

    progress

    Closure where upload progress will be reported

    completion

    Returns a BoxResponse object or an error if request fails

    Return Value

    BoxUploadTask

  • Performs an HTTP OPTIONS method call on an API endpoint and returns a response.

    Declaration

    Swift

    @discardableResult
    public func options(
        url: URL,
        httpHeaders: BoxHTTPHeaders = [:],
        queryParameters: QueryParameters = [:],
        json: Any? = nil,
        completion: @escaping Callback<BoxResponse>
    ) -> BoxNetworkTask

    Parameters

    url

    The URL of the API endpoint to call.

    httpHeaders

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

    queryParameters

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

    json

    The JSON body of the request

    completion

    Returns a BoxResponse object or an error if request fails

    Return Value

    BoxNetworkTask

  • Performs an HTTP DELETE method call on an API endpoint and returns a response.

    Declaration

    Swift

    public func delete(
        url: URL,
        httpHeaders: BoxHTTPHeaders = [:],
        queryParameters: QueryParameters = [:],
        completion: @escaping Callback<BoxResponse>
    )

    Parameters

    url

    The URL of the API endpoint to call.

    httpHeaders

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

    queryParameters

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

    completion

    Returns a BoxResponse object or an error if request fails

  • Performs an HTTP GET method call for downloading on an API endpoint and returns a response.

    Declaration

    Swift

    @discardableResult
    public func download(
        url: URL,
        downloadDestinationURL: URL,
        httpHeaders: BoxHTTPHeaders = [:],
        queryParameters: QueryParameters = [:],
        progress: @escaping (Progress) -> Void = { _ in },
        completion: @escaping Callback<BoxResponse>
    ) -> BoxDownloadTask

    Parameters

    url

    The URL of the API endpoint to call.

    httpHeaders

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

    queryParameters

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

    downloadDestinationURL

    The URL on disk where the data will be saved

    progress

    Completion block to track the progress of the request

    completion

    Returns a BoxResponse object or an error if request fails

    Return Value

    BoxDownloadTask