//native
type Codat = {
encodedKey: string
}
/**
* Set configuration
* Use *Set configuration* endpoint to configure a given company ID.
*/
export async function main(
auth: Codat,
companyId: string,
body: {
companyId?: string
accountingSoftwareCompanyName?: string
enabled?: false | true
configured?: false | true
schedule?: {
selectedFrequency?: string
frequencyOptions?: string[]
startDate?: string
syncHourUtc?: number
timeZoneIanaId?: string
}
configuration?: {
syncAsBankFeeds?: {
enableSync?: false | true
selectedBankAccountId?: string
bankAccountOptions?: {
id?: string
name?: string
accountType?: string
}[]
}
syncAsExpenses?: {
enableSync?: false | true
supplier?: {
selectedSupplierId?: string
supplierOptions?: { id?: string; name?: string }[]
}
customer?: {
selectedCustomerId?: string
customerOptions?: { id?: string; name?: string }[]
}
selectedBankAccountId?: string
bankAccountOptions?: {
id?: string
name?: string
accountType?: string
}[]
}
}
}
) {
const url = new URL(`https://api.codat.io/companies/${companyId}/sync/banking/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