FoldersModule

public class FoldersModule

Provides Folder management.

  • Get information about a folder.

    Declaration

    Swift

    public func get(
        folderId: String,
        fields: [String]? = nil,
        completion: @escaping Callback<Folder>
    )

    Parameters

    folderId

    The ID of the folder on which to retrieve information.

    fields

    Comma-separated list of fields to include in the response.

    completion

    Returns a full folder object or an error.

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

    Declaration

    Swift

    public func listItems(
        folderId: String,
        usemarker: Bool? = nil,
        marker: String? = nil,
        offset: Int? = nil,
        limit: Int? = nil,
        sort: FolderItemsOrderBy? = nil,
        direction: OrderDirection? = nil,
        fields: [String]? = nil
    ) -> PagingIterator<FolderItem>

    Parameters

    folderId

    The ID of the folder on which to retrieve information.

    usemarker

    This specifies whether you would like to use marker-based or offset-based paging. You can only use one or the other. Marker-based paging is the preferred method and is most performant. If not specified, this endpoint defaults to using offset-based paging. This parameter is unique to Get Folder Items to retain backwards compatibility for this endpoint. This parameter is required for both the first and subsequent calls to use marked-based paging.

    marker

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

    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.

    sort

    This can be id, name, or date. This parameter is not yet supported for marker- based paging on folder 0.

    direction

    This can be ASC or DESC.

    fields

    Comma-separated list of fields to include in the response.

  • Create a new folder.

    Declaration

    Swift

    public func create(
        name: String,
        parentId: String,
        fields: [String]? = nil,
        completion: @escaping Callback<Folder>
    )

    Parameters

    name

    The desired name for the folder. Box supports folder 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.

    parentId

    The ID of the parent folder.

    fields

    Comma-separated list of fields to include in the response.

    completion

    Returns a full folder object or an error if the parentId is invalid or if a name collision occurs.

  • Update a folder.

    Declaration

    Swift

    public func update(
        folderId: String,
        name: String? = nil,
        description: String? = nil,
        parentId: String? = nil,
        sharedLink: NullableParameter<SharedLinkData>? = nil,
        folderUploadEmailAccess: FolderUploadEmailAccess? = nil,
        tags: [String]? = nil,
        canNonOwnersInvite: Bool? = nil,
        isCollaborationRestrictedToEnterprise: Bool? = nil,
        collections: [String]? = nil,
        fields: [String]? = nil,
        completion: @escaping Callback<Folder>
    )

    Parameters

    folderId

    The ID of the file to update

    name

    The name of the folder.

    description

    The description of the folder.

    parentId

    The ID of the parent folder

    access

    The level of access. Can be open (“People with the link”), company (“People in your company”), or collaborators (“People in this folder”). If you omit this field then the access level will be set to the default access level specified by the enterprise admin.

    password

    The password required to access the shared link. Set to .empty value to delete password

    unsharedAt

    The date-time that this link will become disabled. This field can only be set by users with paid accounts.

    canDownload

    Whether the shared link allows downloads. For shared links on folders, this also applies to any items in the folder. Can only be set with access levels open and company (not collaborators).

    folderUploadEmailAccess

    Can be open or collaborators

    tags

    Array of tags to be added or replaced to the folder

    canNonOwnersInvite

    If this parameter is set to false, only folder owners and co-owners can send collaborator invites

    isCollaborationRestrictedToEnterprise

    Whether to restrict future collaborations to within the enterprise. Does not affect existing collaborations.

    fields

    Comma-separated list of fields to include in the response.

    completion

    The updated folder is returned if the name is valid. Errors generally occur only if there is a name collision.

  • Delete a folder or move a folder to the trash. The recursive parameter must be included in order to delete folders that aren’t empty. Depending on the enterprise settings for this user, the item will either be actually deleted from Box or moved to the trash.

    Declaration

    Swift

    public func delete(
        folderId: String,
        recursive: Bool? = nil,
        completion: @escaping Callback<Void>
    )

    Parameters

    folderId

    The ID of the file to delete.

    recursive

    Whether to delete this folder if it has items inside of it.

    completion

    An empty response will be returned upon successful deletion. An error is thrown if the folder is not empty and the ‘recursive’ parameter is not included.

  • Used to create a copy of a folder in another folder. The original version of the folder will not be altered.

    Declaration

    Swift

    public func copy(
        folderId: String,
        destinationFolderID: String,
        name: String? = nil,
        fields: [String]? = nil,
        completion: @escaping Callback<Folder>
    )

    Parameters

    folderId

    The ID of the folder that will be copy.

    destinationFolderID

    The ID of the destination folder

    name

    An optional new name for the folder

    fields

    Comma-separated list of fields to include in the response.

    completion

    Returns a full folder object or an error if the parentId is invalid or if a name collision occurs.

  • Use this to get a list of all the collaborations on a folder i.e. all of the users that have access to that folder.

    Declaration

    Swift

    public func listCollaborations(
        folderId: String,
        fields: [String]? = nil
    ) -> PagingIterator<Collaboration>

    Parameters

    folderId

    The ID of the folder on which to retrieve collaborations.

    fields

    Comma-separated list of fields to include in the response.

  • Add folder to favorites

    Declaration

    Swift

    public func addToFavorites(
        folderId: String,
        completion: @escaping Callback<Folder>
    )

    Parameters

    folderId

    The ID of the folder

    completion

    Returns the updated folder or an error

  • Add folder to particular collection

    Declaration

    Swift

    public func addToCollection(
        folderId: String,
        collectionId: String,
        completion: @escaping Callback<Folder>
    )

    Parameters

    folderId

    The ID of the folder

    collectionId

    The ID of the collection

    completion

    Returns the updated folder or an error

  • Remove folder from favorites

    Declaration

    Swift

    public func removeFromFavorites(
        folderId: String,
        completion: @escaping Callback<Folder>
    )

    Parameters

    folderId

    The ID of the folder

    completion

    Returns the updated folder or an error

  • Add folder to particular collection

    Declaration

    Swift

    public func removeFromCollection(
        folderId: String,
        collectionId: String,
        completion: @escaping Callback<Folder>
    )

    Parameters

    folderId

    The ID of the folder

    collectionId

    The ID of the collection

    completion

    Returns the updated folder or an error

  • Gets folder with updated shared link

    Declaration

    Swift

    public func getSharedLink(
        forFolder folderId: String,
        completion: @escaping Callback<SharedLink>
    )

    Parameters

    folderId

    The ID of the folder

    completion

    Returns a standard SharedLink object or an error

  • Creates or updates shared link for a folder

    Declaration

    Swift

    public func setSharedLink(
        forFolder folderId: String,
        access: SharedLinkAccess? = nil,
        unsharedAt: NullableParameter<Date>? = nil,
        password: NullableParameter<String>? = nil,
        canDownload: Bool? = nil,
        completion: @escaping Callback<SharedLink>
    )

    Parameters

    folderId

    The ID of the folder

    access

    The level of access. If you omit this field then the access level will be set to the default access level specified by the enterprise admin

    unsharedAt

    The date-time that this link will become disabled. This field can only be set by users with paid accounts

    password

    The password required to access the shared link. Set to .null to remove the password

    canDownload

    Whether the shared link allows downloads. Applies to any items in the folder

    completion

    Returns a standard SharedLink object or an error

  • Removes shared link for a folder

    Declaration

    Swift

    public func deleteSharedLink(
        forFolder folderId: String,
        completion: @escaping Callback<Void>
    )

    Parameters

    folderId

    The ID of the folder

    completion

    Returns an empty response or an error

  • Retrieves the watermark on a specified folder.

    Declaration

    Swift

    public func getWatermark(
        folderId: String,
        completion: @escaping Callback<Watermark>
    )

    Parameters

    folderId

    The id of the folder to retrieve the watermark from.

    completion

    Returns a watermark object or an error.

  • Apply or update the watermark on a specified folder.

    Declaration

    Swift

    public func applyWatermark(
        folderId: String,
        completion: @escaping Callback<Watermark>
    )

    Parameters

    folderId

    The id of the folder to update the watermark for.

    completion

    Returns a watermark object or an error.

  • Remove the watermark from a specified folder.

    Declaration

    Swift

    public func removeWatermark(
        folderId: String,
        completion: @escaping Callback<Void>
    )

    Parameters

    folderId

    The id of the folder to remove the watermark from.

    completion

    Returns an empty response or an error.

  • Get all of the locks on a folder.

    Declaration

    Swift

    public func listLocks(
        folderId: String
    ) -> PagingIterator<FolderLock>

    Parameters

    folderId

    The ID of the folder on which to retrieve folder locks.

    completion

    Returns all of the locks on the folder, or an error if the request is unsuccessful.

  • Creates a folder lock on a folder, preventing it from being moved and/or deleted.

    Declaration

    Swift

    public func createLock(
        folderId: String,
        completion: @escaping Callback<FolderLock>
    )

    Parameters

    folderId

    The ID of the folder to apply the lock to.

    completion

    Returns a folder lock object or an error if the request is unsuccessful.

  • Remove the specified folder lock.

    Declaration

    Swift

    public func deleteLock(
        folderLockId: String,
        completion: @escaping Callback<Void>
    )

    Parameters

    folderLockId

    The id of the folder lock to remove.

    completion

    Returns an empty response or an error.