CollectionsModule

public class CollectionsModule

Management of collections of files and folders. The only collection available is the Favorites.

  • Retrieves the collections for the given user.

    Declaration

    Swift

    public func getCollections(offset: Int? = nil, limit: Int? = nil, fields: [String]? = nil) -> OffsetPaginationIterator<BoxCollection>

    Parameters

    offset

    The offset of the item at which to begin the response. See offset-based paging for details. This parameter cannot be used simultaneously with the ‘marker’ parameter.

    limit

    The maximum number of items to return. The default is 100 and the maximum is 1,000.

  • Gets all of the files, folders, or web links contained within a collection.

    Declaration

    Swift

    public func getCollectionItems(
        collectionId: String,
        offset: Int? = nil,
        limit: Int? = nil,
        fields: [String]? = nil
    ) -> OffsetPaginationIterator<FolderItem>

    Parameters

    collectionId

    The ID of the collection on which to retrieve information.

    offset

    The offset of the item at which to begin the response. See offset-based paging for details. This parameter cannot be used simultaneously with the ‘marker’ parameter.

    limit

    The maximum number of items to return. The default is 100 and the maximum is 1,000.

    fields

    Comma-separated list of fields to include in the response. Any attribute in the full file or folder objects can be passed in with the fields parameter to get specific attributes, and only those specific attributes back; otherwise, the mini format is returned for each item by default. Multiple attributes can be passed in separated by commas e.g. fields=name,created_at.

  • Update the information about a file, including renaming or moving the file.

    Declaration

    Swift

    public func addItemsToCollection(
        fileId: String,
        collectionId: String,
        ifMatch: String? = nil,
        fields: [String]? = nil,
        completion: @escaping (Result<File, BoxError>) -> Void
    )

    Parameters

    fileId

    The ID of the file on which to perform the update.

    updateFileInfo

    The new values with which to update the file.

    ifMatch

    This is in the ‘etag’ field of the file object, which can be included to prevent race conditions.

    fields

    Comma-separated list of fields to include in the response. Any attribute in the full file or folder objects can be passed in with the fields parameter to get specific attributes, and only those specific attributes back; otherwise, the mini format is returned for each item by default. Multiple attributes can be passed in separated by commas e.g. fields=name,created_at.

    completion

    Returns a standard file object or an error if the fileId is invalid or the user doesn’t have access to the file.

  • Create a copy of a file in another folder. The original version of the file will not be altered.

    Declaration

    Swift

    public func deleteItemsFromCollection(
        fileId: String,
        parentId: String,
        name: String? = nil,
        version: String? = nil,
        fields: [String]? = nil,
        completion: @escaping (Result<File, BoxError>) -> Void
    )

    Parameters

    fileId

    The ID of the source file to copy.

    parentId

    The ID of the destination folder.

    name

    An optional new name for the file. Box supports file names of 255 characters or less. Names containing non-printable ASCII characters, / or \, names with trailing spaces, and the special names “.” and “..” are also not allowed.

    version

    An optional file version ID if you want to copy a specific file version

    fields

    Comma-separated list of fields to include in the response. Any attribute in the full file or folder objects can be passed in with the fields parameter to get specific attributes, and only those specific attributes back; otherwise, the mini format is returned for each item by default. Multiple attributes can be passed in separated by commas e.g. fields=name,created_at.

    completion

    Returns a standard file object or an error if the fileId is invalid or the update is not successful. An error will be returned if the destination folder is invalid or if a file name collision occurs.