//native
type Xero = {
token: string;
};
/**
* Retrieves history records of a specific credit note
*
*/
export async function main(
auth: Xero,
CreditNoteID: string,
xero_tenant_id: string,
Idempotency_Key: string,
body: {
HistoryRecords?: {
Details?: string;
Changes?: string;
User?: string;
DateUTC?: string;
}[];
},
) {
const url = new URL(
`https://api.xero.com/api.xro/2.0/CreditNotes/${CreditNoteID}/History`,
);
const response = await fetch(url, {
method: "PUT",
headers: {
Accept: 'application/json',
"xero-tenant-id": xero_tenant_id,
"Idempotency-Key": Idempotency_Key,
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 515 days ago