import { RpcMethod } from './commonTypes'; export type CatalogService_ListProducts = RpcMethod; export type CatalogService_GetProducts = RpcMethod; export type CatalogService_PreviewFeed = RpcMethod; export type CatalogService_UpsertProducts = RpcMethod; export type CatalogService_DeleteProducts = RpcMethod; export type CatalogService_DeleteAllProducts = RpcMethod; export type CatalogService_ListCategories = RpcMethod; export type CatalogService_GetFeed = RpcMethod; export type CatalogService_SetFeed = RpcMethod; export type CatalogService_DeleteFeed = RpcMethod; export type CatalogService_SyncFeed = RpcMethod; /** * CatalogService manages the per-application product catalog used by email * product blocks. Proxies to the catalog backend (recommender-api). */ export interface CatalogService { /** Lists products of an application (code XXXXX-XXXXX) catalog with a title search, category filter, sorting and pagination. Returns one page and the total match count. Use to browse or search the product catalog. */ ListProducts: CatalogService_ListProducts; /** Returns catalog products of an application (code XXXXX-XXXXX) by product IDs. Use to re-read specific products, e.g. to refresh product blocks in an email template. */ GetProducts: CatalogService_GetProducts; /** Returns the product rows a catalog rule would put into a message, ranked the way the send-time products feed ranks them. Use to preview a recommendation rule before saving a preset: the plain catalog list is ordered by the catalog, not by the strategy. Per-recipient strategies (also_bought, recently_viewed) are not previewable and answer FAILED_PRECONDITION. */ PreviewFeed: CatalogService_PreviewFeed; /** Inserts or updates products of an application (code XXXXX-XXXXX) catalog, matched by product id; at most 1000 per request. Returns inserted and updated counts. Use to add products manually or import them from a CSV file. */ UpsertProducts: CatalogService_UpsertProducts; /** Deletes products from an application (code XXXXX-XXXXX) catalog by product IDs. Returns the number of deleted products. */ DeleteProducts: CatalogService_DeleteProducts; /** Deletes ALL products of an application (code XXXXX-XXXXX) catalog. Irreversible; use only when the user explicitly asks to clear the whole catalog. */ DeleteAllProducts: CatalogService_DeleteAllProducts; /** Returns the distinct product categories of an application (code XXXXX-XXXXX) catalog. Use to build category filters. */ ListCategories: CatalogService_ListCategories; /** Returns the merchant-feed URL of an application (code XXXXX-XXXXX) catalog and the last sync state. Empty url means no feed is connected. */ GetFeed: CatalogService_GetFeed; /** Connects a merchant feed (JSON or Google Merchant XML, http(s) URL) to an application (code XXXXX-XXXXX) catalog; one feed per application. The feed is imported hourly; use sync_catalog_feed to import right away. */ SetFeed: CatalogService_SetFeed; /** Disconnects the merchant feed from an application (code XXXXX-XXXXX) catalog. Already-imported products stay in the catalog. */ DeleteFeed: CatalogService_DeleteFeed; /** Starts a merchant-feed sync of an application (code XXXXX-XXXXX) catalog in the background. Returns started=false when a sync is already running. Poll get_catalog_feed for the outcome. */ SyncFeed: CatalogService_SyncFeed; } export type Product = { /** Unique product id within the application catalog (SKU or external id). */ id: string; title: string; description: string; imageUrl: string; /** Product page URL. */ url: string; price: number; category: string; sku: string; currentStock: number; /** ISO 4217 code, e.g. "USD". */ currency: string; /** Discounted price; 0 means no sale. */ salePrice: number; }; export type ListProductsRequest = { /** Pushwoosh application code (XXXXX-XXXXX). */ applicationCode?: string; /** Case-insensitive substring match on title. */ search?: string; category?: string; /** One of: title, price, category, sku, stock; default title. */ sortBy?: string; sortDesc?: boolean; /** 0-based page number. */ page?: number; /** Defaults to 50, capped at 500. */ pageSize?: number; }; export type ListProductsResponse = { products: Product[]; /** Total matching products regardless of pagination. */ total: number; }; export type PreviewFeedRequest = { /** Pushwoosh application code (XXXXX-XXXXX). */ applicationCode?: string; category?: string; /** One of: newest, price_asc, price_desc, title; default newest. */ sort?: string; /** Rows to return, 1..50; defaults to 10. */ limit?: number; /** * One of: newest, bestsellers_7d, bestsellers_30d, back_in_stock, price_drop, or empty for * the plain rule; per-recipient ones (also_bought, recently_viewed) are rejected for now. */ strategy?: string; }; export type PreviewFeedItem = { id: string; title: string; description: string; imageUrl: string; /** Product page URL, without the click-attribution parameters the send adds. */ url: string; /** Display string, formatted the way the feed formats it, e.g. "$12.99". */ priceFormatted: string; /** Empty unless the product is on sale. */ oldPriceFormatted: string; category: string; }; export type PreviewFeedResponse = { items: PreviewFeedItem[]; /** The strategy yielded nothing and the plain catalog rule answered instead. */ fellBack: boolean; }; export type GetProductsRequest = { /** Pushwoosh application code (XXXXX-XXXXX). */ applicationCode?: string; productIds?: string[]; }; export type GetProductsResponse = { products: Product[]; }; export type UpsertProductsRequest = { /** Pushwoosh application code (XXXXX-XXXXX). */ applicationCode?: string; products?: Product[]; }; export type UpsertProductsResponse = { inserted: number; updated: number; }; export type DeleteProductsRequest = { /** Pushwoosh application code (XXXXX-XXXXX). */ applicationCode?: string; productIds?: string[]; }; export type DeleteProductsResponse = { deleted: number; }; export type DeleteAllProductsRequest = { /** Pushwoosh application code (XXXXX-XXXXX). */ applicationCode?: string; }; export type DeleteAllProductsResponse = {}; export type ListCategoriesRequest = { /** Pushwoosh application code (XXXXX-XXXXX). */ applicationCode?: string; }; export type ListCategoriesResponse = { categories: string[]; }; /** Last merchant-feed sync outcome; empty status means the feed never synced. */ export type FeedState = { /** One of: syncing, ok, error. */ status: string; startedAt: Date; finishedAt: Date; itemsUpserted: number; /** Products that disappeared from the feed and were removed. */ itemsDeleted: number; /** Feed entries without the required id+title. */ itemsSkipped: number; /** The feed answered 304 Not Modified — catalog left as is. */ notModified: boolean; error: string; }; export type GetFeedRequest = { /** Pushwoosh application code (XXXXX-XXXXX). */ applicationCode?: string; }; export type GetFeedResponse = { /** Empty when no feed is connected. */ url: string; state: FeedState; }; export type SetFeedRequest = { /** Pushwoosh application code (XXXXX-XXXXX). */ applicationCode?: string; /** http(s) URL of a JSON or Google Merchant XML feed. */ url?: string; }; export type SetFeedResponse = {}; export type DeleteFeedRequest = { /** Pushwoosh application code (XXXXX-XXXXX). */ applicationCode?: string; }; export type DeleteFeedResponse = {}; export type SyncFeedRequest = { /** Pushwoosh application code (XXXXX-XXXXX). */ applicationCode?: string; }; export type SyncFeedResponse = { /** False when a sync was already running (the running one continues). */ started: boolean; };