export type GetApiOnlineAvailabilityNaIdNaIdArgs = {naId?: number | undefined}; export type GetApiOnlineAvailabilityNaIdNaIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get all online availability information for a record with the given naId. * * GET /online-availability/naId/{naId} */ export const getApiOnlineAvailabilityNaIdNaId = async (args: GetApiOnlineAvailabilityNaIdNaIdArgs, options?: GetApiOnlineAvailabilityNaIdNaIdOptions) => { const {baseUrl = "https://catalog.archives.gov/api/v2", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() const url = `${baseUrl.replace(/\/+$/, '')}/online-availability/naId/${encodeURIComponent(String(args.naId))}${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 };