export type GetApiEcologyApiV1ObservationsArgs = {skip?: number | undefined, take?: number | undefined, type_id?: string | undefined, site_id?: string | undefined, property_id?: string | undefined, ultimate_foi_id?: string | undefined, date_to?: string | undefined, date_from?: string | undefined}; export type GetApiEcologyApiV1ObservationsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Get observations. Filterable by one or more: type of observation, site, observable property, ultimate feature of interest * * GET /ecology/api/v1/observations */ export const getApiEcologyApiV1Observations = async (args: GetApiEcologyApiV1ObservationsArgs, options: GetApiEcologyApiV1ObservationsOptions) => { 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.type_id != null) query.append("type_id", String(args.type_id)) if (args.site_id != null) query.append("site_id", String(args.site_id)) if (args.property_id != null) query.append("property_id", String(args.property_id)) if (args.ultimate_foi_id != null) query.append("ultimate_foi_id", String(args.ultimate_foi_id)) 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)) const url = `${baseUrl.replace(/\/+$/, '')}/ecology/api/v1/observations${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 };