export type GetApiSearchLangRecordsIdArgs = {id: string, lang: string, provider_id?: string | undefined}; export type GetApiSearchLangRecordsIdOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Find One * * GET /search/{lang}/records/{id} */ export const getApiSearchLangRecordsId = async (args: GetApiSearchLangRecordsIdArgs, options: GetApiSearchLangRecordsIdOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/html") if (args.provider_id != null) query.append("provider_id", String(args.provider_id)) const url = `${baseUrl.replace(/\/+$/, '')}/search/${encodeURIComponent(String(args.lang))}/records/${encodeURIComponent(String(args.id))}${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 res.text() };