export type GetApiRecipesIdTasteWidgetPngArgs = {id: number, normalize?: boolean | undefined, rgb?: string | undefined}; export type GetApiRecipesIdTasteWidgetPngOptions = {baseUrl?: string | undefined, apiKeyScheme?: string | undefined, fetch?: typeof fetch | undefined}; /** * Recipe Taste by ID Image * * GET /recipes/{id}/tasteWidget.png */ export const getApiRecipesIdTasteWidgetPng = async (args: GetApiRecipesIdTasteWidgetPngArgs, options?: GetApiRecipesIdTasteWidgetPngOptions) => { const {baseUrl = "https://api.spoonacular.com", fetch: fetchFn = fetch, apiKeyScheme} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "image/png") if (args.normalize != null) query.append("normalize", String(args.normalize)) if (args.rgb != null) query.append("rgb", String(args.rgb)) if (apiKeyScheme !== undefined) headers.set("x-api-key", apiKeyScheme) const url = `${baseUrl.replace(/\/+$/, '')}/recipes/${encodeURIComponent(String(args.id))}/tasteWidget.png${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() };