export type GetApiTranscriptionsIdArgs = {id?: string | undefined, debug?: boolean | undefined}; export type GetApiTranscriptionsIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get a single transcription object by transcription id. * * GET /transcriptions/{id} */ export const getApiTranscriptionsId = async (args: GetApiTranscriptionsIdArgs, options?: GetApiTranscriptionsIdOptions) => { const {baseUrl = "https://catalog.archives.gov/api/v2", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.id != null) query.append("id", String(args.id)) if (args.debug != null) query.append("debug", String(args.debug)) const url = `${baseUrl.replace(/\/+$/, '')}/transcriptions/${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 undefined };