//native
type Bitly = {
token: string;
};
/**
* Update a Channel
* Updates an existing channel.
*/
export async function main(
auth: Bitly,
channel_guid: string,
body: {
name?: string;
guid?: string;
created?: string;
modified?: string;
group_guid?: string;
} & { bitlinks?: { campaign_guid?: string; bitlink_id?: string }[] },
) {
const url = new URL(`https://api-ssl.bitly.com/v4/channels/${channel_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