export type GetApiRisksTransactionIdReportReportIdArgs = {'transaction-id': string, 'report-id': string, format?: ('html' | 'pdf' | 'json') | undefined, locale?: ('de' | 'en') | undefined}; export type GetApiRisksTransactionIdReportReportIdOptions = {baseUrl?: string | undefined, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Download a Report * * GET /risks/{transaction-id}/report/{report-id} */ export const getApiRisksTransactionIdReportReportId = async (args: GetApiRisksTransactionIdReportReportIdArgs, options?: GetApiRisksTransactionIdReportReportIdOptions) => { const {baseUrl = "https://api.xs2a.com/v1", fetch: fetchFn = fetch, basicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.format != null) query.append("format", String(args.format)) if (args.locale != null) query.append("locale", String(args.locale)) if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/risks/${encodeURIComponent(String(args['transaction-id']))}/report/${encodeURIComponent(String(args['report-id']))}${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 };