//native
type Xero = {
token: string
}
/**
* Get Cash flow report
* The statement of cash flows - direct method, provides the year to date changes in operating, financing and investing cash flow activities for an organisation. Cashflow statement is not available in US region at this stage.
*/
export async function main(
auth: Xero,
startDate: string | undefined,
endDate: string | undefined,
xero_tenant_id: string
) {
const url = new URL(`https://api.xero.com/finance.xro/1.0/FinancialStatements/Cashflow`)
for (const [k, v] of [
['startDate', startDate],
['endDate', endDate]
]) {
if (v !== undefined && v !== '' && k !== undefined) {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'GET',
headers: {
Accept: 'application/json',
'xero-tenant-id': xero_tenant_id,
Authorization: 'Bearer ' + auth.token
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 515 days ago