export type CanonicalOrderEnvelopeDto = {external_store_id?: string | undefined, event_id?: string | undefined, order: {external_id?: string | undefined, external_name?: string | undefined, currency?: string | undefined, total_price?: number | undefined, status_url?: (string | null) | undefined, details_url?: (string | null) | undefined, customer?: ({name?: (string | null) | undefined, phone?: (string | null) | undefined, email?: (string | null) | undefined}) | undefined, line_items?: Array<{external_product_id: string, quantity: number}> | undefined, metadata?: {[key: string]: unknown} | undefined}}; export type CreateApiApiPublicAppsAppIdEventsOrderArgs = {'x-vambe-timestamp': string, 'x-vambe-signature': string, appId: string, body: CanonicalOrderEnvelopeDto}; export type CreateApiApiPublicAppsAppIdEventsOrderOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Order event * * POST /api/public/apps/{appId}/events/order */ export const createApiApiPublicAppsAppIdEventsOrder = async (args: CreateApiApiPublicAppsAppIdEventsOrderArgs, options?: CreateApiApiPublicAppsAppIdEventsOrderOptions) => { 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/order${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 };