1 | |
2 | type Zoho = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Update currencies |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Zoho, |
11 | body: { |
12 | currencies: { |
13 | iso_code: string; |
14 | symbol: string; |
15 | created_time: string; |
16 | is_active: false | true; |
17 | exchange_rate: string; |
18 | format: { |
19 | decimal_separator: "Comma" | "Period"; |
20 | thousand_separator: "Comma" | "Period" | "Space"; |
21 | decimal_places: "0" | "2" | "3"; |
22 | }; |
23 | created_by: { name: string; id: string; email?: string }; |
24 | prefix_symbol: false | true; |
25 | is_base: false | true; |
26 | modified_time: string; |
27 | name: string; |
28 | modified_by: { name: string; id: string; email?: string }; |
29 | id: string; |
30 | }[]; |
31 | }, |
32 | ) { |
33 | const url = new URL(`https://zohoapis.com/crm/v8/org/currencies`); |
34 |
|
35 | const response = await fetch(url, { |
36 | method: "PUT", |
37 | headers: { |
38 | "Content-Type": "application/json", |
39 | Authorization: "Zoho-oauthtoken " + auth.token, |
40 | }, |
41 | body: JSON.stringify(body), |
42 | }); |
43 | if (!response.ok) { |
44 | const text = await response.text(); |
45 | throw new Error(`${response.status} ${text}`); |
46 | } |
47 | return await response.json(); |
48 | } |
49 |
|