//native
type Xero = {
token: string;
};
/**
* Retrieves a specific attachment from a specific expense claim receipts by file name
*
*/
export async function main(
auth: Xero,
ReceiptID: string,
FileName: string,
xero_tenant_id: string,
contentType: string,
) {
const url = new URL(
`https://api.xero.com/api.xro/2.0/Receipts/${ReceiptID}/Attachments/${FileName}`,
);
const response = await fetch(url, {
method: "GET",
headers: {
Accept: 'application/json',
"xero-tenant-id": xero_tenant_id,
contentType: contentType,
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 515 days ago