forio Toggle navigation

Member API Adapter

The Member API Adapter provides methods to look up information about end users for your project and how they are divided across groups. It is based on query capabilities of the underlying RESTful Member API.

This is only needed for Authenticated projects, that is, team projects with end users and groups. For example, if some of your end users are facilitators, or if your end users should be treated differently based on which group they are in, use the Member API to find that information.

const ma = new F.service.Member();
ma.getGroupsForUser({ userId: 'b6b313a3-ab84-479c-baea-206f6bff337' });
ma.getGroupDetails({ groupId: '00b53308-9833-47f2-b21e-1278c07d53b8' });

Constructor options

Required? Name Type Description
  userId string Epicenter user id.
  groupId string Epicenter group id. Note that this is the group id, not the group name.
  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

getGroupsForUser(params[, options])

Retrieve details about all of the group memberships for one end user. The membership details are returned in an array, with one element (group record) for each group to which the end user belongs.

In the membership array, each group record includes the group id, project id, account (team) id, and an array of members. However, only the user whose userId is included in the call is listed in the members array (regardless of whether there are other members in this group).

Parameters

Required? Name Type Description
Yes params string / object The user id for the end user. Alternatively, an object with field userId and value the user id.
  options object Overrides for configuration options.

Example

const ma = new F.service.Member();
ma.getGroupsForUser('42836d4b-5b61-4fe4-80eb-3136e956ee5c')
    .then(function(memberships){
        for (const i=0; i<memberships.length; i++) {
            console.log(memberships[i].groupId);
        }
    });

ma.getGroupsForUser({ userId: '42836d4b-5b61-4fe4-80eb-3136e956ee5c' });

addUsersToGroup(userlist[, groupId, options])

Add given userids to group

Parameters

Required? Name Type Description
Yes userlist Array.<string> / Array.<{ userId: string }> list of users to add to group. [userId1,userId2..] or [{userid: userId},{userId: userId2}...]
  groupId string Group to add users to. Pulls current group from session if not provided
  options object Overrides for configuration options.

Example

const ma = new F.service.Member();
ma.addUsersToGroup(['42836d4b-5b61-4fe4-80eb-3136e956ee5c', '42836d4b-5b61-4fe4-80eb-3136e956ee5c'])

getGroupDetails(params[, options])

Retrieve details about one group, including an array of all its members.

Parameters

Required? Name Type Description
Yes params string / object The group id. Alternatively, an object with field groupId and value the group id.
  options object Overrides for configuration options.

Example

const ma = new F.service.Member();
ma.getGroupDetails('80257a25-aa10-4959-968b-fd053901f72f')
    .then(function(group){
        for (const i=0; i<group.members.length; i++) {
            console.log(group.members[i].userName);
        }
    });

ma.getGroupDetails({ groupId: '80257a25-aa10-4959-968b-fd053901f72f' });

makeUserActive(params[, options])

Set a particular end user as active. Active end users can be assigned to worlds in multiplayer games during automatic assignment.

Parameters

Required? Name Type Description
Yes params object The end user and group information.
Yes params.userId string / Array.<string> The id or list of ids of the end user(s) to make active.
Yes params.groupId string The id of the group to which this end user belongs, and in which the end user should become active.
  options object Overrides for configuration options.

Example

const ma = new F.service.Member();
ma.makeUserActive({ userId: '42836d4b-5b61-4fe4-80eb-3136e956ee5c',
                          groupId: '80257a25-aa10-4959-968b-fd053901f72f' });

makeUserInactive(params[, options])

Set a particular end user as inactive. Inactive end users are not assigned to worlds in multiplayer games during automatic assignment.

Parameters

Required? Name Type Description
Yes params object The end user and group information.
Yes params.userId string / Array.<string> The id or list of ids of the end user(s) to make inactive.
Yes params.groupId string The id of the group to which this end user belongs, and in which the end user should become inactive.
  options object Overrides for configuration options.

Example

const ma = new F.service.Member();
ma.makeUserInactive({ userId: '42836d4b-5b61-4fe4-80eb-3136e956ee5c',
  groupId: '80257a25-aa10-4959-968b-fd053901f72f' });