1 | |
2 | type Zoho = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Add appointments rescheduled history |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Zoho, |
11 | body: { |
12 | data: { |
13 | $currency_symbol: string; |
14 | Rescheduled_To: string; |
15 | $review_process: false | true; |
16 | Reschedule_Reason: string; |
17 | $sharing_permission: string; |
18 | Name: string; |
19 | Modified_By: { name: string; id: string; email: string }; |
20 | $review: false | true; |
21 | Rescheduled_By: { name: string; id: string; email: string }; |
22 | $state: string; |
23 | $canvas_id: string; |
24 | $process_flow: false | true; |
25 | id: string; |
26 | Rescheduled_Time: string; |
27 | $zia_visions: false | true; |
28 | $approved: false | true; |
29 | Modified_Time: string; |
30 | $approval: { |
31 | delegate: false | true; |
32 | approve: false | true; |
33 | reject: false | true; |
34 | resubmit: false | true; |
35 | }; |
36 | Created_Time: string; |
37 | Rescheduled_From: string; |
38 | Appointment_Name: { name: string; id: string }; |
39 | $editable: false | true; |
40 | $orchestration: false | true; |
41 | $in_merge: false | true; |
42 | Created_By: { name: string; id: string; email: string }; |
43 | $approval_state: string; |
44 | Reschedule_Note: string; |
45 | }[]; |
46 | }, |
47 | ) { |
48 | const url = new URL( |
49 | `https://zohoapis.com/crm/v8/Appointments_Rescheduled_History__s`, |
50 | ); |
51 |
|
52 | const response = await fetch(url, { |
53 | method: "POST", |
54 | headers: { |
55 | "Content-Type": "application/json", |
56 | Authorization: "Zoho-oauthtoken " + auth.token, |
57 | }, |
58 | body: JSON.stringify(body), |
59 | }); |
60 | if (!response.ok) { |
61 | const text = await response.text(); |
62 | throw new Error(`${response.status} ${text}`); |
63 | } |
64 | return await response.json(); |
65 | } |
66 |
|