//native
type Codat = {
encodedKey: string
}
/**
* Set company configuration
* Sets a companies expense sync configuration
*/
export async function main(
auth: Codat,
companyId: string,
body: {
bankAccount: { id?: string }
supplier: { id?: string }
customer: { id?: string }
}
) {
const url = new URL(`https://api.codat.io/companies/${companyId}/sync/expenses/config`)
const response = await fetch(url, {
method: 'POST',
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