//native
type Square = {
token: string;
};
/**
* DeleteInvoiceAttachment
* Removes an attachment from an invoice and permanently deletes the file. Attachments can be removed only
from invoices in the `DRAFT`, `SCHEDULED`, `UNPAID`, or `PARTIALLY_PAID` state.
*/
export async function main(
auth: Square,
invoice_id: string,
attachment_id: string,
) {
const url = new URL(
`https://connect.squareup.com/v2/invoices/${invoice_id}/attachments/${attachment_id}`,
);
const response = await fetch(url, {
method: "DELETE",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago