//native
type Codat = {
encodedKey: string
}
/**
* List direct income attachments
* The *List direct income attachments* endpoint returns a list of attachments available to download for given `directIncomeId`.
[Direct incomes](https://docs.codat.io/lending-api#/schemas/DirectIncome) are incomes received directly from the business' operations at the point of the sale.
*/
export async function main(
auth: Codat,
companyId: string,
connectionId: string,
directIncomeId: string
) {
const url = new URL(
`https://api.codat.io/companies/${companyId}/connections/${connectionId}/data/directIncomes/${directIncomeId}/attachments`
)
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