export type CreateApiApiHoldingsArgs = {page?: number | undefined, resultsPerPage?: number | undefined, searchterm?: string | undefined, keyword?: string | undefined, gridid?: number | undefined, region?: string | undefined, regionclass?: string | undefined, classitem?: string | undefined, searchproperty?: string | undefined, status?: string | undefined, parent?: number | undefined, datefield?: string | undefined, start?: string | undefined, end?: string | undefined, types?: string | undefined, enableThesaurus?: boolean | undefined}; export type CreateApiApiHoldingsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Returns a page of holdings recognised by the system * * POST /api/holdings */ export const createApiApiHoldings = async (args: CreateApiApiHoldingsArgs, options: CreateApiApiHoldingsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.page != null) query.append("page", String(args.page)) if (args.resultsPerPage != null) query.append("resultsPerPage", String(args.resultsPerPage)) if (args.searchterm != null) query.append("searchterm", String(args.searchterm)) if (args.keyword != null) query.append("keyword", String(args.keyword)) if (args.gridid != null) query.append("gridid", String(args.gridid)) if (args.region != null) query.append("region", String(args.region)) if (args.regionclass != null) query.append("regionclass", String(args.regionclass)) if (args.classitem != null) query.append("classitem", String(args.classitem)) if (args.searchproperty != null) query.append("searchproperty", String(args.searchproperty)) if (args.status != null) query.append("status", String(args.status)) if (args.parent != null) query.append("parent", String(args.parent)) if (args.datefield != null) query.append("datefield", String(args.datefield)) if (args.start != null) query.append("start", String(args.start)) if (args.end != null) query.append("end", String(args.end)) if (args.types != null) query.append("types", String(args.types)) if (args.enableThesaurus != null) query.append("enableThesaurus", String(args.enableThesaurus)) const url = `${baseUrl.replace(/\/+$/, '')}/api/holdings${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };