//native
type Clickup = {
token: string;
};
/**
* Get singular time entry
* View a single time entry. \
\
***Note:** A time entry that has a negative duration means that timer is currently running for that user.*
*/
export async function main(
auth: Clickup,
team_id: string,
timer_id: string,
include_task_tags: string | undefined,
include_location_names: string | undefined,
include_approval_history: string | undefined,
include_approval_details: string | undefined,
Content_Type: string,
) {
const url = new URL(
`https://api.clickup.com/api/v2/team/${team_id}/time_entries/${timer_id}`,
);
for (const [k, v] of [
["include_task_tags", include_task_tags],
["include_location_names", include_location_names],
["include_approval_history", include_approval_history],
["include_approval_details", include_approval_details],
]) {
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 235 days ago