//native
type Square = {
token: string;
};
/**
* UpdateItemTaxes
* Updates the [CatalogTax]($m/CatalogTax) objects that apply to the
targeted [CatalogItem]($m/CatalogItem) without having to perform an
upsert on the entire item.
*/
export async function main(
auth: Square,
body: {
item_ids: string[];
taxes_to_enable?: string[];
taxes_to_disable?: string[];
},
) {
const url = new URL(
`https://connect.squareup.com/v2/catalog/update-item-taxes`,
);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago