Teams methods

If your UI App must enable users to work with the teams in the Gtmhub account it's installed to, you can leverage the Teams methods from the UI Apps SDK. You can perform all CRUD operations with the SDK. For example, if you UI App enables users to import organizational structure from another system in Gtmhub, you can use the Teams methods to get the task done easily.

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

createTeam

To create a Team, use the createTeam method and pass a payload object with the properties of the new team you are creating. For a full reference of the available and required properties of the Team object, refer to the Create Team REST API Endpoint

const createTeamPayload = { 
 name: "my-team",
 description: "",
 color: "#87a6bc",
 avatar: "users_multiple-11",
 customFields: {},
 picture: ""
};

sdk
  .createTeam(createTeamPayload)
  .then((team) => console.log(team));

getTeams

To get a list of teams, use the getTeams method. You can pass filtering, sorting, paging and field projection parameters in a payload object. For example, to get the IDs of the first 15 teams, sorted alphabetically you can say:

const getTeamsPayload = { sort: "name", skip: 0, limit: 15, fields: "id" };

sdk
  .getTeams(getTeamsPayload).then(teams => console.log(teams));

Check out the Get Teams 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:

getTeam

To get an existing team, use the getTeam method and pass the desired team's Id. For example:

const teamId = "some-test-team-id";

sdk
  .getTeam(teamId)
  .then((team) => console.log(team));

updateTeam

To update a team, use the updateTeam method and pass a payload object with the properties you must update. For example, to update the name of a team you can say:

  • Update team by id:
const updateTeamPayload = { id: "some-test-team-id", name: "my-new-team-name"};

sdk
  .updateTeam(updateTeamPayload)
  .then((team) => console.log(team));

NOTE When updating a team, your payload must always contain an id property with the value of the Id of the team you are updating.

deleteTeam

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

const teamId = "some-test-team-id";

sdk.deleteTeam(teamId);