export type ReportUid = string; export type GetApiReportsReportUidArgs = {reportUid: ReportUid}; export type GetApiReportsReportUidOptions = {baseUrl?: string | undefined, BasicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Download specific report * * GET /reports/{reportUid} * * Also accepts auth: BearerAuth */ export const getApiReportsReportUid = async (args: GetApiReportsReportUidArgs, options?: GetApiReportsReportUidOptions) => { const {baseUrl = "https://emea.gsc.verifone.cloud/oidc/checkout-service", fetch: fetchFn = fetch, BasicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/pdf") if (BasicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${BasicAuth.username}:${BasicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/reports/${encodeURIComponent(String(args.reportUid))}${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() };