UsersModule

public class UsersModule

Provides User management.

  • Get information about the user for which this client is authenticated.

    Declaration

    Swift

    public func getCurrent(
        fields: [String]? = nil,
        completion: @escaping Callback<User>
    )

    Parameters

    fields

    List of user object fields to include in the response. Only those fields will be populated on the resulting model object. If not passed, a default set of fields will be returned.

    completion

    Returns a standard user object or an error.

  • Get information about a user in the enterprise. Requires enterprise administration authorization.

    Declaration

    Swift

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

    Parameters

    userId

    The ID of the user.

    fields

    List of user object fields to include in the response. Only those fields will be populated on the resulting model object. If not passed, a default set of fields will be returned.

    completion

    Returns a standard user object or an error.

  • Get image of a user’s avatar

    Declaration

    Swift

    public func getAvatar(
        userId: String,
        completion: @escaping Callback<Data>
    )

    Parameters

    userId

    The ID of the user.

    completion

    Returns the data object of the avatar image of the user or an error.

  • Create a new managed user in an enterprise. This method only works for Box admins.

    Declaration

    Swift

    public func create(
        login: String,
        name: String,
        role: UserRole? = nil,
        language: String? = nil,
        isSyncEnabled: Bool? = nil,
        jobTitle: String? = nil,
        phone: String? = nil,
        address: String? = nil,
        spaceAmount: Int64? = nil,
        trackingCodes: [User.TrackingCode]? = nil,
        canSeeManagedUsers: Bool? = nil,
        timezone: String? = nil,
        isExternalCollabRestricted: Bool? = nil,
        isExemptFromDeviceLimits: Bool? = nil,
        isExemptFromLoginVerification: Bool? = nil,
        status: UserStatus? = nil,
        fields: [String]? = nil,
        completion: @escaping Callback<User>
    )

    Parameters

    login

    The email address the user uses to login

    name

    The name of the user

    role

    The user’s enterprise role. Can be coadmin or user

    language

    The language of the user. Input format follows a modified version of the ISO 639-1 language code format. https://developer.box.com/docs/api-language-codes

    isSyncEnabled

    Whether the user can use Box Sync

    jobTitle

    The user’s job title

    phone

    The user’s phone number

    address

    The user’s address

    spaceAmount

    The user’s total available space amount in bytes

    trackingCodes

    An array of key/value pairs set by the user’s admin

    canSeeManagedUsers

    Whether the user can see other managed users

    timezone

    The user’s timezone. Input format follows tz database timezones. https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

    isExternalCollabRestricted

    Whether the user is restricted from external collaboration

    isExemptFromDeviceLimits

    Whether to exempt the user from Enterprise device limits

    isExemptFromLoginVerification

    Whether the user must use two-factor authentication

    status

    active, inactive, cannotDeleteOrEdit, or cannotDeleteEditOrupload

    fields

    List of user object fields to include in the response. Only those fields will be populated on the resulting model object. If not passed, a default set of fields will be returned.

    completion

    Returns a standard user object or an error.

  • Update the information for a user.

    Declaration

    Swift

    public func update(
        userId: String,
        login: String? = nil,
        name: String? = nil,
        role: UserRole? = nil,
        language: String? = nil,
        isSyncEnabled: Bool? = nil,
        jobTitle: String? = nil,
        phone: String? = nil,
        address: String? = nil,
        spaceAmount: Int64? = nil,
        trackingCodes: [User.TrackingCode]? = nil,
        canSeeManagedUsers: Bool? = nil,
        timezone: String? = nil,
        isExternalCollabRestricted: Bool? = nil,
        isExemptFromDeviceLimits: Bool? = nil,
        isExemptFromLoginVerification: Bool? = nil,
        status: UserStatus? = nil,
        fields: [String]? = nil,
        completion: @escaping Callback<User>
    )

    Parameters

    userId

    The ID of the user.

    login

    The ID of the user.

    name

    The name of the user

    role

    The user’s enterprise role. Can be coadmin or user

    language

    The language of the user. Input format follows a modified version of the ISO 639-1 language code format. https://developer.box.com/docs/api-language-codes

    isSyncEnabled

    Whether the user can use Box Sync

    jobTitle

    The user’s job title

    phone

    The user’s phone number

    address

    The user’s address

    spaceAmount

    The user’s total available space amount in bytes

    trackingCodes

    An array of key/value pairs set by the user’s admin

    canSeeManagedUsers

    Whether the user can see other managed users

    timezone

    The user’s timezone. Input format follows tz database timezones. https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

    isExternalCollabRestricted

    Whether the user is restricted from external collaboration

    isExemptFromDeviceLimits

    Whether to exempt the user from Enterprise device limits

    isExemptFromLoginVerification

    Whether the user must use two-factor authentication

    status

    active, inactive, cannotDeleteOrEdit, or cannotDeleteEditOrupload

    fields

    List of user object fields to include in the response. Only those fields will be populated on the resulting model object. If not passed, a default set of fields will be returned.

    completion

    Returns a standard user object or an error.

  • Create a new app user in an enterprise.

    Declaration

    Swift

    public func createAppUser(
        name: String,
        language: String? = nil,
        jobTitle: String? = nil,
        timezone: String? = nil,
        phone: String? = nil,
        address: String? = nil,
        spaceAmount: Int64? = nil,
        status: UserStatus? = nil,
        isExternalCollabRestricted: Bool? = nil,
        canSeeManagedUsers: Bool? = nil,
        fields: [String]? = nil,
        completion: @escaping Callback<User>
    )

    Parameters

    name

    The name of the user. All special characters are acceptable except for <, >, and “ ”.

    language

    The language of the user. Input format follows a modified version of the ISO 639-1 language code format. https://developer.box.com/v2.0/docs/api-language-codes

    jobTitle

    The user’s job title

    timezone

    The user’s timezone. Input format follows tz database timezones. https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

    phone

    The user’s phone number

    address

    The user’s address

    spaceAmount

    The user’s total available space amount in bytes

    status

    active, inactive, cannotDeleteOrEdit, or cannotDeleteEditOrupload

    isExternalCollabRestricted

    Whether the user is restricted from external collaboration

    canSeeManagedUsers

    Whether the user can see managed users

    fields

    List of user object fields to include in the response. Only those fields will be populated on the resulting model object. If not passed, a default set of fields will be returned.

    completion

    Returns a standard user object or an error.

  • Delete a user.

    Declaration

    Swift

    public func delete(
        userId: String,
        notify: Bool? = nil,
        force: Bool? = nil,
        completion: @escaping Callback<Void>
    )

    Parameters

    userId

    The ID of the user

    notify

    Whether the destination user will receive email notification of the transfer

    force

    Whether the user should be deleted even if this user still own files

    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.

  • Returns all of the users for the Enterprise. Only available to admin accounts or service accounts.

    Declaration

    Swift

    public func listForEnterprise(
        filterTerm: String? = nil,
        fields: [String]? = nil,
        usemarker: Bool? = nil,
        marker: String? = nil,
        offset: Int? = nil,
        limit: Int? = nil
    ) -> PagingIterator<User>

    Parameters

    filterTerm

    Only return users whose name or login matches the filter_term. See notes below for details on the matching.

    fields

    List of user object fields to include in the response. Only those fields will be populated on the resulting model object. If not passed, a default set of fields will be returned.

    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.

    limit

    The maximum number of items to return.

    completion

    Returns an iterator of users or a BoxSDKError

  • Invite an existing user to join an Enterprise.

    Declaration

    Swift

    public func inviteToJoinEnterprise(
        login: String,
        enterpriseId: String,
        fields: [String]? = nil,
        completion: @escaping Callback<Invite>
    )

    Parameters

    enterpriseId

    The ID of the enterprise the user will be invited to

    login

    The login of the user that will receive the invitation

    fields

    List of user object fields to include in the response. Only those fields will be populated on the resulting model object. If not passed, a default set of fields will be returned.

    completion

    Returns a standard Invite object or an error.

  • Move all of the items owned by a user into a new folder in another user’s account.

    Declaration

    Swift

    public func moveItemsOwnedByUser(
        withID sourceUserID: String,
        toUserWithID destinationUserID: String,
        notify: Bool? = nil,
        fields: [String]? = nil,
        completion: @escaping Callback<Folder>
    )

    Parameters

    sourceUserID

    The ID of the user whose owned content will be moved

    destinationUserID

    The ID of the user who the folder will be transferred to

    notify

    Whether the destination user should receive email notification of the transfer

    fields

    List of user object fields to include in the response. Only those fields will be populated on the resulting model object. If not passed, a default set of fields will be returned.

    completion

    Returns a standard Folder object or an error.

  • Used to convert one of the user’s confirmed email aliases into the user’s primary login.

    Declaration

    Swift

    public func changeLogin(
        userId: String,
        login: String,
        fields: [String]? = nil,
        completion: @escaping Callback<User>
    )

    Parameters

    userId

    The ID of the user

    login

    The email alias to become the primary email

    fields

    List of user object fields to include in the response. Only those fields will be populated on the resulting model object. If not passed, a default set of fields will be returned.

    completion

    Returns a standard User object or an error.

  • Retrieves all email aliases for this user.

    Declaration

    Swift

    public func listEmailAliases(
        userId: String,
        completion: @escaping Callback<EntryContainer<EmailAlias>>
    )

    Parameters

    userId

    The ID of the user

    completion

    Returns a collection of Email Aliases of the user or an error.

  • Adds a new email alias to the given user’s account.

    Declaration

    Swift

    public func createEmailAlias(
        userId: String,
        email: String,
        completion: @escaping Callback<EmailAlias>
    )

    Parameters

    userId

    The ID of the user

    email

    The email address to add to the account as an alias

    completion

    Returns a Email Aliases object or an error.

  • Removes an email alias from a user.

    Declaration

    Swift

    public func deleteEmailAlias(
        userId: String,
        emailAliasId: String,
        completion: @escaping Callback<Void>
    )

    Parameters

    userId

    The ID of the user

    emailAliasId

    The ID of the email alias

    completion

    An empty response will be returned upon successful deletion. An error is thrown if the user don’t have permission to delete the email alias.

  • Roll a user out of their enterprise (and convert them to a standalone free user)

    Declaration

    Swift

    public func rollOutOfEnterprise(
        userId: String,
        notify: Bool? = nil,
        fields: [String]? = nil,
        completion: @escaping Callback<User>
    )

    Parameters

    userId

    The ID of the user

    notify

    Whether the user should receive an email when they are rolled out of an enterprise

    fields

    List of user object fields to include in the response. Only those fields will be populated on the resulting model object. If not passed, a default set of fields will be returned.

    completion

    Returns a standard User object of the updated user, or an error.