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