//native
type Segment = {
token: string;
baseUrl: string;
};
/**
* Replace Users in User Group
* Replaces the members of a user group by email.
*/
export async function main(
auth: Segment,
userGroupId: string,
body: { emails: string[] },
) {
const url = new URL(`${auth.baseUrl}/group/${userGroupId}/users`);
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.json();
}
Submitted by hugo697 235 days ago