//native
type Codat = {
encodedKey: string
}
/**
* List direct cost attachments
* The *List direct cost attachments* endpoint returns a list of attachments available to download for given `directCostId`.
[Direct costs](https://docs.codat.io/lending-api#/schemas/DirectCost) are business expenses that don't impact Accounts Payable.
*/
export async function main(
auth: Codat,
companyId: string,
connectionId: string,
directCostId: string
) {
const url = new URL(
`https://api.codat.io/companies/${companyId}/connections/${connectionId}/data/directCosts/${directCostId}/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