export type GetApiApiCityArgs = {search?: string | undefined, country_id?: string | undefined, state_id?: string | undefined, county_id?: string | undefined, order_by?: ('id' | 'name' | 'county_id' | 'county_name' | 'state_id' | 'state_name' | 'country_id' | 'country_name' | 'locations_count') | undefined, order?: ('asc' | 'desc') | undefined, limit?: number | undefined, paginate?: number | undefined}; export type GetApiApiCityOptions = {baseUrl: string, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * List cities * * GET /api/city */ export const getApiApiCity = async (args: GetApiApiCityArgs, options: GetApiApiCityOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.search != null) query.append("search", String(args.search)) if (args.country_id != null) query.append("country_id", String(args.country_id)) if (args.state_id != null) query.append("state_id", String(args.state_id)) if (args.county_id != null) query.append("county_id", String(args.county_id)) if (args.order_by != null) query.append("order_by", String(args.order_by)) if (args.order != null) query.append("order", String(args.order)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.paginate != null) query.append("paginate", String(args.paginate)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/city${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 };