export type Customer = {full_name: string, phone_number: string, email?: string | undefined, country_code: string, language?: string | undefined}; export type Session = {abandonment_timestamp: string, flow_stage: 'product_selection' | 'cart_review' | 'checkout' | 'payment', platform: 'web' | 'ios' | 'android', session_id?: string | undefined}; export type CartItem = {name?: string | undefined, sku?: string | undefined, quantity?: number | undefined, price?: number | undefined}; export type Cart = {total_value?: number | undefined, currency?: string | undefined, items?: Array | undefined}; export type Engagement = {preferred_channel?: ('call' | 'whatsapp' | 'auto') | undefined, reason?: string | undefined, metadata?: Record | undefined}; export type RecoveryOutreachRequest = {customer: Customer, session: Session, cart?: Cart | undefined, engagement?: Engagement | undefined}; export type CreateApiSmartSupportExternalPaymentsArgs = {body: RecoveryOutreachRequest}; export type CreateApiSmartSupportExternalPaymentsOptions = {baseUrl?: string | undefined, publicApiKey?: string | undefined, privateSecretKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Initiate Recovery Outreach for Abandoned User Flows * * POST /smart-support/external/payments */ export const createApiSmartSupportExternalPayments = async (args: CreateApiSmartSupportExternalPaymentsArgs, options?: CreateApiSmartSupportExternalPaymentsOptions) => { const {baseUrl = "https://api-sandbox.y.uno/v1", fetch: fetchFn = fetch, publicApiKey, privateSecretKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (publicApiKey !== undefined) headers.set("PUBLIC-API-KEY", publicApiKey) if (privateSecretKey !== undefined) headers.set("PRIVATE-SECRET-KEY", privateSecretKey) const url = `${baseUrl.replace(/\/+$/, '')}/smart-support/external/payments${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 };