//native
type Bitly = {
token: string;
};
/**
* Retrieve QR Codes by Group
* Retrieves a list of QR codes matching the filter settings. Values are in reverse chronological order.
The pagination occurs by calling the next link in the pagination response object.
*/
export async function main(
auth: Bitly,
group_guid: string,
has_render_customizations: "on" | "off" | "both" | undefined,
archived: "on" | "off" | "both" | undefined,
size: string | undefined,
search_after: string | undefined,
) {
const url = new URL(
`https://api-ssl.bitly.com/v4/groups/${group_guid}/qr-codes`,
);
for (const [k, v] of [
["has_render_customizations", has_render_customizations],
["archived", archived],
["size", size],
["search_after", search_after],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 428 days ago