export type GetApiStatementsStatementIdDownloadArgs = {statementId: string}; export type GetApiStatementsStatementIdDownloadOptions = {baseUrl?: string | undefined, ApiAccessKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download a statement * * GET /statements/{statementId}/download */ export const getApiStatementsStatementIdDownload = async (args: GetApiStatementsStatementIdDownloadArgs, options?: GetApiStatementsStatementIdDownloadOptions) => { const {baseUrl = "https://api.anchorage-staging.com/v2", fetch: fetchFn = fetch, ApiAccessKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/pdf") if (ApiAccessKey !== undefined) headers.set("Api-Access-Key", ApiAccessKey) const url = `${baseUrl.replace(/\/+$/, '')}/statements/${encodeURIComponent(String(args.statementId))}/download${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() };