//native
type Clickup = {
token: string;
};
/**
* Update a time Entry
* Update the details of a time entry.
*/
export async function main(
auth: Clickup,
team_id: string,
timer_id: string,
custom_task_ids: string | undefined,
body: {
description?: string;
tags: { name: string; tag_fg: string; tag_bg: string }[];
tag_action?: string;
start?: number;
end?: number;
tid: string;
billable?: false | true;
duration?: number;
},
) {
const url = new URL(
`https://api.clickup.com/api/v2/team/${team_id}/time_entries/${timer_id}`,
);
for (const [k, v] of [["custom_task_ids", custom_task_ids]]) {
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 168 days ago