//native
type Box = {
token: string;
};
/**
* Assign task
* Assigns a task to a user.
A task can be assigned to more than one user by creating multiple
assignments.
*/
export async function main(
auth: Box,
body: {
task: { id: string; type: "task" };
assign_to: { id?: string; login?: string };
},
) {
const url = new URL(`https://api.box.com/2.0/task_assignments`);
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 235 days ago