//native
type Bitly = {
token: string;
};
/**
* Bulk update bitlinks
* Bulk update can add or remove tags or archive up to 100 links at a time; The response includes a list of bitlink ids that were updated.
*/
export async function main(
auth: Bitly,
group_guid: string,
body: {
action: "archive" | "edit_tags";
archive?: false | true;
add_tags?: string[];
remove_tags?: string[];
links?: string[];
},
) {
const url = new URL(
`https://api-ssl.bitly.com/v4/groups/${group_guid}/bitlinks`,
);
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