export type GetApiEcologyApiV1SitesArgs = {skip: number, take: number, mode: string, type?: string | undefined, lat?: number | undefined, long?: number | undefined, distance_km?: number | undefined}; export type GetApiEcologyApiV1SitesOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Get sites * * GET /ecology/api/v1/sites */ export const getApiEcologyApiV1Sites = async (args: GetApiEcologyApiV1SitesArgs, options: GetApiEcologyApiV1SitesOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.skip != null) query.append("skip", String(args.skip)) if (args.take != null) query.append("take", String(args.take)) if (args.mode != null) query.append("mode", String(args.mode)) if (args.type != null) query.append("type", String(args.type)) if (args.lat != null) query.append("lat", String(args.lat)) if (args.long != null) query.append("long", String(args.long)) if (args.distance_km != null) query.append("distance_km", String(args.distance_km)) const url = `${baseUrl.replace(/\/+$/, '')}/ecology/api/v1/sites${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 };