//native
type Codat = {
encodedKey: string
}
/**
* Get customer attachment
* The *Get customer attachment* endpoint returns a specific attachment for a given `customerId` and `attachmentId`.
[Customers](https://docs.codat.io/lending-api#/schemas/Customer) are people or organizations that buy goods or services from the SMB.
*/
export async function main(
auth: Codat,
companyId: string,
connectionId: string,
customerId: string,
attachmentId: string
) {
const url = new URL(
`https://api.codat.io/companies/${companyId}/connections/${connectionId}/data/customers/${customerId}/attachments/${attachmentId}`
)
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