//native
/**
* Create Supplier
* Create a supplier. Only name is required; field names use dashes, e.g. display-name, po-email, primary-contact.
*/
export async function main(auth: RT.Coupa, body: { [key: string]: any }) {
const base = auth.instance_url.replace(/\/+$/, "")
const url = new URL(`${base}/api/suppliers`)
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