UNPKG

@apptus/esales-api

Version:

Library for making requests to Elevate 4 API v3

85 lines (74 loc) 2.97 kB
import type { SortType } from './mod.ts'; export type ViewId = 'production' | 'preview'; export type FacetValue = boolean | string[] | FacetRange; export type FacetRange = { min: number, max?: number; } | { min?: number, max: number; }; export interface FacetParams { [key: string]: FacetValue; } // GENERAL PARAM TYPES /** Parameters shared between all Storefront queries */ export interface BaseParams { /** Setting this parameter can change the returned content between "preview" and "production" (default) */ viewId?: ViewId; /** Set this parameter to `false` to not generate any event data for this request */ notify?: boolean; } /** Parameters that change product data based on current context (price used, channels, etc) */ export interface ProductContextParams { /** Set this parameter to change to a custom price that exists in your product feed */ priceId?: string; /** * Selects what channels to use, ONLINE or STORE, affecting stock-related ranking and filtering. * Defaults to ONLINE|STORE */ channels?: 'ONLINE' | 'STORE' | 'ONLINE|STORE' | 'STORE|ONLINE'; /** One or more store keys from the product feed, used with channels and presented in the result */ stores?: string; } /** Parameters used by queries that search for items */ export interface SearchParams { /** The search query for this request */ q: string; } /** Paramaters used by pagination of products or content items */ export interface PaginationParams { /** For implementing pagination, how many items to fetch in the result (defaults to 60) */ limit?: number; /** For implementing pagination, how many items to skip in the result */ skip?: number; } // PAGE CONTEXT PARAM TYPES /** Paramaters that are shared for endpoints returning products */ export interface ProductParams extends BaseParams, ProductContextParams { /** A list of custom attributes to include on products in listings */ presentCustom?: string[]; /** * A list of custom price ID's to include for products. * * Each ID must match a supplied custom price ID in the data feed. * @example * ['VIP', 'member'] */ presentPrices?: string[]; /** * The ID of a response template to apply to all product lists returned. * * Templates can adjust which attributes are returned for products, and makes * `presentCustom` unnecessary. Templates can be imported via the Admin API. * @see https://docs.elevate.voyado.cloud/elevate/4/guides/product-list-response-templates/ */ templateId?: string; } /** Paramaters used by pages that list products, for pagination, sorting, and facets */ export interface ProductListParams extends PaginationParams { /** The facets to be passed along e.g. * @example * { * "price": { "min": 10, "max": 100 }, // range * "custom.fit": [ "slim", "regular" ], // multiple values * } */ facets?: FacetParams; /** Changes how products are sorted in the response */ sort?: SortType; }