Users methods

To enable CRUD operations with the Quantive account users in your UI App you must use the Users SDK methods. For example, your UI App may enable users to view a list of users from an external system and selectively import them in Quantive Results.

NOTE: Before you start using the SDK methods, ensure you have imported and configured the SDK first.

createUser

To create a user, use the createuser method and pass a payload object with the properties of the new user you are creating. For a full list of the available and required properties of a Quantive Results User object, refer to the Create User REST API Endpoint.

For example, to create a new user and set their email, first and last names you can say:

const createUserPayload = { 
  firstName: "my-user",
  lastName: "user-last-name",
  email: "my-user@gmail.com"
};

sdk
  .createUser(createUserPayload)
  .then((user) => console.log(user));

getUsers

To get a list of users, use the getusers method. You can pass sorting, filtering, paging and field projection parameters in a payload object. For example, to get the first 15 users, sorted by their first name, and specify that you need only a selected list of their properties, you can say:

  • Get multiple users:
const getUsersPayload = { 
  sort: "firstName",
  skip: 0,
  limit: 15,
  fields: "id,email,firstName,lastName,picture,teamIds,managedTeamIds,badges"
};

sdk
  .getUsers(getUsersPayload)
  .then((users) => console.log(users));

Check out the Get Users REST API endpoint for a full list of the supported parameters you can pass in your query. For more information on constructing the filter expression, paging, sorting and field projection refer to these articles:

getUser

To get an existing user, use the getUser endpoint and pass the desired user's Id. For example:

const userId = "some-test-user-id";

sdk
  .getUser(userId)
  .then((user) => console.log(user));

getCurrentUser

To get the current Quantive Results user interacting with your UI App, use the getCurrentUser helper method.

updateUser

To update a user, use the updateUser method and pass the properties you must update in a payload object. For example, to update the first name of a user, you can say:

const updateUserPayload = {id: "some-test-user-id", firstName: "desired-new-name"};

sdk
  .updateUser(updateUserPayload)
  .then((user) => console.log(user));

NOTE When updating a user, your payload must always include an id property set to the Id of the desired user you are updating.

deleteUser

To delete a user, use the deleteUser method and pass the desired user's Id. For example:

const userId = "some-test-user-id";

sdk.deleteUser(userId);