export type BadgeStyle = 'flat' | 'plastic' | 'flat-square' | 'for-the-badge' | 'social'; export type BadgeTheme = 'light' | 'dark' | 'default'; export type GetApiV1BadgesGroupsGroupIdArgs = {groupId: number, style?: BadgeStyle | undefined, theme?: BadgeTheme | undefined, responseTime?: boolean | undefined}; export type GetApiV1BadgesGroupsGroupIdOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get group status badge. You can enable the badges feature in [account settings](https://app.checklyhq.com/settings/account/general) * * GET /v1/badges/groups/{groupId} */ export const getApiV1BadgesGroupsGroupId = async (args: GetApiV1BadgesGroupsGroupIdArgs, options?: GetApiV1BadgesGroupsGroupIdOptions) => { const {baseUrl = "https://api.checklyhq.com", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/svg+xml") if (args.style != null) query.append("style", String(args.style)) if (args.theme != null) query.append("theme", String(args.theme)) if (args.responseTime != null) query.append("responseTime", String(args.responseTime)) if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/badges/groups/${encodeURIComponent(String(args.groupId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };