//native
type Buttondown = {
token: string;
};
/**
* Create Advertising Unit
*
*/
export async function main(
auth: Buttondown,
body: {
title?: string;
description?: string;
behavior?: string;
url?: string;
price?: number;
},
) {
const url = new URL(`https://api.buttondown.com/v1/advertising_units`);
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