1 | |
2 | type Zoho = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Update users unavailability |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Zoho, |
11 | body: { |
12 | users_unavailability: { |
13 | service: string; |
14 | title: string; |
15 | all_day: false | true; |
16 | tp_calendar_id: string; |
17 | tp_event_id: string; |
18 | comments: string; |
19 | from: string; |
20 | id: string; |
21 | to: string; |
22 | user: { name: string; id: string; zuid: string }; |
23 | }[]; |
24 | }, |
25 | ) { |
26 | const url = new URL( |
27 | `https://zohoapis.com/crm/v8/settings/users_unavailability`, |
28 | ); |
29 |
|
30 | const response = await fetch(url, { |
31 | method: "PUT", |
32 | headers: { |
33 | "Content-Type": "application/json", |
34 | Authorization: "Zoho-oauthtoken " + auth.token, |
35 | }, |
36 | body: JSON.stringify(body), |
37 | }); |
38 | if (!response.ok) { |
39 | const text = await response.text(); |
40 | throw new Error(`${response.status} ${text}`); |
41 | } |
42 | return await response.json(); |
43 | } |
44 |
|