UNPKG

lykdat

Version:

Official JavaScript SDK for Lykdat API (https://solutions.lykdat.com/)

216 lines (214 loc) 7.08 kB
/** * Configuration object used to initialise the Image Search UI */ type ImageSearchConfig = { /** * Your Lykdat Publishable API Key */ publishableApiKey: string; /** * The name of the Catalog which you'll be searching. * A Catalog is created at https://console.lykdat.com */ catalogName: string; /** * The CSS selector of a button to which a click event handler will be * attached to open the Image Search interaction dialog. * If not specified, a button will be automatically added by the function. */ triggerSelector?: string; }; /** * Attaches a Image Search UI to the dom. With this UI, users of your website * can select an image (from their computer) with which they will be search. * Once a search result is returned, it will be rendered by this UI function as * well. * @param {ProductAlertUIConfig} config required parameters to initialise the UI. */ export function initImageSearchUI(config: ImageSearchConfig): void; /** * Configuration object used to initialise the In-Stock Alert UI */ type ProductAlertUIConfig = { /** * Your Lykdat Publishable API Key */ publishableApiKey: string; /** * The name of your product alert website. This is name is usually * set-up at https://console.lykdat.com when you create your Product Alert * account. */ websiteName: string; /** * The CSS selector on which the UI should be rendered. */ targetSelector: string; }; /** * Attaches a Form UI to the dom. With this Form, users of your website * can subscribe to be notified when the related product is in-stock * (assuming it was previously unavailable). Typically you'll only want to * call this function on the Details page of a product that is currently * not in stock. * @param {ProductAlertUIConfig} config required parameters to initialise the UI. */ export function initInStockAlertUI(config: ProductAlertUIConfig): void; /** * Configuration object used to communicate with the Back In-Stock Alert API */ type ProductAlertConfig = { /** * Your Lykdat Publishable API Key */ publishableApiKey: string; /** * The name of your product alert website. This is name is usually * set-up at https://console.lykdat.com when you create your Product Alert * account. */ websiteName: string; }; type Product = { name?: string; url: string; price: string; currency: string; images: string[]; in_stock: boolean; }; type _ProductAlertResponse1 = { product?: Product; }; /** * Subscribes a user (whose email is provided) to be notified * when the specified prodduct becomes available (aka in-stock). * @param {ProductAlertConfig} config * @param {string} emailAddress the email of the subscriber. * @param {string} productUrl the URL of the product that is being subscribed to. * The Product URL must have the same base URL as the website associated with the * Product Alert settings created on console.lykdat.com * @returns */ export function subscribeToInStockAlert(config: ProductAlertConfig, emailAddress: string, productUrl: string): Promise<_ProductAlertResponse1>; /** * Subscribes a user (whose email is provided) to be notified * when the price of the specified prodduct drops. * @param {ProductAlertConfig} config * @param {string} emailAddress the email of the subscriber. * @param {string} productUrl the URL of the product that is being subscribed to. * The Product URL must have the same base URL as the website associated with the * Product Alert settings created on console.lykdat.com * @returns */ export function subscribeToPriceAlert(config: ProductAlertConfig, emailAddress: string, productUrl: string): Promise<_ProductAlertResponse1>; /** * Configuration object used to communicate with the Product Fetch API */ type ExtractionConfig = { /** * Your Lykdat Publishable API Key */ publishableApiKey: string; }; type _ProductExtractResponse1 = { product?: Product; }; /** * Extract the basic info (name, price, currency) of a Product from its URL. * @param {ExtractionConfig} config * @param {string} productUrl the URL of the product whose details is to be extracted. * @returns {ProductExtractResponse} */ export function extractProduct(config: ExtractionConfig, productUrl: string): Promise<_ProductExtractResponse1>; /** * Configuration object used to communicate with the Text Search API */ type TextSearchConfig = { /** * Your Lykdat Publishable API Key */ publishableApiKey: string; /** * The name of the Catalog which you'll be searching. * A Catalog is created at https://console.lykdat.com */ catalogName: string; }; /** * Additional Sort, Filter and Query options used to fine tune the results * of your search */ type TextSearchQueryOptions = { /** * the field name to sort the result by */ sort?: 'price'; /** * the order at which to sort the result. Could be 'asc' for ascending and * 'desc' for descending */ order?: 'asc' | 'desc'; /** * filter results by the gender field (if applicable to your catalog) */ genders?: Array<'female' | 'male' | 'unisex'>; /** * filter results by brand names (if applicable to your catalog) */ brands?: string[]; /** * filter results by colors (if applicable to your catalog) */ colors?: string[]; /** * As regards to pagination, this specifies the page number result to be returned. */ page?: number; /** * As regards to pagination, this specifies the number of products that should be returned * in each page. */ per_page?: number; }; /** * The response received after a successful Search is made. */ type _TextSearchResponse1 = { pagination: { total_items: number; total_pages: number; }; facets: Array<{ field_name: string; value_counts: Array<{ count: number; value: any; }>; }>; products: Array<{ id: string; name: string; url: string; price: string; reduced_price?: string; currency: string; images: string[]; in_stock: boolean; brand_name?: string; description?: string; colors?: string[]; }>; }; /** * Executes a product text search request through a product catalog. * @param query the text query to search the target catalog for * @param config coniguratoon options to provide API Key and target catalog name * @param options addition query options to sort and filter the search result * @returns {TextSearchResponse} */ export function searchText(query: string, config: TextSearchConfig, options?: TextSearchQueryOptions): Promise<_TextSearchResponse1>; export type ProductAlertResponse = _ProductAlertResponse1; export type TextSearchResponse = _TextSearchResponse1; export type ProductExtractResponse = _ProductExtractResponse1; //# sourceMappingURL=types.d.ts.map