//native
type Codat = {
encodedKey: string
}
/**
* Get enhanced cash flow report
* > **Categorization engine**
>
> The categorization engine uses machine learning and has been fully trained against Plaid and TrueLayer banking data sources. It is not fully trained against the Basiq banking data source.
The Enhanced Cash Flow Transactions endpoint provides a fully categorized list of banking transactions for a company. Accounts and transaction data are obtained from the company's banking data sources.
*/
export async function main(
auth: Codat,
companyId: string,
page: string | undefined,
pageSize: string | undefined,
query: string | undefined
) {
const url = new URL(
`https://api.codat.io/companies/${companyId}/reports/enhancedCashFlow/transactions`
)
for (const [k, v] of [
['page', page],
['pageSize', pageSize],
['query', query]
]) {
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