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