export type GetApiFoodsBuildFoodResponseCacheArgs = {build_usda_table?: boolean | undefined, threaded?: boolean | undefined}; export type GetApiFoodsBuildFoodResponseCacheOptions = {baseUrl: string, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Rebuild the FoodResponse Cache. Runs as a background process. * * GET /foods/build_food_response_cache */ export const getApiFoodsBuildFoodResponseCache = async (args: GetApiFoodsBuildFoodResponseCacheArgs, options: GetApiFoodsBuildFoodResponseCacheOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.build_usda_table != null) query.append("build_usda_table", String(args.build_usda_table)) if (args.threaded != null) query.append("threaded", String(args.threaded)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/foods/build_food_response_cache${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 undefined };