//native
type Gitbook = {
token: string;
};
/**
* Updates members of a team
* Updates members of an organization team, either adding or removing them. If a the same user is included as both an add and a remove, they will be removed from the team.
*/
export async function main(
auth: Gitbook,
organizationId: string,
teamId: string,
body: { add?: string[]; memberships?: {}; remove?: string[] },
) {
const url = new URL(
`https://api.gitbook.com/v1/orgs/${organizationId}/teams/${teamId}/members`,
);
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 235 days ago