//native
type Bitly = {
token: string;
};
/**
* Update Campaign
* Updates a campaign's details.
*/
export async function main(
auth: Bitly,
campaign_guid: string,
body: {
group_guid?: string;
name?: string;
description?: string;
channel_guids?: string[];
},
) {
const url = new URL(
`https://api-ssl.bitly.com/v4/campaigns/${campaign_guid}`,
);
const response = await fetch(url, {
method: "PATCH",
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 428 days ago