export type GetApiV1OrdersOrderIdInvoicesReceiptIdArgs = {orderId: string, receiptId: string}; export type GetApiV1OrdersOrderIdInvoicesReceiptIdOptions = {baseUrl?: string | undefined, SystemApiKey?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Download the invoice PDF of the order * * GET /v1/orders/{orderId}/invoices/{receiptId} */ export const getApiV1OrdersOrderIdInvoicesReceiptId = async (args: GetApiV1OrdersOrderIdInvoicesReceiptIdArgs, options?: GetApiV1OrdersOrderIdInvoicesReceiptIdOptions) => { const {baseUrl = "https://api.digitalriver.com", fetch: fetchFn = fetch, SystemApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/pdf") if (SystemApiKey !== undefined) headers.set('authorization', `Basic ${btoa(`${SystemApiKey.username}:${SystemApiKey.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/orders/${encodeURIComponent(String(args.orderId))}/invoices/${encodeURIComponent(String(args.receiptId))}${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() };