//native
type Bitly = {
token: string;
};
/**
* Update Group Preferences
* Updates preferences for a group.
*/
export async function main(
auth: Bitly,
group_guid: string,
body: { group_guid?: string; domain_preference?: string },
) {
const url = new URL(
`https://api-ssl.bitly.com/v4/groups/${group_guid}/preferences`,
);
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