export type CheckoutTokenAddEvent = {account_id: string, event_delivery: string, event: 'checkout_token_add', token: {id: string, token: string, type: 'payment_token', status: 'ACTIVE' | 'INACTIVE' | 'SUSPENDED' | 'CANCELLED' | 'DELETED', card_brand: 'visa' | 'mastercard', masked_pan: string, pan_expiry_date?: unknown | undefined, token_expiry_date: unknown, links?: (Array<{href: string, rel: 'digital_card_art' | 'digital_card_art_background' | 'card_symbol' | 'terms_and_conditions', mime_type?: ('image/png' | 'image/pdf' | 'text/plain' | 'text/html') | undefined}>) | undefined, customer_id?: string | undefined, account_id: string, relationship_id?: string | undefined, transaction_id?: unknown | undefined, external_token_references?: Array | undefined, payment_product_type: string, created_at: string, created_by?: string | undefined, updated_at: string, deleted_at?: string | undefined, deleted_by?: string | undefined}}; export type CheckoutTokenUpdateEvent = {account_id: string, event_delivery: string, event: 'checkout_token_update', token: {id: string, token: string, type: 'payment_token', status: 'ACTIVE' | 'INACTIVE' | 'SUSPENDED' | 'CANCELLED' | 'DELETED', card_brand: 'visa' | 'mastercard', masked_pan: string, pan_expiry_date?: unknown | undefined, token_expiry_date: unknown, links?: (Array<{href: string, rel: 'digital_card_art' | 'digital_card_art_background' | 'card_symbol' | 'terms_and_conditions', mime_type?: ('image/png' | 'image/pdf' | 'text/plain' | 'text/html') | undefined}>) | undefined, customer_id?: string | undefined, account_id: string, relationship_id?: string | undefined, transaction_id?: unknown | undefined, external_token_references?: Array | undefined, payment_product_type: string, created_at: string, created_by?: string | undefined, updated_at: string, deleted_at?: string | undefined, deleted_by?: string | undefined}}; export type CheckoutTokenDeleteEvent = {account_id: string, event_delivery: string, event: 'checkout_token_delete', token: {id: string, token?: string | undefined, type: 'payment_token', status: 'ACTIVE' | 'INACTIVE' | 'SUSPENDED' | 'CANCELLED' | 'DELETED', card_brand: 'visa' | 'mastercard', masked_pan?: string | undefined, pan_expiry_date?: unknown | undefined, token_expiry_date?: unknown | undefined, links?: (Array<{href: string, rel: 'digital_card_art' | 'digital_card_art_background' | 'card_symbol' | 'terms_and_conditions', mime_type?: ('image/png' | 'image/pdf' | 'text/plain' | 'text/html') | undefined}>) | undefined, customer_id?: string | undefined, account_id: string, relationship_id?: string | undefined, transaction_id?: unknown | undefined, external_token_references?: Array | undefined, payment_product_type: string, created_at: string, created_by?: string | undefined, updated_at: string, deleted_at: string, deleted_by: string}}; export type CheckoutTokenEvent = CheckoutTokenAddEvent | CheckoutTokenUpdateEvent | CheckoutTokenDeleteEvent; export type CreateApiExamplesCheckoutTokenArgs = {event: string, 'event-delivery': string, 'event-signature'?: string | undefined, 'content-type': string, body: CheckoutTokenEvent}; export type CreateApiExamplesCheckoutTokenOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * example_checkout_token_event * * POST /examples/checkout_token */ export const createApiExamplesCheckoutToken = async (args: CreateApiExamplesCheckoutTokenArgs, options?: CreateApiExamplesCheckoutTokenOptions) => { const {baseUrl = "https://api.dintero.com/v1", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.event != null) headers.set("event", String(args.event)) if (args['event-delivery'] != null) headers.set("event-delivery", String(args['event-delivery'])) if (args['event-signature'] != null) headers.set("event-signature", String(args['event-signature'])) if (args['content-type'] != null) headers.set("content-type", String(args['content-type'])) const url = `${baseUrl.replace(/\/+$/, '')}/examples/checkout_token${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 };