//native
type Codat = {
encodedKey: string
}
/**
* Sync new
* Run a Commerce sync from the last successful sync up to the date provided (optional), otherwise UtcNow is used.
If there was no previously successful sync, the start date in the config is used.
*/
export async function main(auth: Codat, companyId: string, body: { syncTo?: string }) {
const url = new URL(`https://api.codat.io/companies/${companyId}/sync/commerce/latest`)
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