1 | |
2 | type Zoho = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Remove territories from record |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Zoho, |
11 | id: string, |
12 | module_api_name: string, |
13 | body: { |
14 | data?: { |
15 | id?: string; |
16 | Created_By?: { name: string; id: string; email?: string }; |
17 | Created_Time?: string; |
18 | Modified_By?: { name: string; id: string; email?: string }; |
19 | Modified_Time?: string; |
20 | Tag?: { |
21 | name: string; |
22 | color_code: |
23 | | "#57B1FD" |
24 | | "#879BFC" |
25 | | "#658BA8" |
26 | | "#FD87BD" |
27 | | "#969696" |
28 | | "#F48435" |
29 | | "#1DB9B4" |
30 | | "#E7A826" |
31 | | "#63C57E" |
32 | | "#F17574" |
33 | | "#D297EE" |
34 | | "#A8C026" |
35 | | "#B88562"; |
36 | created_time: string; |
37 | modified_time: string; |
38 | modified_by: { name: string; id: string; email?: string }; |
39 | created_by: { name: string; id: string; email?: string }; |
40 | id: string; |
41 | }[]; |
42 | name?: string; |
43 | }[]; |
44 | trigger?: string[]; |
45 | process?: string[]; |
46 | duplicate_check_fields?: string[]; |
47 | wf_trigger?: string; |
48 | lar_id?: string; |
49 | }, |
50 | ) { |
51 | const url = new URL( |
52 | `https://zohoapis.com/crm/v8/${module_api_name}/${id}/actions/remove_territories`, |
53 | ); |
54 |
|
55 | const response = await fetch(url, { |
56 | method: "POST", |
57 | headers: { |
58 | "Content-Type": "application/json", |
59 | Authorization: "Zoho-oauthtoken " + auth.token, |
60 | }, |
61 | body: JSON.stringify(body), |
62 | }); |
63 | if (!response.ok) { |
64 | const text = await response.text(); |
65 | throw new Error(`${response.status} ${text}`); |
66 | } |
67 | return await response.json(); |
68 | } |
69 |
|