1 | |
2 | type Clickup = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Get singular time entry |
7 | * View a single time entry. \ |
8 | \ |
9 | ***Note:** A time entry that has a negative duration means that timer is currently running for that user.* |
10 | */ |
11 | export async function main( |
12 | auth: Clickup, |
13 | team_id: string, |
14 | timer_id: string, |
15 | include_task_tags: string | undefined, |
16 | include_location_names: string | undefined, |
17 | include_approval_history: string | undefined, |
18 | include_approval_details: string | undefined, |
19 | Content_Type: string, |
20 | ) { |
21 | const url = new URL( |
22 | `https://api.clickup.com/api/v2/team/${team_id}/time_entries/${timer_id}`, |
23 | ); |
24 | for (const [k, v] of [ |
25 | ["include_task_tags", include_task_tags], |
26 | ["include_location_names", include_location_names], |
27 | ["include_approval_history", include_approval_history], |
28 | ["include_approval_details", include_approval_details], |
29 | ]) { |
30 | if (v !== undefined && v !== "" && k !== undefined) { |
31 | url.searchParams.append(k, v); |
32 | } |
33 | } |
34 | const response = await fetch(url, { |
35 | method: "GET", |
36 | headers: { |
37 | "Content-Type": Content_Type, |
38 | Authorization: auth.token, |
39 | }, |
40 | body: undefined, |
41 | }); |
42 | if (!response.ok) { |
43 | const text = await response.text(); |
44 | throw new Error(`${response.status} ${text}`); |
45 | } |
46 | return await response.json(); |
47 | } |
48 |
|