//native
type Codat = {
encodedKey: string
}
/**
* List categorized bank statement accounts
* > **Available as beta release**
>
> This endpoint is part of a beta release. Please contact your account manager if you want to enable it.
The *Get categorized bank statement accounts* endpoint returns a list of bank accounts associated with categorized transactions for a company.
Before using it, you must call the [Generate report](https://docs.codat.io/lending-api#/operations/generate-report) endpoint of type `categorizedBankStatement`.
*/
export async function main(
auth: Codat,
companyId: string,
reportId: string,
maxAge: string | undefined,
page: string | undefined,
pageSize: string | undefined,
query: string | undefined,
orderBy: string | undefined
) {
const url = new URL(
`https://api.codat.io/companies/${companyId}/reports/categorizedBankStatement/${reportId}/accounts`
)
for (const [k, v] of [
['maxAge', maxAge],
['page', page],
['pageSize', pageSize],
['query', query],
['orderBy', orderBy]
]) {
if (v !== undefined && v !== '' && k !== undefined) {
url.searchParams.append(k, v)
}
}
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.json()
}
Submitted by hugo697 235 days ago