export type GetApiQrCodeSha256HashArgs = {sha256_hash: string, size?: number | undefined, version?: string | undefined, utm_medium?: string | undefined, utm_campaign?: string | undefined, type?: string | undefined}; export type GetApiQrCodeSha256HashOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get QR code for an email address' profile * * GET /qr-code/{sha256_hash} */ export const getApiQrCodeSha256Hash = async (args: GetApiQrCodeSha256HashArgs, options?: GetApiQrCodeSha256HashOptions) => { const {baseUrl = "https://api.gravatar.com/v3", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/png") if (args.size != null) query.append("size", String(args.size)) if (args.version != null) query.append("version", String(args.version)) if (args.utm_medium != null) query.append("utm_medium", String(args.utm_medium)) if (args.utm_campaign != null) query.append("utm_campaign", String(args.utm_campaign)) if (args.type != null) query.append("type", String(args.type)) const url = `${baseUrl.replace(/\/+$/, '')}/qr-code/${encodeURIComponent(String(args.sha256_hash))}${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() };