//native
type Codat = {
encodedKey: string
}
/**
* Update company
* Use the *Update company* endpoint to update the name, description, or tags of the company.
The *Update company* endpoint doesn't have any required fields. If any of the fields provided are `null` or not provided, they won't be included in the update.
A [company](https://docs.codat.io/sync-for-payables-api#/schemas/Company) represents a business sharing access to their data.
*/
export async function main(
auth: Codat,
companyId: string,
body: { name?: string; description?: string; tags?: {} }
) {
const url = new URL(`https://api.codat.io/companies/${companyId}`)
const response = await fetch(url, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
Authorization: `Basic ${auth.encodedKey}`
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 235 days ago