export type GetApiApiFurusatoSearchArgs = {keyword?: string | undefined, prefecture?: string | undefined, muni_code?: string | undefined, category?: ('food' | 'craft' | 'travel' | 'event' | 'other') | undefined, subcategory?: string | undefined, min_amount?: number | undefined, max_amount?: number | undefined, min_return_rate?: number | undefined, sort?: ('relevance' | 'amount_asc' | 'amount_desc' | 'return_rate_desc' | 'newest') | undefined, limit?: number | undefined, offset?: number | undefined}; export type GetApiApiFurusatoSearchOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * ふるさと納税 返礼品の横断検索 * * GET /api/furusato/search */ export const getApiApiFurusatoSearch = async (args: GetApiApiFurusatoSearchArgs, options?: GetApiApiFurusatoSearchOptions) => { const {baseUrl = "https://localgov.jp", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.keyword != null) query.append("keyword", String(args.keyword)) if (args.prefecture != null) query.append("prefecture", String(args.prefecture)) if (args.muni_code != null) query.append("muni_code", String(args.muni_code)) if (args.category != null) query.append("category", String(args.category)) if (args.subcategory != null) query.append("subcategory", String(args.subcategory)) if (args.min_amount != null) query.append("min_amount", String(args.min_amount)) if (args.max_amount != null) query.append("max_amount", String(args.max_amount)) if (args.min_return_rate != null) query.append("min_return_rate", String(args.min_return_rate)) if (args.sort != null) query.append("sort", String(args.sort)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.offset != null) query.append("offset", String(args.offset)) const url = `${baseUrl.replace(/\/+$/, '')}/api/furusato/search${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 };