The "Team" Class

Import the Team class using one of the following:

import { Team } from '@inventives/coforio-sdk';
const { Team } = require('@inventives/coforio.sdk');

Typically though, you would only want to use the Team object as instantiated from the Coforio object. See The "Coforio" Class reference.

Class Constructor

const team = new Team(id, {}, null);

Arguments

  • id - team ID
  • headers - (Optional) authorization headers. You can get this from the Coforio object: cio.headers.
  • token - (Optional) user authorization token to perform actions on behalf of a user

Class Methods

Team.Get

await team.Get();

Latest team data will be present in the team.data property.

Team.Update

await team.Update({/* data */}, scopes, name);

Arguments

  • data - difference of data object to update; only the passed properties in data will be updated. To remove a property, set the value as null.
  • scopes - (Optional) a list of access scopes to set for the team
  • name - (Optional) team name

Team.Delete

await team.Delete();

Team.ListMemberships

const memberships = await team.ListMemberships();

Returns

  • A list of team membership objects - with each containing the membership id, access_level, and the corresponding team member's user object.

Team.GetMembershipById, Team.GetMembershipByUserId, Team.GetMembershipByUserEmail

const membership = await team.GetMembershipById(id);
const membership = await team.GetMembershipByUserId(userId);
const membership = await team.GetMembershipByUserEmail(userEmail);

Arguments

  • id - membership ID
  • userId - member user ID
  • userEmail - member user Email

Returns

  • A membership object containing the membership id, access_level, and the corresponding team member's user object.

Team.UpdateMembership

await team.UpdateMembership(id, { access_level, scopes, data });

Arguments

  • id - membership ID
  • access_level - (Optional) desired user access level for the team; one of: member, admin, or owner
  • scopes - (Optional) a list of access scopes to provide for the membership
  • data - (Optional) any custom membership data to be stored for the team member

Team.DeregisterMember

await team.DeregisterMember(id);

Arguments

  • id - membership ID

📘

Email Notification

The team member will receive an email informing them that their membership from the team has been revoked.

Team.Invite

await team.Invite(email, access_level='member', data={}, scopes=[], redirect_uri);

Arguments

  • email - new member's email address
  • access_level - (Optional) desired user access level for the team; one of: member, admin, or owner
  • data - (Optional) any custom membership data to be stored for the team member
  • scopes - (Optional) a list of access scopes to provide for the new member
  • redirect_uri - (Optional, but HIGHLY RECOMMENDED) URL to send the user to login to on the frontend after account is created.

👍

Accept invitation using link in email

The new member will receive an email to accept the invitation to join the team. They can click on the link to connect an existing Cofor.io account or create a new one and join the team.