export type CanonicalCheckoutEnvelopeDto = {external_store_id?: string | undefined, event_id?: string | undefined, checkout: {external_id?: string | undefined, external_name?: (string | null) | undefined, currency?: string | undefined, total_price?: number | undefined, recover_url?: string | undefined, details_url?: (string | null) | undefined, customer?: ({name?: (string | null) | undefined, phone: string, email?: (string | null) | undefined}) | undefined, line_items?: Array<{external_product_id: string, quantity: number}> | undefined}}; export type CreateApiApiPublicAppsAppIdEventsCheckoutArgs = {'x-vambe-timestamp': string, 'x-vambe-signature': string, appId: string, body: CanonicalCheckoutEnvelopeDto}; export type CreateApiApiPublicAppsAppIdEventsCheckoutOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Checkout event * * POST /api/public/apps/{appId}/events/checkout */ export const createApiApiPublicAppsAppIdEventsCheckout = async (args: CreateApiApiPublicAppsAppIdEventsCheckoutArgs, options?: CreateApiApiPublicAppsAppIdEventsCheckoutOptions) => { const {baseUrl = "https://api.vambe.me", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['x-vambe-timestamp'] != null) headers.set("x-vambe-timestamp", String(args['x-vambe-timestamp'])) if (args['x-vambe-signature'] != null) headers.set("x-vambe-signature", String(args['x-vambe-signature'])) const url = `${baseUrl.replace(/\/+$/, '')}/api/public/apps/${encodeURIComponent(String(args.appId))}/events/checkout${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 };