1 | |
2 | type Zoho = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Update a tax authority [US and CA Edition only] |
7 | * Update the details of a tax authority. |
8 | */ |
9 | export async function main( |
10 | auth: Zoho, |
11 | tax_authority_id: string, |
12 | organization_id: string | undefined, |
13 | body: { |
14 | tax_authority_name?: string; |
15 | description?: string; |
16 | registration_number?: string; |
17 | registration_number_label?: string; |
18 | }, |
19 | ) { |
20 | const url = new URL( |
21 | `https://www.zohoapis.com/inventory/v1/settings/taxauthorities/${tax_authority_id}`, |
22 | ); |
23 | for (const [k, v] of [["organization_id", organization_id]]) { |
24 | if (v !== undefined && v !== "" && k !== undefined) { |
25 | url.searchParams.append(k, v); |
26 | } |
27 | } |
28 | const response = await fetch(url, { |
29 | method: "PUT", |
30 | headers: { |
31 | "Content-Type": "application/json", |
32 | Authorization: "Zoho-oauthtoken " + auth.token, |
33 | }, |
34 | body: JSON.stringify(body), |
35 | }); |
36 | if (!response.ok) { |
37 | const text = await response.text(); |
38 | throw new Error(`${response.status} ${text}`); |
39 | } |
40 | return await response.json(); |
41 | } |
42 |
|