export type CreateApiRecipesVisualizeEquipmentArgs = {'Content-Type'?: ('application/x-www-form-urlencoded' | 'application/json' | 'multipart/form-data') | undefined, Accept?: ('application/json' | 'text/html' | 'media/*') | undefined, body: string}; export type CreateApiRecipesVisualizeEquipmentOptions = {baseUrl?: string | undefined, apiKeyScheme?: string | undefined, fetch?: typeof fetch | undefined}; /** * Equipment Widget * * POST /recipes/visualizeEquipment */ export const createApiRecipesVisualizeEquipment = async (args: CreateApiRecipesVisualizeEquipmentArgs, options?: CreateApiRecipesVisualizeEquipmentOptions) => { const {baseUrl = "https://api.spoonacular.com", fetch: fetchFn = fetch, apiKeyScheme} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/x-www-form-urlencoded") headers.set('accept', "text/html") if (args['Content-Type'] != null) headers.set("Content-Type", String(args['Content-Type'])) if (args.Accept != null) headers.set("Accept", String(args.Accept)) if (apiKeyScheme !== undefined) headers.set("x-api-key", apiKeyScheme) const url = `${baseUrl.replace(/\/+$/, '')}/recipes/visualizeEquipment${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: new URLSearchParams(Object.entries(args.body).flatMap(([key, value]) => (value == null ? [] : [[key, String(value)]])))}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.text() };