Class: Users

Users(client) → {void}

Simple manager for interacting with all 'User' endpoints and actions.

Constructor

new Users(client) → {void}

Parameters:
Name Type Description
client BoxClient The Box API Client that is responsible for making calls to the API
Source:
Returns:
Type
void

Members

(constant) CURRENT_USER_ID :string

Type:
  • string
Source:

Methods

addEmailAlias(userID, email, optionsopt, callbackopt) → {Promise.<Object>}

Add a linked email address to a user's account. API Endpoint: '/users/:id/email_aliases' Method: POST
Parameters:
Name Type Attributes Description
userID string The ID of the user to add an email alias to
email string The email address to add
options Object <optional>
Optional parameters
Properties
Name Type Attributes Default Description
is_confirmed boolean <optional>
false Whether or not to attempt to auto-confirm the alias (for admins)
callback function <optional>
Passed the new alias if successful
Source:
Returns:
A promise resolving to the new email alias
Type
Promise.<Object>

addEmailAlias(userID, email, optionsopt, callbackopt) → {Promise.<Object>}

Add a linked email address to a user's account. API Endpoint: '/users/:id/email_aliases' Method: POST
Parameters:
Name Type Attributes Description
userID string The ID of the user to add an email alias to
email string The email address to add
options Object <optional>
Optional parameters
Properties
Name Type Attributes Default Description
is_confirmed boolean <optional>
false Whether or not to attempt to auto-confirm the alias (for admins)
callback function <optional>
Passed the new alias if successful
Source:
Returns:
A promise resolving to the new email alias
Type
Promise.<Object>

delete(userID, optionsopt, callbackopt) → {Promise.<void>}

Deletes a user in an enterprise account. API Endpoint: '/users/:userID' Method: DELETE
Parameters:
Name Type Attributes Description
userID string The ID of the user to delete
options Object <optional>
Additional options for the request. Can be left null in most cases.
Properties
Name Type Attributes Description
notify boolean <optional>
Determines if the destination user should receive email notification of the transfer.
force boolean <optional>
Whether or not the user should be deleted even if this user still own files.
callback function <optional>
Empty response body passed if successful, error otherwise
Source:
Returns:
A promise resolving to nothing
Type
Promise.<void>

delete(userID, optionsopt, callbackopt) → {Promise.<void>}

Deletes a user in an enterprise account. API Endpoint: '/users/:userID' Method: DELETE
Parameters:
Name Type Attributes Description
userID string The ID of the user to delete
options Object <optional>
Additional options for the request. Can be left null in most cases.
Properties
Name Type Attributes Description
notify boolean <optional>
Determines if the destination user should receive email notification of the transfer.
force boolean <optional>
Whether or not the user should be deleted even if this user still own files.
callback function <optional>
Empty response body passed if successful, error otherwise
Source:
Returns:
A promise resolving to nothing
Type
Promise.<void>

deleteAvatar(userID, callbackopt) → {Promise.<void>}

Delete the user's avatar image. API Endpoint: '/users/:userID/avatar' Method: DELETE
Parameters:
Name Type Attributes Description
userID string The ID of the user whose avatar should be deleted
callback function <optional>
Passed nothing if successful
Source:
Returns:
A promise resolving to nothing
Type
Promise.<void>

deleteAvatar(userID, callbackopt) → {Promise.<void>}

Delete the user's avatar image. API Endpoint: '/users/:userID/avatar' Method: DELETE
Parameters:
Name Type Attributes Description
userID string The ID of the user whose avatar should be deleted
callback function <optional>
Passed nothing if successful
Source:
Returns:
A promise resolving to nothing
Type
Promise.<void>

get(userID, optionsopt, callbackopt) → {Promise.<Object>}

Requests information for the Box user info associated with a given ID API Endpoint: '/users/:id' Method: GET
Parameters:
Name Type Attributes Description
userID string The ID of the user to retrieve
options Object <optional>
Additional options for the request. Can be left null in most cases.
callback function <optional>
passed the user info if it was acquired successfully
Source:
Returns:
A promise resolving to the user object
Type
Promise.<Object>

get(userID, optionsopt, callbackopt) → {Promise.<Object>}

Requests information for the Box user info associated with a given ID API Endpoint: '/users/:id' Method: GET
Parameters:
Name Type Attributes Description
userID string The ID of the user to retrieve
options Object <optional>
Additional options for the request. Can be left null in most cases.
callback function <optional>
passed the user info if it was acquired successfully
Source:
Returns:
A promise resolving to the user object
Type
Promise.<Object>

getAvatar(userID, callbackopt) → {Promise.<Readable>}

Retrieve the user's avatar image. API Endpoint: '/users/:userID/avatar' Method: GET
Parameters:
Name Type Attributes Description
userID string The ID of the user whose avatar should be retrieved
callback function <optional>
Passed a stream over the bytes of the avatar image if successful
Source:
Returns:
A promise resolving to the image stream
Type
Promise.<Readable>

getAvatar(userID, callbackopt) → {Promise.<Readable>}

Retrieve the user's avatar image. API Endpoint: '/users/:userID/avatar' Method: GET
Parameters:
Name Type Attributes Description
userID string The ID of the user whose avatar should be retrieved
callback function <optional>
Passed a stream over the bytes of the avatar image if successful
Source:
Returns:
A promise resolving to the image stream
Type
Promise.<Readable>

getEmailAliases(userID, callbackopt) → {Promise.<Object>}

Get all linked email addresses for a user. API Endpoint: '/users/:id/email_aliases' Method: GET
Parameters:
Name Type Attributes Description
userID string The ID of the user to retrieve email alises for
callback function <optional>
Passed the email aliases if successful
Source:
Returns:
A promise resolving to the collection of email aliases
Type
Promise.<Object>

