forio Toggle navigation

User API Adapter

The User API Adapter allows you to retrieve details about end users in your team (account). It is based on the querying capabilities of the underlying RESTful User API.

Example:

var ua = new F.service.User({
    account: 'acme-simulations',
    token: 'user-or-project-access-token'
});
ua.getById('42836d4b-5b61-4fe4-80eb-3136e956ee5c');
ua.get({ userName: 'jsmith' });
ua.get({ id: ['42836d4b-5b61-4fe4-80eb-3136e956ee5c',
            '4ea75631-4c8d-4872-9d80-b4600146478e'] });

Constructor options

Required? Name Type Description
  account string The account id. In the Epicenter UI, this is the Team ID (for team projects) or User ID (for personal projects). Defaults to undefined. If left undefined, taken from the URL.
  project string The project id. Defaults to undefined. If left undefined, parsed from the URL.
  token string For projects that require authentication, pass in the user access token (defaults to undefined). If the user is already logged in to Epicenter, the user access token is already set in a cookie and automatically loaded from there. (See more background on access tokens). @see Authentication API Service for getting tokens.
  transport JQueryAjaxOptions Options to pass on to the underlying transport layer. All jquery.ajax options are supported.
  server object
  server.host string The value of host is usually the string api.forio.com, the URI of the Forio API server. This is automatically set, but you can pass it explicitly if desired. It is most commonly used for clarity when you are hosting an Epicenter project on your own server
  server.protocol https / http Defaults to https

Methods

get(filter[, options])

Retrieve details about particular end users in your team, based on user name or user id.

Parameters

Required? Name Type Description
Yes filter object Object with field userName and value of the username. Alternatively, object with field id and value of an array of user ids.
  options object Overrides for configuration options.

Example

var ua = new F.service.User({
    account: 'acme-simulations',
});
ua.get({ userName: 'jsmith' });
ua.get({ id: ['42836d4b-5b61-4fe4-80eb-3136e956ee5c',
                  '4ea75631-4c8d-4872-9d80-b4600146478e'] });

getById(userId[, options])

Retrieve details about a single end user in your team, based on user id.

Parameters

Required? Name Type Description
Yes userId string The user id for the end user in your team.
  options object Overrides for configuration options.

Example

var ua = new F.service.User({
    account: 'acme-simulations',
});
ua.getById('42836d4b-5b61-4fe4-80eb-3136e956ee5c');

createUsers(userList[, options])

Upload list of users to current account

Parameters

Required? Name Type Description
Yes userList Array.<object> Array of {userName, password, firstName, lastName, ...} objects to upload
  options object Overrides for configuration options.

Example

var us = new F.service.User({
    account: 'acme-simulations',
});
us.createUsers([{ userName: 'jsmith@forio.com', firstName: 'John', lastName: 'Smith', password: 'passw0rd' }]);