Deletes a specific option for a specific tracking category

Script xero Verified

by hugo697 ยท 12/20/2024

The script

Submitted by hugo697 Bun
Verified 515 days ago
1
//native
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