//native
type Xero = {
token: string
}
/**
* Sends a copy of a specific invoice to related contact via email
*
*/
export async function main(
auth: Xero,
InvoiceID: string,
xero_tenant_id: string,
Idempotency_Key: string,
body: { Status?: string }
) {
const url = new URL(`https://api.xero.com/api.xro/2.0/Invoices/${InvoiceID}/Email`)
const response = await fetch(url, {
method: 'POST',
headers: {
Accept: 'application/json',
'xero-tenant-id': xero_tenant_id,
'Idempotency-Key': Idempotency_Key,
'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.text()
}
Submitted by hugo697 448 days ago