//native
type Clickup = {
token: string;
};
/**
* Get tracked time
* ***Note:** This is a legacy time tracking endpoint. We recommend using the Time Tracking API endpoints to manage time entries.*
*/
export async function main(
auth: Clickup,
task_id: string,
custom_task_ids: string | undefined,
team_id: string | undefined,
Content_Type: string,
) {
const url = new URL(`https://api.clickup.com/api/v2/task/${task_id}/time`);
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: "GET",
headers: {
"Content-Type": Content_Type,
Authorization: auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 168 days ago