export type GetApiPaymentsPaymentIdConfirmationArgs = {paymentId: number, accountId: string}; export type GetApiPaymentsPaymentIdConfirmationOptions = {baseUrl?: string | undefined, CommonAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download PDF confirmation of a payment * * GET /payments/{paymentId}/confirmation */ export const getApiPaymentsPaymentIdConfirmation = async (args: GetApiPaymentsPaymentIdConfirmationArgs, options?: GetApiPaymentsPaymentIdConfirmationOptions) => { const {baseUrl = "https://api.equalsmoney.com/v2", fetch: fetchFn = fetch, CommonAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/pdf") if (args.accountId != null) query.append("accountId", String(args.accountId)) if (CommonAuth !== undefined) headers.set("Authorization", CommonAuth) const url = `${baseUrl.replace(/\/+$/, '')}/payments/${encodeURIComponent(String(args.paymentId))}/confirmation${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() };