export type GetApiSeriesIdArchiveArgs = {filename?: string | undefined, 'lossy-quality'?: number | undefined, transcode?: string | undefined, id: string}; export type GetApiSeriesIdArchiveOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create ZIP archive * * GET /series/{id}/archive */ export const getApiSeriesIdArchive = async (args: GetApiSeriesIdArchiveArgs, options?: GetApiSeriesIdArchiveOptions) => { const {baseUrl = "https://orthanc.uclouvain.be/demo", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/zip") if (args.filename != null) query.append("filename", String(args.filename)) if (args['lossy-quality'] != null) query.append("lossy-quality", String(args['lossy-quality'])) if (args.transcode != null) query.append("transcode", String(args.transcode)) const url = `${baseUrl.replace(/\/+$/, '')}/series/${encodeURIComponent(String(args.id))}/archive${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.blob() };