UNPKG

@apptus/esales-api

Version:

Library for making requests to Elevate 4 API v3

111 lines (98 loc) 2.89 kB
export type Facet = TextFacet | ColorFacet | RangeFacet | SizeFacet | CheckboxFacet; export type FacetType = Facet['type']; export type FacetTextSort = 'ALPHABETICAL' | 'RELEVANCE' | 'NATURAL'; interface FacetData { /** * Identifier for this facet. Should be used to select this facet, * e.g. when creating a facet query parameters or product rules. * * @example * ```ts * api.query.landingPage({ * facets: { * [facet.id]: [facet.values[0].id] * } * }); * ``` */ id: string; /** Presentation text for facet */ label: string; } export interface TextFacet extends FacetData { /** Type of facet */ type: 'TEXT'; /** How the values are sorted */ sort: FacetTextSort; /** Number of selected facet values */ selectedCount: number; /** Values of facet */ values: TextFacetValue[]; } export interface ColorFacet extends FacetData { /** Type of facet */ type: 'COLOR'; /** Number of selected facet values */ selectedCount: number; /** Values of facet */ values: ColorFacetValue[]; } export interface RangeFacet extends FacetData { /** Type of facet */ type: 'RANGE'; /** The unit of the value. Only applicable for measurements */ unit?: string; /** Minimum value of range, inclusive. Undefined if there are no products in the selection */ min?: number; /** Maximum value of range, inclusive. Undefined if there are no products in the selection */ max?: number; /** Selected min value, undefined if not selected */ minSelected?: number; /** Selected max value, undefined if not selected */ maxSelected?: number; } export interface SizeFacet extends FacetData { /** Type of facet */ type: 'SIZE'; /** Number of selected facet values */ selectedCount: number; /** The defined sizeTypes */ sizeTypes: SizeType[]; } export interface CheckboxFacet extends FacetData { /** Type of facet */ type: 'CHECKBOX'; /** Identifies the checkbox as selected */ selected: boolean; /** The number of products that match the criteria. Only available when `selected` is `true` */ count?: number; } export interface TextFacetValue { /** * Identifier for this facet value. Use this value when refining queries with * selected facet values. */ id: string; /** Presentation text */ label: string; /** Identifies the value as selected */ selected: boolean; /** The number of products that match the criteria */ count: number; } export interface ColorFacetValue extends TextFacetValue { /** A CSS-color code for this color facet */ color: string; } export interface SizeType { /** Type of size, e.g. cloth or shoe sizes */ label: string; /** Size formats for type */ formats: SizeFormat[]; } export interface SizeFormat { /** The identifier for this size format */ format: string; /** Size values for format */ values: TextFacetValue[]; }