export type GetApiApiStatusPagesPublicSlugBadgeSvgArgs = {slug: string}; export type GetApiApiStatusPagesPublicSlugBadgeSvgOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Get the status badge of a page * * GET /api/status_pages_public/{slug}/badge.svg */ export const getApiApiStatusPagesPublicSlugBadgeSvg = async (args: GetApiApiStatusPagesPublicSlugBadgeSvgArgs, options: GetApiApiStatusPagesPublicSlugBadgeSvgOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/svg+xml") const url = `${baseUrl.replace(/\/+$/, '')}/api/status_pages_public/${encodeURIComponent(String(args.slug))}/badge.svg${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() };