1 | |
2 | type Clickup = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Search Docs |
7 | * View the Docs in your Workspace. You can only view information of Docs you can access. |
8 | */ |
9 | export async function main( |
10 | auth: Clickup, |
11 | workspaceId: string, |
12 | id: string | undefined, |
13 | creator: string | undefined, |
14 | deleted: string | undefined, |
15 | archived: string | undefined, |
16 | parent_id: string | undefined, |
17 | parent_type: string | undefined, |
18 | limit: string | undefined, |
19 | next_cursor: string | undefined, |
20 | ) { |
21 | const url = new URL( |
22 | `https://api.clickup.com/api/v3/workspaces/${workspaceId}/docs`, |
23 | ); |
24 | for (const [k, v] of [ |
25 | ["id", id], |
26 | ["creator", creator], |
27 | ["deleted", deleted], |
28 | ["archived", archived], |
29 | ["parent_id", parent_id], |
30 | ["parent_type", parent_type], |
31 | ["limit", limit], |
32 | ["next_cursor", next_cursor], |
33 | ]) { |
34 | if (v !== undefined && v !== "" && k !== undefined) { |
35 | url.searchParams.append(k, v); |
36 | } |
37 | } |
38 | const response = await fetch(url, { |
39 | method: "GET", |
40 | headers: { |
41 | Authorization: auth.token, |
42 | }, |
43 | body: undefined, |
44 | }); |
45 | if (!response.ok) { |
46 | const text = await response.text(); |
47 | throw new Error(`${response.status} ${text}`); |
48 | } |
49 | return await response.json(); |
50 | } |
51 |
|