//native
type Clickup = {
token: string;
};
/**
* Update Task
* Update a task by including one or more fields in the request body.
*/
export async function main(
auth: Clickup,
task_id: string,
custom_task_ids: string | undefined,
team_id: string | undefined,
body: {
custom_item_id?: number;
name?: string;
description?: string;
markdown_content?: string;
status?: string;
priority?: number;
due_date?: number;
due_date_time?: false | true;
parent?: string;
time_estimate?: number;
start_date?: number;
start_date_time?: false | true;
points?: number;
assignees?: { add: number[]; rem: number[] };
group_assignees?: { add?: number[]; rem?: number[] };
watchers?: { add: number[]; rem: number[] };
archived?: false | true;
},
) {
const url = new URL(`https://api.clickup.com/api/v2/task/${task_id}`);
for (const [k, v] of [
["custom_task_ids", custom_task_ids],
["team_id", team_id],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: 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