//native
type Codat = {
encodedKey: string
}
/**
* Generate report
* > **Available as beta release**
>
> This endpoint is part of a beta release. Please contact your account manager if you want to enable it.
Use the *Generate report* endpoint to initiate the generation of a report specified by the `reportType` parameter.
This action triggers the system to refresh and pull the necessary data from the company's data sources to ensure the report contains the most up-to-date information.
*/
export async function main(auth: Codat, companyId: string, reportType: 'spendAnalysis') {
const url = new URL(`https://api.codat.io/companies/${companyId}/reports/${reportType}`)
const response = await fetch(url, {
method: 'POST',
headers: {
Authorization: `Basic ${auth.encodedKey}`
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 235 days ago