//native
type Square = {
token: string;
};
/**
* BatchRetrieveOrders
* Retrieves a set of [orders]($m/Order) by their IDs.
If a given order ID does not exist, the ID is ignored instead of generating an error.
*/
export async function main(
auth: Square,
body: { location_id?: string; order_ids: string[] },
) {
const url = new URL(`https://connect.squareup.com/v2/orders/batch-retrieve`);
const response = await fetch(url, {
method: "POST",
headers: {
"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 235 days ago