export type GetApiEcologyApiV1SurveysArgs = {skip?: number | undefined, take?: number | undefined, site_type?: string | undefined, date_to?: string | undefined, date_from?: string | undefined, lat?: number | undefined, long?: number | undefined, distance_km?: number | undefined}; export type GetApiEcologyApiV1SurveysOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Get surveys * * GET /ecology/api/v1/surveys */ export const getApiEcologyApiV1Surveys = async (args: GetApiEcologyApiV1SurveysArgs, options: GetApiEcologyApiV1SurveysOptions) => { 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.site_type != null) query.append("site_type", String(args.site_type)) if (args.date_to != null) query.append("date_to", String(args.date_to)) if (args.date_from != null) query.append("date_from", String(args.date_from)) 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/surveys${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 };