getEmailAliases(userID, callbackopt) → {Promise.<Object>}

Get all linked email addresses for a user. API Endpoint: '/users/:id/email_aliases' Method: GET
Parameters:
Name Type Attributes Description
userID string The ID of the user to retrieve email alises for
callback function <optional>
Passed the email aliases if successful
Source:
Returns:
A promise resolving to the collection of email aliases
Type
Promise.<Object>

getGroupMemberships(userID, optionsopt, callbackopt) → {Promise.<Object>}

Retrieve a list of group memberships for the user, which show which groups the user belongs to. This ability is restricted to group admins. API Endpoint: '/users/:userID/memberships' Method: GET
Parameters:
Name Type Attributes Description
userID string The ID of the user to get group memberships for
options Object <optional>
Optional parameters, can be left null in most cases
Properties
Name Type Attributes Description
limit int <optional>
The number of memberships to retrieve
offset int <optional>
Paging marker, retrieve records starting at this position in the list
callback function <optional>
Passed a list of memberships if successful, error otherwise
Source:
Returns:
A promise resolving to the collection of group memberships
Type
Promise.<Object>

getGroupMemberships(userID, optionsopt, callbackopt) → {Promise.<Object>}

Retrieve a list of group memberships for the user, which show which groups the user belongs to. This ability is restricted to group admins. API Endpoint: '/users/:userID/memberships' Method: GET
Parameters:
Name Type Attributes Description
userID string The ID of the user to get group memberships for
options Object <optional>
Optional parameters, can be left null in most cases
Properties
Name Type Attributes Description
limit int <optional>
The number of memberships to retrieve
offset int <optional>
Paging marker, retrieve records starting at this position in the list
callback function <optional>
Passed a list of memberships if successful, error otherwise
Source:
Returns:
A promise resolving to the collection of group memberships
Type
Promise.<Object>

removeEmailAlias(userID, aliasID, callbackopt) → {Promise.<void>}

Remove a linked email address from the current user by alias ID. API Endpoint: '/users/:id/email_aliases/:aliasID' Method: DELETE
Parameters:
Name Type Attributes Description
userID string The ID of the user to remove the email alias from
aliasID string The ID of the linked email alias to remove
callback function <optional>
Passed nothing on success
Source:
Returns:
A promise resolving to nothing
Type
Promise.<void>

removeEmailAlias(userID, aliasID, callbackopt) → {Promise.<void>}

Remove a linked email address from the current user by alias ID. API Endpoint: '/users/:id/email_aliases/:aliasID' Method: DELETE
Parameters:
Name Type Attributes Description
userID string The ID of the user to remove the email alias from
aliasID string The ID of the linked email alias to remove
callback function <optional>
Passed nothing on success
Source:
Returns:
A promise resolving to nothing
Type
Promise.<void>

setAvatar(userID, avatar, callbackopt) → {Promise.<Object>}

Set the user's avatar image. API Endpoint: '/users/:userID/avatar' Method: POST
Parameters:
Name Type Attributes Description
userID string The ID of the user whose avatar should be set
avatar string | Buffer | ReadStream the content of the file. It can be a string, a Buffer, or a read stream (like that returned by fs.createReadStream()).
callback function <optional>
Passed dictionary of picture urls if successful
Source:
Returns:
A promise resolving to the picture urls
Type
Promise.<Object>

setAvatar(userID, avatar, callbackopt) → {Promise.<Object>}

Set the user's avatar image. API Endpoint: '/users/:userID/avatar' Method: POST
Parameters:
Name Type Attributes Description
userID string The ID of the user whose avatar should be set
avatar string | Buffer | ReadStream the content of the file. It can be a string, a Buffer, or a read stream (like that returned by fs.createReadStream()).
callback function <optional>
Passed dictionary of picture urls if successful
Source:
Returns:
A promise resolving to the picture urls
Type
Promise.<Object>

terminateSession(options) → {Promise.<Object>}

Validates the roles and permissions of the user, and creates asynchronous jobs to terminate the user's sessions. API Endpoint: '/users/terminate_sessions' Method: POST
Parameters:
Name Type Description
options Object The user IDs or logins to terminate sessions
Properties
Name Type Attributes Description
userIDs Array.<string> <optional>
The user IDs to terminate sessions
userLogins Array.<string> <optional>
The user logins to terminate sessions
Source:
Returns:
A promise resolving a message about the request status.
Type
Promise.<Object>

terminateSession(options) → {Promise.<Object>}

Validates the roles and permissions of the user, and creates asynchronous jobs to terminate the user's sessions. API Endpoint: '/users/terminate_sessions' Method: POST
Parameters:
Name Type Description
options Object The user IDs or logins to terminate sessions
Properties
Name Type Attributes Description
userIDs Array.<string> <optional>
The user IDs to terminate sessions
userLogins Array.<string> <optional>
The user logins to terminate sessions
Source:
Returns:
A promise resolving a message about the request status.
Type
Promise.<Object>

update(userID, updates, callbackopt) → {Promise.<Object>}

Update some information about a user. API Endpoint: '/users/:id' Method: PUT
Parameters:
Name Type Attributes Description
userID string The ID of the user to update
updates Object User fields to update
callback function <optional>
Passed the updated user information if it was acquired successfully
Source:
Returns:
A promise resolving to the updated user object
Type
Promise.<Object>

update(userID, updates, callbackopt) → {Promise.<Object>}

Update some information about a user. API Endpoint: '/users/:id' Method: PUT
Parameters:
Name Type Attributes Description
userID string The ID of the user to update
updates Object User fields to update
callback function <optional>
Passed the updated user information if it was acquired successfully
Source:
Returns:
A promise resolving to the updated user object
Type
Promise.<Object>