type Asana = {
token: string;
};
/**
* Remove a user from a workspace or organization
* Remove a user from a workspace or organization.
The user making this call must be an admin in the workspace. The user can be referenced by their globally unique user ID or their email address.
Returns an empty data record.
*/
export async function main(
auth: Asana,
workspace_gid: string,
opt_pretty: string | undefined,
opt_fields: string | undefined,
body: { data?: { user?: string; [k: string]: unknown }; [k: string]: unknown }
) {
const url = new URL(
`https://app.asana.com/api/1.0/workspaces/${workspace_gid}/removeUser`
);
for (const [k, v] of [
["opt_pretty", opt_pretty],
["opt_fields", opt_fields],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "POST",
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 383 days ago
type Asana = {
token: string;
};
/**
* Remove a user from a workspace or organization
* Remove a user from a workspace or organization.
The user making this call must be an admin in the workspace. The user can be referenced by their globally unique user ID or their email address.
Returns an empty data record.
*/
export async function main(
auth: Asana,
workspace_gid: string,
opt_pretty: string | undefined,
opt_fields: string | undefined,
body: { data?: { user?: string; [k: string]: unknown }; [k: string]: unknown }
) {
const url = new URL(
`https://app.asana.com/api/1.0/workspaces/${workspace_gid}/removeUser`
);
for (const [k, v] of [
["opt_pretty", opt_pretty],
["opt_fields", opt_fields],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "POST",
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 937 days ago