export type GetApiDownloadTokenPathwaysResourceFilenameCsvArgs = {token: string, resource: 'TOTAL' | 'UNIPROT' | 'ENSEMBL' | 'CHEBI' | 'IUPHAR' | 'MIRBASE' | 'NCBI' | 'PROTEIN' | 'EMBL' | 'COMPOUND' | 'PUBCHEM_COMPOUND', filename: string}; export type GetApiDownloadTokenPathwaysResourceFilenameCsvOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Downloads all hit pathways for a given analysis * * GET /download/{token}/pathways/{resource}/{filename}.csv */ export const getApiDownloadTokenPathwaysResourceFilenameCsv = async (args: GetApiDownloadTokenPathwaysResourceFilenameCsvArgs, options: GetApiDownloadTokenPathwaysResourceFilenameCsvOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() const url = `${baseUrl.replace(/\/+$/, '')}/download/${encodeURIComponent(String(args.token))}/pathways/${encodeURIComponent(String(args.resource))}/${encodeURIComponent(String(args.filename))}.csv${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 };