//native
type Buttondown = {
token: string;
};
/**
* Create Price
*
*/
export async function main(
auth: Buttondown,
body: {
style: "pay-what-you-want" | "fixed" | "usage-based";
amount?: number;
currency: string;
cadence: "year" | "month" | "one-time" | "email";
},
) {
const url = new URL(`https://api.buttondown.com/v1/prices`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Token " + 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 428 days ago