export type CanonicalProductEnvelopeDto = {external_store_id?: string | undefined, event_id?: string | undefined, product: {external_id?: string | undefined, name?: string | undefined, description?: string | undefined, price?: number | undefined, currency?: string | undefined, sku?: (string | null) | undefined, file_url?: (string | null) | undefined, image_urls?: Array | undefined, metadata?: Array<{key: string, value: string}> | undefined}}; export type CreateApiApiPublicAppsAppIdEventsProductArgs = {'x-vambe-timestamp': string, 'x-vambe-signature': string, appId: string, body: CanonicalProductEnvelopeDto}; export type CreateApiApiPublicAppsAppIdEventsProductOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Product upsert event * * POST /api/public/apps/{appId}/events/product */ export const createApiApiPublicAppsAppIdEventsProduct = async (args: CreateApiApiPublicAppsAppIdEventsProductArgs, options?: CreateApiApiPublicAppsAppIdEventsProductOptions) => { 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/product${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 };