//native
type Bitly = {
token: string;
};
/**
* Update a Bitlink
* Updates fields in the specified link. To redirect the link (i.e. to update the Long URL), use PATCH /v4/custom_bitlinks/{custom_bitlink} (https://dev.bitly.com/api-reference/#updateCustomBitlink)
*/
export async function main(
auth: Bitly,
bitlink: string,
body: {
title?: string;
archived?: false | true;
tags?: string[];
deeplinks?: {
guid?: string;
bitlink?: string;
app_uri_path?: string;
install_url?: string;
app_guid?: string;
os?: "ios" | "android";
install_type?: "no_install" | "auto_install" | "promote_install";
created?: string;
modified?: string;
brand_guid?: string;
}[];
},
) {
const url = new URL(`https://api-ssl.bitly.com/v4/bitlinks/${bitlink}`);
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