//native
/**
* Create Invoice
* Create an invoice. Required: invoice-number, invoice-date, supplier, currency, invoice-lines; field names use dashes.
*/
export async function main(auth: RT.Coupa, body: { [key: string]: any }) {
const base = auth.instance_url.replace(/\/+$/, "")
const url = new URL(`${base}/api/invoices`)
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: `Bearer ${auth.token}`,
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify(body),
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
if (response.status === 204) return { success: true }
return await response.json()
}
Submitted by hugo989 3 hours ago