//native
type Square = {
token: string;
};
/**
* BulkSwapPlan
* Schedules a plan variation change for all active subscriptions under a given plan
variation. For more information, see [Swap Subscription Plan Variations](https://developer.squareup.com/docs/subscriptions-api/swap-plan-variations).
*/
export async function main(
auth: Square,
body: {
new_plan_variation_id: string;
old_plan_variation_id: string;
location_id: string;
},
) {
const url = new URL(
`https://connect.squareup.com/v2/subscriptions/bulk-swap-plan`,
);
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