//native
type Codat = {
encodedKey: string
}
/**
* List supplier attachments
* The *List supplier attachments* endpoint returns a list of attachments available to download for given `supplierId`.
[Suppliers](https://docs.codat.io/lending-api#/schemas/Supplier) are people or organizations that provide something, such as a product or service.
*/
export async function main(
auth: Codat,
companyId: string,
connectionId: string,
supplierId: string
) {
const url = new URL(
`https://api.codat.io/companies/${companyId}/connections/${connectionId}/data/suppliers/${supplierId}/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