export type QrConfig = {width?: number | undefined, height?: number | undefined, action?: string | undefined}; export type CreateApiV2InvoicingInvoicesInvoiceIdGenerateQrCodeArgs = {invoice_id: string, body: QrConfig}; export type CreateApiV2InvoicingInvoicesInvoiceIdGenerateQrCodeOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Generate QR code * * POST /v2/invoicing/invoices/{invoice_id}/generate-qr-code */ export const createApiV2InvoicingInvoicesInvoiceIdGenerateQrCode = async (args: CreateApiV2InvoicingInvoicesInvoiceIdGenerateQrCodeArgs, options?: CreateApiV2InvoicingInvoicesInvoiceIdGenerateQrCodeOptions) => { const {baseUrl = "https://api-m.paypal.com", fetch: fetchFn = fetch, Oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (Oauth2 !== undefined) headers.set('authorization', `Bearer ${Oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/invoicing/invoices/${encodeURIComponent(String(args.invoice_id))}/generate-qr-code${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };