//native
/**
* Update Supplier
* Update a supplier by ID. Pass only the fields to change; field names use dashes, e.g. po-email, payment-method.
*/
export async function main(
auth: RT.Coupa,
supplier_id: number,
body: { [key: string]: any }
) {
const base = auth.instance_url.replace(/\/+$/, "")
const url = new URL(`${base}/api/suppliers/${supplier_id}`)
const response = await fetch(url, {
method: "PUT",
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