1 | |
2 | type Zoho = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Update an organization |
7 | * Update the details of an organization. |
8 | */ |
9 | export async function main( |
10 | auth: Zoho, |
11 | organization_id: string, |
12 | body: { |
13 | name?: string; |
14 | fiscal_year_start_month?: string; |
15 | is_logo_uploaded?: false | true; |
16 | time_zone?: string; |
17 | date_format?: string; |
18 | field_separator?: string; |
19 | language_code?: string; |
20 | org_address?: string; |
21 | remit_to_address?: string; |
22 | address?: { |
23 | street_address1?: string; |
24 | street_address2?: string; |
25 | city?: string; |
26 | state?: string; |
27 | country?: string; |
28 | zip?: string; |
29 | }[]; |
30 | contact_name?: string; |
31 | phone?: string; |
32 | fax?: string; |
33 | website?: string; |
34 | email?: string; |
35 | currency_id?: string; |
36 | companyid_label?: string; |
37 | companyid_value?: string; |
38 | taxid_label?: string; |
39 | taxid_value?: string; |
40 | custom_fields?: { index?: number; value?: string; label?: string }[]; |
41 | }, |
42 | ) { |
43 | const url = new URL( |
44 | `https://www.zohoapis.com/inventory/v1/organizations/${organization_id}`, |
45 | ); |
46 |
|
47 | const response = await fetch(url, { |
48 | method: "PUT", |
49 | headers: { |
50 | "Content-Type": "application/json", |
51 | Authorization: "Zoho-oauthtoken " + auth.token, |
52 | }, |
53 | body: JSON.stringify(body), |
54 | }); |
55 | if (!response.ok) { |
56 | const text = await response.text(); |
57 | throw new Error(`${response.status} ${text}`); |
58 | } |
59 | return await response.json(); |
60 | } |
61 |
|