Class: UserAPI

API.UserAPI

Singleton class that handle every User requests.
Author:
  • Bruno Morceli - pirofagista@gmail.com
Source:

Extends

  • ApiBase

Methods

(async) create(userObj) → {Promise}

Create a User.
Parameters:
Name Type Description
userObj Entity.UserEntity User entity instance.
Source:
Returns:
Type
Promise
Example
const userData = new CannedIO.entity.user(
  null, // id (not necessary here).
  'user@mycompany.com', // email
  'password123' // password
);

CannedIO.api.user
.get(userData)
.then(user => console.log('success:', user.toJSON()))
.catch(error => console.log('something is wrong:', error));

(async) get(userId) → {Promise}

Get a user by ID.
Parameters:
Name Type Description
userId string user UUID.
Source:
Returns:
Type
Promise
Example
CannedIO.api.user
.get(userId)
.then(user => console.log('success:', user.toJSON()))
.catch(error => console.log('something is wrong:', error));

(async) list() → {Promise}

Get all active users.
Source:
Returns:
Type
Promise
Example
CannedIO.api.user
.list()
.then(list => console.log('I got', user.length, 'users.'))
.catch(error => console.log('something is wrong:', error));

(async) logout(userId) → {Promise}

Logout a user by ID.
Parameters:
Name Type Description
userId String User UUID.
Source:
Returns:
Type
Promise
Example
CannedIO.api.user
.logout(userId)
.then(user => console.log('success:', user.toJSON()))
.catch(error => console.log('something is wrong:', error));

(async) remove(userId) → {Promise}

Remove a user by ID.
Parameters:
Name Type Description
userId string user UUID.
Source:
Returns:
Type
Promise
Example
CannedIO.api.user
.remove(userId)
.then(user => console.log('success:', user.toJSON()))
.catch(error => console.log('something is wrong:', error));