1 | |
2 | type Clickup = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Update Space |
7 | * Rename, set the Space color, and enable ClickApps for a Space. |
8 | */ |
9 | export async function main( |
10 | auth: Clickup, |
11 | space_id: string, |
12 | body: { |
13 | name: string; |
14 | color: string; |
15 | private: false | true; |
16 | admin_can_manage: false | true; |
17 | multiple_assignees: false | true; |
18 | features: { |
19 | due_dates: { |
20 | enabled: false | true; |
21 | start_date: false | true; |
22 | remap_due_dates: false | true; |
23 | remap_closed_due_date: false | true; |
24 | }; |
25 | time_tracking: { enabled: false | true }; |
26 | tags: { enabled: false | true }; |
27 | time_estimates: { enabled: false | true }; |
28 | checklists: { enabled: false | true }; |
29 | custom_fields: { enabled: false | true }; |
30 | remap_dependencies: { enabled: false | true }; |
31 | dependency_warning: { enabled: false | true }; |
32 | portfolios: { enabled: false | true }; |
33 | }; |
34 | }, |
35 | ) { |
36 | const url = new URL(`https://api.clickup.com/api/v2/space/${space_id}`); |
37 |
|
38 | const response = await fetch(url, { |
39 | method: "PUT", |
40 | headers: { |
41 | "Content-Type": "application/json", |
42 | Authorization: auth.token, |
43 | }, |
44 | body: JSON.stringify(body), |
45 | }); |
46 | if (!response.ok) { |
47 | const text = await response.text(); |
48 | throw new Error(`${response.status} ${text}`); |
49 | } |
50 | return await response.json(); |
51 | } |
52 |
|