export type GetApiRestaurantsSlugRestaurantSlugArgs = {filter?: unknown | undefined, q?: unknown | undefined, restaurantSlug: number}; export type GetApiRestaurantsSlugRestaurantSlugOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Get restaurant by its slug * * GET /restaurants/slug/{restaurantSlug} */ export const getApiRestaurantsSlugRestaurantSlug = async (args: GetApiRestaurantsSlugRestaurantSlugArgs, options: GetApiRestaurantsSlugRestaurantSlugOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.filter != null) query.append("filter", String(args.filter)) if (args.q != null) query.append("q", String(args.q)) const url = `${baseUrl.replace(/\/+$/, '')}/restaurants/slug/${encodeURIComponent(String(args.restaurantSlug))}${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 };