//native
type Xero = {
token: string;
};
/**
* Retrieves superfunds
*
*/
export async function main(
auth: Xero,
where: string | undefined,
order: string | undefined,
page: string | undefined,
Xero_Tenant_Id: string,
If_Modified_Since: string,
) {
const url = new URL(`https://api.xero.com/payroll.xro/1.0/Superfunds`);
for (const [k, v] of [
["where", where],
["order", order],
["page", page],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Accept: 'application/json',
"Xero-Tenant-Id": Xero_Tenant_Id,
"If-Modified-Since": If_Modified_Since,
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 515 days ago