export type GetApiReportTokenSpeciesFilenamePdfArgs = {token: string, species: string, filename: string, number?: number | undefined, resource?: ('TOTAL' | 'UNIPROT' | 'ENSEMBL' | 'CHEBI' | 'IUPHAR' | 'MIRBASE' | 'NCBI_PROTEIN' | 'EMBL' | 'COMPOUND' | 'PUBCHEM_COMPOUND') | undefined, importableOnly?: boolean | undefined, diagramProfile?: ('Modern' | 'Standard') | undefined, analysisProfile?: ('Standard' | 'Strosobar' | 'Copper Plus') | undefined, fireworksProfile?: ('Cooper' | 'Cooper Plus' | 'Barium Lithium' | 'Calcium Salts') | undefined}; export type GetApiReportTokenSpeciesFilenamePdfOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Downloads a report for a given pathway analysis result * * GET /report/{token}/{species}/{filename}.pdf */ export const getApiReportTokenSpeciesFilenamePdf = async (args: GetApiReportTokenSpeciesFilenamePdfArgs, options: GetApiReportTokenSpeciesFilenamePdfOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.number != null) query.append("number", String(args.number)) if (args.resource != null) query.append("resource", String(args.resource)) if (args.importableOnly != null) query.append("importableOnly", String(args.importableOnly)) if (args.diagramProfile != null) query.append("diagramProfile", String(args.diagramProfile)) if (args.analysisProfile != null) query.append("analysisProfile", String(args.analysisProfile)) if (args.fireworksProfile != null) query.append("fireworksProfile", String(args.fireworksProfile)) const url = `${baseUrl.replace(/\/+$/, '')}/report/${encodeURIComponent(String(args.token))}/${encodeURIComponent(String(args.species))}/${encodeURIComponent(String(args.filename))}.pdf${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 };