BoxClient

public class BoxClient

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

  • Provides File management.

    Declaration

    Swift

    public private(set) lazy var files: FilesModule { get set }
  • Provides Folder management.

    Declaration

    Swift

    public private(set) lazy var folders: FoldersModule { get set }
  • Provides User management.

    Declaration

    Swift

    public private(set) lazy var users: UsersModule { get set }
  • Provides Comment management.

    Declaration

    Swift

    public private(set) lazy var comments: CommentsModule { get set }
  • Provides SharedItem management.

    Declaration

    Swift

    public private(set) lazy var sharedItems: SharedItemsModule { get set }
  • Provides search functionality.

    Declaration

    Swift

    public private(set) lazy var search: SearchModule { get set }
  • Provides collections functionality.

    Declaration

    Swift

    public private(set) lazy var collections: CollectionsModule { get set }
  • Provides collaborations functionality.

    Declaration

    Swift

    public private(set) lazy var collaborations: CollaborationsModule { get set }
  • Metadata management.

    Declaration

    Swift

    public private(set) lazy var metadata: MetadataModule { get set }
  • Provides authentication session management.

    Declaration

    Swift

    public private(set) var session: SessionProtocol
  • Requests header.

    Declaration

    Swift

    public private(set) var headers: BoxHTTPHeaders?
  • SDK request configuration.

    Declaration

    Swift

    public private(set) var configuration: BoxSDKConfiguration
  • Indicates whether this BoxClient instance was already destroyed and should not be further used.

    Declaration

    Swift

    public private(set) var isDestroyed: Bool
  • ID of user’s favorites collection.

    Declaration

    Swift

    public internal(set) var favoritesCollectionId: String?
  • Initializer

    Declaration

    Swift

    public init(networkAgent: NetworkAgentProtocol, session: SessionProtocol, configuration: BoxSDKConfiguration)

    Parameters

    networkAgent

    Provides network communication with the Box APIs.

    session

    Provides authentication session management.

    configuration

    Provides parameters to makes API calls in order to tailor it to their application’s specific needs

  • Creates BoxClient instance based on shared link URL and password.

    Declaration

    Swift

    public func withSharedLink(url: URL, password: String?) -> BoxClient

    Parameters

    url

    Shared link URL.

    password

    Shared link password.

    Return Value

    Returns new standard BoxClient object.

  • Creates BoxClient instance based on user identifier.

    Declaration

    Swift

    public func asUser(withId userId: String) -> BoxClient

    Parameters

    userId

    User identifier.

    Return Value

    Returns new standard BoxCliennt object.

  • Destroys the client, revoking its access tokens and rendering it inoperable.

    Declaration

    Swift

    public func destroy(completion: @escaping (Result<Void, BoxError>) -> Void)

    Parameters

    completion

    Called when the operation is complete.

  • 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 (Result<BoxResponse, BoxError>) -> Void
    )

    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 (Result<BoxResponse, BoxError>) -> Void
    )

    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

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

    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

  • 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 (Result<BoxResponse, BoxError>) -> Void
    )

    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

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

    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

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

    Declaration

    Swift

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

    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 DELETE method call on an API endpoint and returns a response.

    Declaration

    Swift

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

    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

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

    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 reques

    completion

    Returns a BoxResponse object or an error if request fails