1 | |
2 | type Zoho = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Update note |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Zoho, |
11 | id: string, |
12 | body: { |
13 | data: { |
14 | Modified_Time: string; |
15 | $attachments: { |
16 | Owner: { name: string; id: string; email?: string }; |
17 | Modified_By: { name: string; id: string; email?: string }; |
18 | Created_By: { name: string; id: string; email?: string }; |
19 | Parent_Id: { id: string; name: string }; |
20 | $sharing_permission?: string; |
21 | $attachment_type?: number; |
22 | id: string; |
23 | Modified_Time: string; |
24 | Created_Time: string; |
25 | File_Name: string; |
26 | Size: string; |
27 | $editable: false | true; |
28 | $file_id: string; |
29 | $type: string; |
30 | $se_module: string; |
31 | $state: string; |
32 | $link_url: string; |
33 | }[]; |
34 | Owner: { name: string; id: string; email?: string }; |
35 | Created_Time: string; |
36 | Parent_Id: { |
37 | module?: { |
38 | api_name: string; |
39 | id: string; |
40 | module_name?: string; |
41 | module?: string; |
42 | }; |
43 | id?: string; |
44 | name?: string; |
45 | }; |
46 | $editable: false | true; |
47 | $is_shared_to_client: false | true; |
48 | $sharing_permission?: string; |
49 | Modified_By: { name: string; id: string; email?: string }; |
50 | $size: string; |
51 | $state: string; |
52 | $voice_note: false | true; |
53 | id: string; |
54 | Created_By: { name: string; id: string; email?: string }; |
55 | Note_Title: string; |
56 | Note_Content: string; |
57 | }[]; |
58 | }, |
59 | ) { |
60 | const url = new URL(`https://zohoapis.com/crm/v8/Notes/${id}`); |
61 |
|
62 | const response = await fetch(url, { |
63 | method: "PUT", |
64 | headers: { |
65 | "Content-Type": "application/json", |
66 | Authorization: "Zoho-oauthtoken " + auth.token, |
67 | }, |
68 | body: JSON.stringify(body), |
69 | }); |
70 | if (!response.ok) { |
71 | const text = await response.text(); |
72 | throw new Error(`${response.status} ${text}`); |
73 | } |
74 | return await response.json(); |
75 | } |
76 |
|