1 | |
2 | type Zoho = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Update currency |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Zoho, |
11 | id: string, |
12 | body: { |
13 | currencies: { |
14 | iso_code: string; |
15 | symbol: string; |
16 | created_time: string; |
17 | is_active: false | true; |
18 | exchange_rate: string; |
19 | format: { |
20 | decimal_separator: "Comma" | "Period"; |
21 | thousand_separator: "Comma" | "Period" | "Space"; |
22 | decimal_places: "0" | "2" | "3"; |
23 | }; |
24 | created_by: { name: string; id: string; email?: string }; |
25 | prefix_symbol: false | true; |
26 | is_base: false | true; |
27 | modified_time: string; |
28 | name: string; |
29 | modified_by: { name: string; id: string; email?: string }; |
30 | id: string; |
31 | }[]; |
32 | }, |
33 | ) { |
34 | const url = new URL(`https://zohoapis.com/crm/v8/org/currencies/${id}`); |
35 |
|
36 | const response = await fetch(url, { |
37 | method: "PUT", |
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 |
|