//native
type Vercel = {
token: string;
};
/**
* Update a Team Member
* Update the membership of a Team Member on the Team specified by `teamId`, such as changing the _role_ of the member, or confirming a request to join the Team for an unconfirmed member. The authenticated user must be an `OWNER` of the Team.
*/
export async function main(
auth: Vercel,
uid: string,
teamId: string,
body: {
confirmed?: true;
role?: string;
projects?: {
projectId: string;
role: "ADMIN" | "PROJECT_VIEWER" | "PROJECT_DEVELOPER";
}[];
joinedFrom?: { ssoUserId?: null };
},
) {
const url = new URL(
`https://api.vercel.com/v1/teams/${teamId}/members/${uid}`,
);
const response = await fetch(url, {
method: "PATCH",
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 428 days ago