@nuskin/ns-product-lib 2.2.0 → 2.3.0-cx24-2186.1

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [2.3.0-cx24-2186.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.2.0...v2.3.0-cx24-2186.1) (2022-10-13)
2
+
3
+
4
+ ### New
5
+
6
+ * added inventory label in the mapping (#CX24-2186) ([a24fc39](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/a24fc39915e3d7e525949a2de8be04727c5226fd)), closes [#CX24-2186](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/issues/CX24-2186)
7
+
1
8
  # [2.2.0](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.1.0...v2.2.0) (2022-10-13)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.2.0",
3
+ "version": "2.3.0-cx24-2186.1",
4
4
  "description": "This project contains shared Product models and code between the backend and frontend.",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/product.js CHANGED
@@ -72,6 +72,11 @@ const Product = function(productData) {
72
72
  // agelocme stuff
73
73
  this.agelocme = null; // object containing agelocme information (like code, label, name)
74
74
 
75
+ //equinox API inventory label
76
+ //@example "IN STOCK"
77
+ //@string inventoryLabel
78
+ this.inventoryLabel = "";
79
+
75
80
  this.setMarketAttributes = function(productStatus) {
76
81
  if (productStatus.marketAttributes) {
77
82
  this.marketAttributes = productStatus.marketAttributes;
@@ -626,6 +631,7 @@ const Product = function(productData) {
626
631
  this.marketAttributes = productData.marketAttributes;
627
632
  this.addOns = productData.addOns || [];
628
633
  this.restrictedMarkets = productData.restrictedMarkets || [];
634
+ this.inventoryLabel = productData.inventoryLabel || "";
629
635
 
630
636
  if (data.priceType) {
631
637
  this.addPricing(data.priceType, data.price);
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  const axios = require("axios");
3
3
  const contentstack = require('./contentstack/contentstack');
4
- const product = require("./product");
4
+ const Product = require("./product");
5
5
 
6
6
  /** @type {*} */
7
7
  const ProductData = {
8
8
  /**
9
- * @param {string[]} skus
10
- * @param {string} locale
11
- * @param {string} market
12
- * @param {boolean} isEquinoxEnabled
9
+ * @param {string[]} skus
10
+ * @param {string} locale
11
+ * @param {string} market
12
+ * @param {boolean} isEquinoxEnabled
13
13
  */
14
14
  getProductData: async function (skus, locale, market, isEquinoxEnabled = false) {
15
15
  const localeMarket = `${locale}_${market}`;
@@ -28,7 +28,7 @@ const ProductData = {
28
28
  getProductFromEquinox: async function (skus, locale, storeID) {
29
29
  const filter = '{"filters":[{"field":"index_key_skuId","operation":"IN","value":"' + skus.toString() + '"}]}';
30
30
  axios.defaults.withCredentials = true;
31
-
31
+
32
32
  const url = await contentstack.getKongUrl() + `/orchestrationservices/storefront/catalogs/search/`;
33
33
  console.log("Dynamic URL", url)
34
34
  const href = `${url}?filter=${encodeURI(filter)}`;
@@ -78,7 +78,7 @@ const ProductData = {
78
78
  responseType: 'json'
79
79
  });
80
80
  },
81
-
81
+
82
82
  /**
83
83
  * @param {contentstack.MarketConfig} marketConfig
84
84
  */
@@ -92,13 +92,15 @@ const ProductData = {
92
92
 
93
93
  eqProductMapper: function (productDataResponse) {
94
94
  let prod = [];
95
+
96
+ //sku[0] is equal to base sku
95
97
  let count = 0;
96
98
 
97
99
  let prodArr = productDataResponse.map((data) => {
98
100
  let imageURL = data.sku[count].properties.imageURL;
99
101
  const regex = /\d+.\d+/
100
102
  let thumbnailImage = ''
101
-
103
+
102
104
  if (imageURL.includes('contentstack')) {
103
105
  thumbnailImage = imageURL + '?width=40'
104
106
  } else {
@@ -207,16 +209,18 @@ const ProductData = {
207
209
  "earn": true
208
210
  },
209
211
  "restrictedMarkets": [],
210
- "addOns": []
212
+ "addOns": [],
213
+ inventoryLabel: data.sku[count].inventory || ""
211
214
  };
212
- let newProduct = new product(prod);
213
- return newProduct
214
- })
215
+
216
+ return new Product(prod);
217
+ });
215
218
 
216
219
  let data = {
217
220
  products: prodArr,
218
221
  count: productDataResponse.length
219
222
  };
223
+
220
224
  return {
221
225
  data: {
222
226
  "status": 200,
@@ -252,13 +256,13 @@ const ProductData = {
252
256
  },
253
257
 
254
258
  /**
255
- *
256
- * @param {*} custType
257
- *
259
+ *
260
+ * @param {*} custType
261
+ *
258
262
  */
259
263
  switchCustType: function (custType) {
260
264
  let newCustType = [];
261
- if (custType.includes('Brand Affiliate - Business Entity') || custType.includes('Brand Affiliate - Individual'))
265
+ if (custType.includes('Brand Affiliate - Business Entity') || custType.includes('Brand Affiliate - Individual'))
262
266
  newCustType.push(10)
263
267
  if (custType.includes('Retail Customer'))
264
268
  newCustType.push(20)