Table of Contents

getVisitorCallback

Type: Function

getConsumerCallback

Type: Function

getSessionCallback

Type: Function

APIService

Naiz backend API service, wraps naiz jsapi into a more usable library

Properties

version

Request server version

Returns Promise with version {string} on resolve

config

Request configuration onject for current domain

Returns Promise<ConfigResult, string> Promise with Config object (resolved) or error message (rejected).

assemble

Request assemble data with all data required to launch Naiz Fit Widget

Parameters

  • lang string Language code for HTML strings
  • consumer_hash string? Naiz Fit consumer hash if exists
  • urls Array<string>? Product URLs to check for Naiz Fit size recommendation
  • reference Object? Product reference to check from Naiz Fit size recommendation
    • reference.code string Product reference code
    • reference.brand string Product brand name
  • demo boolean? Ture to request assemble demo

Returns Promise<AssembleResult, string> Promise with AssembleResult object (resolved) or error message (rejected).

sizing

Request sizing for consumer and product

Parameters

  • consumer_hash String Hash of the consumer to check
  • product_code String Naiz Code of the product to check
  • height number Consumer height in mms
  • weight number Consumer weight in kgs
  • birthYear number Consumer birth year
  • gender ("MALE" | "FEMALE") Consumer birth year
  • loosening ("LOOSE" | "NORMAL" | "FIT") Consumer loosening preference

Returns Promise<SizingResult, string> Promise with AssembleResult object (resolved) or error message (rejected).

testQualify

Request qualify side for test

Parameters

Returns Promise<string, string> Promise with side to execute or error message

testCertify

Certify tests result to backend

Parameters

Returns Promise<boolean, string> Promise with TRUE or error message code, visitor, session, view, consumer, success

pushEvent

Push analytics event

Parameters

Returns Promise<boolean, string> Promise with TRUE or error message code, visitor, session, view, consumer, success

transformSizing

Transforms a sizing response from the backend into a SizingResult

Parameters

  • sizing Object Sizing object from the backend

Returns SizingResult

APIService

Naiz backend API service, wraps naiz jsapi into a more usable library

Properties

version

Request server version

Returns Promise with version {string} on resolve

config

Request configuration onject for current domain

Returns Promise<ConfigResult, string> Promise with Config object (resolved) or error message (rejected).

assemble

Request assemble data with all data required to launch Naiz Fit Widget

Parameters

  • lang string Language code for HTML strings
  • consumer_hash string? Naiz Fit consumer hash if exists
  • urls Array<string>? Product URLs to check for Naiz Fit size recommendation
  • reference Object? Product reference to check from Naiz Fit size recommendation
    • reference.code string Product reference code
    • reference.brand string Product brand name
  • demo boolean? Ture to request assemble demo

Returns Promise<AssembleResult, string> Promise with AssembleResult object (resolved) or error message (rejected).

sizing

Request sizing for consumer and product

Parameters

  • consumer_hash String Hash of the consumer to check
  • product_code String Naiz Code of the product to check
  • height number Consumer height in mms
  • weight number Consumer weight in kgs
  • birthYear number Consumer birth year
  • gender ("MALE" | "FEMALE") Consumer birth year
  • loosening ("LOOSE" | "NORMAL" | "FIT") Consumer loosening preference

Returns Promise<SizingResult, string> Promise with AssembleResult object (resolved) or error message (rejected).

testQualify

Request qualify side for test

Parameters

Returns Promise<string, string> Promise with side to execute or error message

testCertify

Certify tests result to backend

Parameters

Returns Promise<boolean, string> Promise with TRUE or error message code, visitor, session, view, consumer, success

pushEvent

Push analytics event

Parameters

Returns Promise<boolean, string> Promise with TRUE or error message code, visitor, session, view, consumer, success

transformSizing

Transforms a sizing response from the backend into a SizingResult

Parameters

  • sizing Object Sizing object from the backend

Returns SizingResult

apiService

Instanced API Service

ConfigResult

Type: Object

Properties

  • version string Version of NaizJS library included in the bundle
  • debug boolean Enable debug mode
  • custom Object? Customisation asset URLS
    • custom.script string? Customisation Javascript file URL
    • custom.html string? Customisation HTML file URL
  • order_url_pattern Sring? URL regexp to check for order processed page
  • order_value_eval string? Processed page JS data extractor

ConfigResult

Type: Object

Properties

  • version string Version of NaizJS library included in the bundle
  • debug boolean Enable debug mode
  • custom Object? Customisation asset URLS
    • custom.script string? Customisation Javascript file URL
    • custom.html string? Customisation HTML file URL
  • order_url_pattern Sring? URL regexp to check for order processed page
  • order_value_eval string? Processed page JS data extractor

SizingResult

Type: Object

