@nuskin/ns-product-lib 1.5.0-cx24-2121.1.1 → 1.5.0-cx24-2121.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/package.json +1 -1
- package/src/productData.js +49 -35
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
# [1.5.0-cx24-2121.1.4](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v1.5.0-cx24-2121.1.3...v1.5.0-cx24-2121.1.4) (2022-08-19)
|
2
|
+
|
3
|
+
|
4
|
+
### Update
|
5
|
+
|
6
|
+
* pass the store ID to getProductData (CX24-2121) ([2f994f6](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/2f994f6214d9854648bf4bef62d47694f59e4001))
|
7
|
+
|
8
|
+
# [1.5.0-cx24-2121.1.3](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v1.5.0-cx24-2121.1.2...v1.5.0-cx24-2121.1.3) (2022-08-19)
|
9
|
+
|
10
|
+
|
11
|
+
### Update
|
12
|
+
|
13
|
+
* pass the store ID to getProductData (CX24-2121) ([8bb39fb](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/8bb39fb1179514ed02a5efd35ed86e1f75b53ff7))
|
14
|
+
|
15
|
+
# [1.5.0-cx24-2121.1.2](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v1.5.0-cx24-2121.1.1...v1.5.0-cx24-2121.1.2) (2022-08-19)
|
16
|
+
|
17
|
+
|
18
|
+
### Update
|
19
|
+
|
20
|
+
* remove hardcoded store ID (CX24-2121) ([3dd107e](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/3dd107ee1cf12de883f6756f271fc7954f0d60f2))
|
21
|
+
|
1
22
|
# [1.5.0-cx24-2121.1.1](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v1.5.0-CX24.1...v1.5.0-cx24-2121.1.1) (2022-08-18)
|
2
23
|
|
3
24
|
|
package/package.json
CHANGED
package/src/productData.js
CHANGED
@@ -1,45 +1,59 @@
|
|
1
1
|
"use strict";
|
2
2
|
const axios = require("axios");
|
3
3
|
const product = require("./product")
|
4
|
-
|
4
|
+
/** @type {*} */
|
5
5
|
const ProductData = {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
let productDataResponse = await axios.request({
|
15
|
-
method: 'get',
|
16
|
-
url: `https://storefront.api.wts.nuskin.io/orchestrationservices/storefront/catalogs/search/`,
|
17
|
-
params: {
|
18
|
-
locale: locale,
|
19
|
-
storeId: '406',
|
20
|
-
filter: filter
|
21
|
-
},
|
22
|
-
headers: this.getProductDataRequestHeaders(marketConfig),
|
23
|
-
responseType: "json"
|
24
|
-
});
|
25
|
-
productResponse = this.eqProductMapper(productDataResponse.data.product)
|
6
|
+
/**
|
7
|
+
* @param {*} skus
|
8
|
+
* @param {*} runConfig
|
9
|
+
* @param {*} marketConfig
|
10
|
+
* @param {{ isEnabled: boolean, storeID: string }} equinoxOptions
|
11
|
+
*/
|
12
|
+
getProductData: async function (skus, runConfig, marketConfig, equinoxOptions) {
|
13
|
+
const locale = `${runConfig.language}_${runConfig.country}`;
|
26
14
|
|
27
|
-
|
28
|
-
|
29
|
-
const payload = {
|
30
|
-
locale: locale,
|
31
|
-
skus: skus
|
32
|
-
};
|
33
|
-
productResponse = await axios.request({
|
34
|
-
method: "post",
|
35
|
-
url: lambdaUrl,
|
36
|
-
data: payload,
|
37
|
-
headers: this.getProductDataRequestHeaders(marketConfig),
|
38
|
-
responseType: "json"
|
39
|
-
});
|
15
|
+
if (equinoxOptions !== undefined && equinoxOptions.isEnabled === true) {
|
16
|
+
return await this.getProductFromEquinox(skus, locale, marketConfig, equinoxOptions.storeID);
|
40
17
|
}
|
41
18
|
|
42
|
-
return
|
19
|
+
return await this.getProductFromLegacy(skus, locale, marketConfig);
|
20
|
+
},
|
21
|
+
|
22
|
+
getProductFromEquinox: async function(skus, locale, marketConfig, storeID) {
|
23
|
+
const filter = `{
|
24
|
+
"filters": [{
|
25
|
+
"field": "index_key_skuId",
|
26
|
+
"operation": "IN",
|
27
|
+
"value": "${skus.toString()}"
|
28
|
+
}]
|
29
|
+
}`;
|
30
|
+
axios.defaults.withCredentials = true;
|
31
|
+
const productDataResponse = await axios.request({
|
32
|
+
method: 'get',
|
33
|
+
url: `https://storefront.api.wts.nuskin.io/orchestrationservices/storefront/catalogs/search/`,
|
34
|
+
params: {
|
35
|
+
locale,
|
36
|
+
storeId: storeID,
|
37
|
+
filter
|
38
|
+
},
|
39
|
+
headers: this.getProductDataRequestHeaders(marketConfig),
|
40
|
+
responseType: "json"
|
41
|
+
});
|
42
|
+
|
43
|
+
return this.eqProductMapper(productDataResponse.data.product);
|
44
|
+
},
|
45
|
+
|
46
|
+
getProductFromLegacy: async function(skus, locale, marketConfig) {
|
47
|
+
const lambdaUrl = `${marketConfig.awsUrl}/productData/v1`;
|
48
|
+
const payload = { locale, skus };
|
49
|
+
|
50
|
+
return await axios.request({
|
51
|
+
method: "post",
|
52
|
+
url: lambdaUrl,
|
53
|
+
data: payload,
|
54
|
+
headers: this.getProductDataRequestHeaders(marketConfig),
|
55
|
+
responseType: "json"
|
56
|
+
});
|
43
57
|
},
|
44
58
|
|
45
59
|
/* eqProductMapper: function(productDataResponse) {
|