1 | |
2 | type Xero = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Deletes a specific option for a specific tracking category |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Xero, |
11 | TrackingCategoryID: string, |
12 | TrackingOptionID: string, |
13 | xero_tenant_id: string, |
14 | ) { |
15 | const url = new URL( |
16 | `https://api.xero.com/api.xro/2.0/TrackingCategories/${TrackingCategoryID}/Options/${TrackingOptionID}`, |
17 | ); |
18 |
|
19 | const response = await fetch(url, { |
20 | method: "DELETE", |
21 | headers: { |
22 | Accept: 'application/json', |
23 | "xero-tenant-id": xero_tenant_id, |
24 | Authorization: "Bearer " + auth.token, |
25 | }, |
26 | body: undefined, |
27 | }); |
28 | if (!response.ok) { |
29 | const text = await response.text(); |
30 | throw new Error(`${response.status} ${text}`); |
31 | } |
32 | return await response.json(); |
33 | } |
34 |
|