1 | |
2 | type Zoho = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Create global picklist |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Zoho, |
11 | body: { |
12 | global_picklists: { |
13 | display_label: string; |
14 | created_time: string; |
15 | modified_time: string; |
16 | id: string; |
17 | api_name: string; |
18 | actual_label: string; |
19 | description: string; |
20 | modified_by: { name: string; id: string; email?: string }; |
21 | created_by: { name: string; id: string; email?: string }; |
22 | presence: false | true; |
23 | pick_list_values_sorted_lexically: false | true; |
24 | pick_list_values: { |
25 | actual_value: string; |
26 | type: "unused" | "used"; |
27 | id: string; |
28 | sequence_number: number; |
29 | display_value: string; |
30 | }[]; |
31 | }[]; |
32 | }, |
33 | ) { |
34 | const url = new URL(`https://zohoapis.com/crm/v8/settings/global_picklists`); |
35 |
|
36 | const response = await fetch(url, { |
37 | method: "POST", |
38 | headers: { |
39 | "Content-Type": "application/json", |
40 | Authorization: "Zoho-oauthtoken " + auth.token, |
41 | }, |
42 | body: JSON.stringify(body), |
43 | }); |
44 | if (!response.ok) { |
45 | const text = await response.text(); |
46 | throw new Error(`${response.status} ${text}`); |
47 | } |
48 | return await response.json(); |
49 | } |
50 |
|