//native
type Bitly = {
token: string;
};
/**
* Update a QR Code
* Updates the QR code with a matching id and returns it.
*/
export async function main(
auth: Bitly,
qrcode_id: string,
body: {
title?: string;
render_customizations?: {
background_color?: string;
dot_pattern_color?: string;
dot_pattern_type?:
| "standard"
| "circle"
| "block"
| "blob"
| "rounded"
| "vertical"
| "horizontal"
| "triangle"
| "heart"
| "star"
| "diamond";
corners?: {
corner_1?: {
inner_color?: string;
outer_color?: string;
shape?:
| "standard"
| "rounded"
| "slightly_round"
| "extra_round"
| "leaf"
| "leaf_inner"
| "leaf_outer"
| "target"
| "concave";
};
corner_2?: {
inner_color?: string;
outer_color?: string;
shape?:
| "standard"
| "rounded"
| "slightly_round"
| "extra_round"
| "leaf"
| "leaf_inner"
| "leaf_outer"
| "target"
| "concave";
};
corner_3?: {
inner_color?: string;
outer_color?: string;
shape?:
| "standard"
| "rounded"
| "slightly_round"
| "extra_round"
| "leaf"
| "leaf_inner"
| "leaf_outer"
| "target"
| "concave";
};
};
gradient?: {
style?: "no_gradient" | "linear" | "radial";
angle?: number;
colors?: { color?: string; offset?: number }[];
exclude_corners?: false | true;
};
background_gradient?: {
style?: "no_gradient" | "linear" | "radial";
angle?: number;
colors?: { color?: string; offset?: number }[];
exclude_corners?: false | true;
};
logo?: { image_guid?: string };
frame?: {
id:
| "none"
| "border_only"
| "text_bottom"
| "tooltip_bottom"
| "arrow"
| "text_top"
| "text_bottom_in_frame"
| "script"
| "text_top_and_bottom"
| "url"
| "instagram";
colors?: { primary?: string; secondary?: string; background?: string };
text?: {
primary?: { content: string; color?: string };
secondary?: { content: string; color?: string };
};
};
text?: {
center?: { content: string; color?: string };
top?: { content: string; color?: string };
bottom?: { content: string; color?: string };
};
branding?: { bitly_brand?: false | true };
spec_settings?: { error_correction?: number };
};
archived?: false | true;
},
) {
const url = new URL(`https://api-ssl.bitly.com/v4/qr-codes/${qrcode_id}`);
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