Properties

  • status number Sizing status (if not 0 it is not available)
  • consumer_hash string Consumer hash (created or updated)
  • primary Object Best found size
    • primary.name string Name of the primary size
    • primary.percent string Percentage of the primary size
  • secondary Object Best found size
    • secondary.name string Name of the secondary size
    • secondary.percent string Percentage of the secondary size

SizingResult

Type: Object

Properties

  • primary Object Best found size
    • primary.name string Name of the primary size
    • primary.percent string Percentage of the primary size
  • secondary Object Best found size
    • secondary.name string Name of the secondary size
    • secondary.percent string Percentage of the secondary size

SizechartResult

Type: Array<Object>

Properties

  • gender string Gender of the measures
  • sizes Array<Object> Sizes array
    • sizes.name string Name of the size
    • sizes.dimensions Array<Object> 2D/3D dimensions of the size
      • sizes.dimensions.position string Position code of the dimension
      • sizes.dimensions.measure string Measure in mm of the dimension

SizechartResult

Type: Array<Object>

Properties

  • gender string Gender of the measures
  • image string? SVG Image describing dimensions
  • sizes Array<Object> Sizes array
    • sizes.name string Name of the size
    • sizes.dimensions Array<Object> 2D/3D dimensions of the size
      • sizes.dimensions.position string Position code of the dimension
      • sizes.dimensions.measure string Measure in mm of the dimension

AssembleProductData

Type: Object

AssembleProductData

Type: Object

AssembleResult

Type: Object

Properties

  • config ConfigResult Configuration bject fro current domain
  • lang Object Language object with all the string for requested langaguage
  • apparel_images Object Object with image url for each apparel type
  • rates Object Rates info
  • html string Mustache HTML template for Size Form Widget
  • tests Array<Object> URL regexp to check for order processed page
    • tests[].code string Test code
  • referenceExists boolean True if URLs or Product reference found for size recommendation
  • referenceCode string? Code of the found referenced product
  • sizing SizingResult? Size recommendation
  • sizechart SizechartResult? Product measures (both 2D and 3D) if available
  • Product AssembleProductData? Product data

Commodities

Naiz Fit Size Chart commodiies, a set of utilities to be used or overriden

langFromBrowser

Extract language, this gets language configuration from browser and parses to get the language code

Returns string Language code (es, fr, en...)

canonicalAlternatesAndLocation

Extract canonical and alternate urls in a array.

Returns Array<string> Canonical and alternate URLs

consumerHashFromLocalStorage

Extract Naiz Fit consumer hash from local storage

Returns (string | null) Consumer hash

productReferenceFromTags

Extract Product reference from tags with Naiz Fit data properties

Returns (Object | null) reference Reference object with code and brand

Returns string reference.code Product reference code

Returns string reference.brand Product brand name

visitorFromLocalStorage

Extract visitor from localstorage, or sets a new one

Returns (string | null) Existing or new visitor hash

sessionFromSessionStorage

Extract Session from session storage, or sets a new one

Returns (string | null) Existing or new session hash

consumerDataFromNaizLocalStorage

Extract Naiz Fit consumer hash from Naiz Fit domain's local storage

Returns string data.hash The consumer hash

Returns ("MALE" | "FEMALE") data.gender The consumer gender

Returns ("LOOSE" | "NORMAL" | "FIT") data.loosening The consumer loosening preference

Returns number data.height The consumer height in cms

Returns number data.weight The consumer weight in kgs

Returns number data.birthYear The consumer birth year

consumerDataToNaizLocalStorage

Set Naiz Fit consumer hash in Naiz Fit domain's local storage

Parameters

  • hash string The consumer hash
  • gender ("MALE" | "FEMALE") The consumer gender
  • loosening ("LOOSE" | "NORMAL" | "FIT") The consumer loosening preference
  • height number The consumer height in cms
  • weight number The consumer weight in kgs
  • birthYear number The consumer birth year

Returns Promise A promise resolved when success

conversion

Conversion utility for height and weight

Parameters

  • src String Source unit
  • target String Target unit
  • value number Source value
  • extras Object Object containing values of extra values that might be needed for conversion

Returns number Value converted to target unit

ConsumerData

Type: Object

ExtractData

Type: Object

AssembleData

Type: Object

Properties

  • config ConfigResult Configuration bject fro current domain
  • lang Object Language object with all the string for requested langaguage
  • rates Object Rates info
  • apparel_images Object Rates info
  • product AssembleProductData Rates info
  • html string Handlebars HTML template for Size Form Widget
  • tests Array<Object> URL regexp to check for order processed page
    • tests[].code string Test code
  • referenceExists boolean True if URLs or Product reference found for size recommendation
  • referenceCode string? Code of the found referenced product
  • sizing SizingResult? Size recommendation
  • sizechart SizechartResult? Product measures (both 2D and 3D) if available

