export type GetApiOgcCollectionsCollectionIdItemsArgs = {collectionId: string, bbox?: (Array) | undefined, datetime?: string | undefined}; export type GetApiOgcCollectionsCollectionIdItemsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * List available items * * GET /ogc/collections/{collectionId}/items */ export const getApiOgcCollectionsCollectionIdItems = async (args: GetApiOgcCollectionsCollectionIdItemsArgs, options: GetApiOgcCollectionsCollectionIdItemsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() for (const item of args.bbox ?? []) query.append("bbox", String(item)) if (args.datetime != null) query.append("datetime", String(args.datetime)) const url = `${baseUrl.replace(/\/+$/, '')}/ogc/collections/${encodeURIComponent(String(args.collectionId))}/items${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 };