export type EmailAddress = unknown; export type EmailAddressList = Array; export type Notification = {subject?: string | undefined, note?: string | undefined, send_to_invoicer?: boolean | undefined, send_to_recipient?: boolean | undefined, additional_recipients?: EmailAddressList | undefined}; export type CreateApiV2InvoicingInvoicesInvoiceIdCancelArgs = {invoice_id: string, body: Notification}; export type CreateApiV2InvoicingInvoicesInvoiceIdCancelOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Cancel sent invoice * * POST /v2/invoicing/invoices/{invoice_id}/cancel */ export const createApiV2InvoicingInvoicesInvoiceIdCancel = async (args: CreateApiV2InvoicingInvoicesInvoiceIdCancelArgs, options?: CreateApiV2InvoicingInvoicesInvoiceIdCancelOptions) => { 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))}/cancel${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 };