TemplateData

Type: Object

Parameters

  • lang Object Language object with all the string for requested langaguage
  • SizeChart Object? The size chart data
    • SizeChart.dimensions Array<string>? All product dimension codes (Name can be get with "lang" helper)
    • SizeChart.sizes Array<Object>? Array with the dimensions data for each product size
  • string string [].sizeName] Name of the size
  • string string [].dimensions[].name] Code of the dimension (Name can be get with "lang" helper)
  • number number [].dimensions[].value] Dimension value in centimeters

FormData

Type: Object

Parameters

  • height number Consumer height in mms
  • weight number Consumer weight in kgs
  • birthYear number Consumer birth year
  • gender ("MALE" | "FEMALE") Consumer birth year
  • loosening ("LOOSE" | "NORMAL" | "FIT") Consumer loosening preference

NaizJSDefault

Properties

  • enabled boolean =true Enables or disables size form automatic rendering, can be edited by tests or domain config
  • endpoint string Backend service URL endpoint, defaults to https://backend.production.naiz.fit
  • partnerKey string Partner key used to connect the backend services
  • openerSelector string ='[data-naiz-opener]' DOM element selector to append the Naiz Fit Size Form opener button
  • formContainerSelector string ='body' DOM element selector to append the Naiz Fit Size Form opener button
  • formEl HTMLElement DOM element with the form
  • mode ("SELECTOR" | "NONE" | "TAG" | "DEMO") ='SELECTOR' Determines the Naiz Fit Size Form loading mode
  • extractedData ExtractData Extracted data for assemble request
  • assembleData AssembleData Received data from assemble request

apiService

Instanced API Service

constructor

Construcor

Parameters

openerEl

Generates the opener element from the templates

Parameters

sizeformEl

Generates the sizeformEl element from the templates

Parameters

render

Renders the Naiz Fit Size Form inserting the opener where apropiate and the size form in the container

openSizeForm

Displays the formContainerElement

closeSizeForm

Hides the formContainerElement

parseTemplate

Precompiles the handlebars template

getTemplateData

Get the required data for the template to be rendered

Returns TemplateData Template data object for Handlebars template merged with custom template data from getCustomTemplateData if exists

extractFormData

Extracts data from the naiz fit form needed to make the sizing request and get the consumer hash

Returns FormData Form data to use for the recommendation

extract

Extract the required information for the Size Form Widget to make the assemble request. This can be overriden in the customisations script

Returns Promise<ExtractData> Data needed for the assemble call

extractVisitor

Extract the visitor hash. This can be overriden.

Returns Promise<Object> result Object containing the visitor

Returns string result.visitor Visitor hash

extractSession

Extract the session hash. This can be overriden.

Returns Promise<Object> result Object containing the session hash

Returns string result.session Session hash

extractView

Extract the test view. This can be overriden.

Returns Promise<Object> result Object containing the tests view

Returns string result.view Tests view

extractLanguage

Extract the language code. This can be overriden.

Returns Promise<Object> result Object containing the language code

Returns string result.lang='es' Language code (es, fr, en...)

extractUrls

Extract the URLs object. This can be overriden.

Returns Promise<Object> result Object containing the urls array code

Returns Array<string> result.urls Current location, canonical and alternate URLs in a single array

extractConsumerData

Extract the Naiz Fit consumer data

Returns Promise<Object> result Object containing the consumer data

Returns string data.hash The consumer hash

Returns ("MALE" | "FEMALE") data.gender The consumer gender

Returns ("LOOSE" | "NORMAL" | "FIT") data.loosening The consumer loosening preference

Returns number data.height The consumer height in cms

Returns number data.weight The consumer weight in kgs

Returns number data.birthYear The consumer birth year

setConsumerData

Set the Naiz Fit consumer hash

Parameters

  • hash string The consumer hash
  • gender ("MALE" | "FEMALE") The consumer gender
  • loosening ("LOOSE" | "NORMAL" | "FIT") The consumer loosening preference
  • height number The consumer height in cms
  • weight number The consumer weight in kgs
  • birthYear number The consumer birth year

Returns Promise<boolean> Returns true when fullfilled

extractProductReference

Extract the product reference

Returns Promise<Object> result Object containing the product refence

Returns Object result.reference Product reference object

Returns string result.refernce.code Product reference code

Returns string result.refernce.brand Product brand name

extractImageSrc

Extract the image source

Returns string Image source for the form

extractOrderData

Extract the order data when order page detected

Returns Object result Order data

Returns string result.order_number Order reference

Returns string result.order_value Order value

Returns Object result.order_data Order extra data

debugEnabled

Get te debug enabled status

Returns boolean Debug enabled or not

checkOrderPage

Check if the page is an order success page to send the analytics event

Returns boolean true if this is a order success page