//native
type Square = {
token: string;
};
/**
* CancelLoyaltyPromotion
* Cancels a loyalty promotion. Use this endpoint to cancel an `ACTIVE` promotion earlier than the
end date, cancel an `ACTIVE` promotion when an end date is not specified, or cancel a `SCHEDULED` promotion.
Because updating a promotion is not supported, you can also use this endpoint to cancel a promotion before
you create a new one.
This endpoint sets the loyalty promotion to the `CANCELED` state
*/
export async function main(
auth: Square,
promotion_id: string,
program_id: string,
) {
const url = new URL(
`https://connect.squareup.com/v2/loyalty/programs/${program_id}/promotions/${promotion_id}/cancel`,
);
const response = await fetch(url, {
method: "POST",
headers: {
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 235 days ago