1 | |
2 | type Zoho = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Update variables |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Zoho, |
11 | body: { |
12 | variables: { |
13 | api_name: string; |
14 | name: string; |
15 | description: string; |
16 | source: string; |
17 | id: string; |
18 | type: |
19 | | "date" |
20 | | "website" |
21 | | "double" |
22 | | "textarea" |
23 | | "integer" |
24 | | "percent" |
25 | | "long" |
26 | | "datetime" |
27 | | "phone" |
28 | | "checkbox" |
29 | | "currency" |
30 | | "text" |
31 | | "email"; |
32 | variable_group: { id: string; api_name: string; name: string }; |
33 | read_only: false | true; |
34 | value: {}; |
35 | }[]; |
36 | }, |
37 | ) { |
38 | const url = new URL(`https://zohoapis.com/crm/v8/settings/variables`); |
39 |
|
40 | const response = await fetch(url, { |
41 | method: "PUT", |
42 | headers: { |
43 | "Content-Type": "application/json", |
44 | Authorization: "Zoho-oauthtoken " + auth.token, |
45 | }, |
46 | body: JSON.stringify(body), |
47 | }); |
48 | if (!response.ok) { |
49 | const text = await response.text(); |
50 | throw new Error(`${response.status} ${text}`); |
51 | } |
52 | return await response.json(); |
53 | } |
54 |
|