1 | |
2 | type Clickup = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Get Filtered Team Tasks |
7 | * View the tasks that meet specific criteria from a Workspace. Responses are limited to 100 tasks per page. \ |
8 | \ |
9 | You can only view task information of tasks you can access. \ |
10 | \ |
11 | Our Try It modal currently supports filtering by two or more Lists, Folders, or Spaces. To filter by a single List, Folder, or Space, we recommend using a free app like [Postman](https://www.postman.com/) to test our public API. |
12 | */ |
13 | export async function main( |
14 | auth: Clickup, |
15 | team_Id: string, |
16 | page: string | undefined, |
17 | order_by: string | undefined, |
18 | reverse: string | undefined, |
19 | subtasks: string | undefined, |
20 | space_ids: string | undefined, |
21 | project_ids: string | undefined, |
22 | list_ids__: string | undefined, |
23 | statuses: string | undefined, |
24 | include_closed: string | undefined, |
25 | assignees: string | undefined, |
26 | tags: string | undefined, |
27 | due_date_gt: string | undefined, |
28 | due_date_lt: string | undefined, |
29 | date_created_gt: string | undefined, |
30 | date_created_lt: string | undefined, |
31 | date_updated_gt: string | undefined, |
32 | date_updated_lt: string | undefined, |
33 | date_done_gt: string | undefined, |
34 | date_done_lt: string | undefined, |
35 | custom_fields: string | undefined, |
36 | custom_task_ids: string | undefined, |
37 | team_id: string | undefined, |
38 | parent: string | undefined, |
39 | include_markdown_description: string | undefined, |
40 | custom_items: string | undefined, |
41 | ) { |
42 | const url = new URL(`https://api.clickup.com/api/v2/team/${team_Id}/task`); |
43 | for (const [k, v] of [ |
44 | ["page", page], |
45 | ["order_by", order_by], |
46 | ["reverse", reverse], |
47 | ["subtasks", subtasks], |
48 | ["space_ids", space_ids], |
49 | ["project_ids", project_ids], |
50 | ["list_ids[]", list_ids__], |
51 | ["statuses", statuses], |
52 | ["include_closed", include_closed], |
53 | ["assignees", assignees], |
54 | ["tags", tags], |
55 | ["due_date_gt", due_date_gt], |
56 | ["due_date_lt", due_date_lt], |
57 | ["date_created_gt", date_created_gt], |
58 | ["date_created_lt", date_created_lt], |
59 | ["date_updated_gt", date_updated_gt], |
60 | ["date_updated_lt", date_updated_lt], |
61 | ["date_done_gt", date_done_gt], |
62 | ["date_done_lt", date_done_lt], |
63 | ["custom_fields", custom_fields], |
64 | ["custom_task_ids", custom_task_ids], |
65 | ["team_id", team_id], |
66 | ["parent", parent], |
67 | ["include_markdown_description", include_markdown_description], |
68 | ["custom_items", custom_items], |
69 | ]) { |
70 | if (v !== undefined && v !== "" && k !== undefined) { |
71 | url.searchParams.append(k, v); |
72 | } |
73 | } |
74 | const response = await fetch(url, { |
75 | method: "GET", |
76 | headers: { |
77 | Authorization: auth.token, |
78 | }, |
79 | body: undefined, |
80 | }); |
81 | if (!response.ok) { |
82 | const text = await response.text(); |
83 | throw new Error(`${response.status} ${text}`); |
84 | } |
85 | return await response.json(); |
86 | } |
87 |
|