//native
type Square = {
token: string;
};
/**
* V1UpdateOrder
* Updates the details of an online store order. Every update you perform on an order corresponds to one of three actions:
*/
export async function main(
auth: Square,
location_id: string,
order_id: string,
body: {
action: "COMPLETE" | "CANCEL" | "REFUND";
shipped_tracking_number?: string;
completed_note?: string;
refunded_note?: string;
canceled_note?: string;
},
) {
const url = new URL(
`https://connect.squareup.com/v1/${location_id}/orders/${order_id}`,
);
const response = await fetch(url, {
method: "PUT",
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