//native
type Codat = {
encodedKey: string
}
/**
* Download spend analysis report
* Download spend analysis report that has already been successfully created. The report will be in Open XML spreadhseet format (.xlsx), which can be opened with Microsoft Excel.
*/
export async function main(auth: Codat, companyId: string) {
const url = new URL(
`https://banking-api.codat.io/companies/${companyId}/reports/spendAnalysis/excel`
)
const response = await fetch(url, {
method: 'GET',
headers: {
Authorization: `Basic ${auth.encodedKey}`
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.text()
}
Submitted by hugo697 235 days ago