@nuskin/ns-product-lib 2.11.0-cx24-5092.15 → 2.11.0-cx24-5092.16
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 +8 -0
- package/package.json +1 -1
- package/src/productData.js +1 -1
- package/src/productGraphQL.js +36 -1
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# [2.11.0-cx24-5092.16](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.15...v2.11.0-cx24-5092.16) (2023-09-14)
|
2
|
+
|
3
|
+
|
4
|
+
### New
|
5
|
+
|
6
|
+
* Moving from AEM to CS for EQ markets ([95c3072](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/95c30729cdbccd4a1520a276057d227d7050f02d))
|
7
|
+
* Moving from AEM to CS for EQ markets ([8dd3f14](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/8dd3f14feaddd492c657cee8bd630c6c7b533e83))
|
8
|
+
|
1
9
|
# [2.11.0-cx24-5092.15](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.14...v2.11.0-cx24-5092.15) (2023-09-14)
|
2
10
|
|
3
11
|
|
package/package.json
CHANGED
package/src/productData.js
CHANGED
@@ -28,7 +28,7 @@ const ProductData = {
|
|
28
28
|
|
29
29
|
const config = (await getConfiguration(['Equinox_Markets'])).Equinox_Markets;
|
30
30
|
if (config.active) {
|
31
|
-
graphQLResponse = ProductGraphQL.getProductFromGraphQL(skus[0], market, locale)
|
31
|
+
graphQLResponse = await ProductGraphQL.getProductFromGraphQL(skus[0], market, locale, config)
|
32
32
|
console.log(graphQLResponse)
|
33
33
|
return graphQLResponse;
|
34
34
|
}
|
package/src/productGraphQL.js
CHANGED
@@ -27,7 +27,7 @@ const ProductGraphQL = {
|
|
27
27
|
return "https://www.nuskin.com/product-api/graphql";
|
28
28
|
}
|
29
29
|
},
|
30
|
-
getProductFromGraphQL: async function (id, market, locale) {
|
30
|
+
getProductFromGraphQL: async function (id, market, locale, config) {
|
31
31
|
|
32
32
|
|
33
33
|
const url = this.getProductGraphqlUrl();
|
@@ -44,6 +44,10 @@ const ProductGraphQL = {
|
|
44
44
|
data: payload,
|
45
45
|
responseType: 'json'
|
46
46
|
});
|
47
|
+
const productId = response.data.data.productById.id
|
48
|
+
const sku = response.data.data.productById.variants[0].sku
|
49
|
+
const promotionResponse = await this.getProductPromotions(sku, productId, config, locale)
|
50
|
+
console.log(JSON.stringify(promotionResponse))
|
47
51
|
return {
|
48
52
|
data: {
|
49
53
|
"status": 200,
|
@@ -64,6 +68,37 @@ const ProductGraphQL = {
|
|
64
68
|
|
65
69
|
|
66
70
|
|
71
|
+
},
|
72
|
+
|
73
|
+
getProductPromotions: async function (sku, productId, config, locale) {
|
74
|
+
|
75
|
+
const url = config.API_Base_URLs
|
76
|
+
const sub = config.kong_subdomains + '/catalogs/products/'
|
77
|
+
const storeId = config.store_id
|
78
|
+
const payload = {
|
79
|
+
"productId": productId,
|
80
|
+
"categoryId": ["all_products"],
|
81
|
+
"skus": [{
|
82
|
+
"skuId": sku,
|
83
|
+
"productId": productId,
|
84
|
+
"type": "DEFAULT"
|
85
|
+
}],
|
86
|
+
"isSubscriptionIncludedInPromotion": true
|
87
|
+
}
|
88
|
+
|
89
|
+
try {
|
90
|
+
const response = await axios.request({
|
91
|
+
method: 'post',
|
92
|
+
url: url + sub + productId + '/promotions?locale=' + locale + '&storeId=' + storeId,
|
93
|
+
data: payload,
|
94
|
+
responseType: 'json'
|
95
|
+
});
|
96
|
+
return response
|
97
|
+
} catch (e) {
|
98
|
+
console.log(e)
|
99
|
+
}
|
100
|
+
|
101
|
+
|
67
102
|
},
|
68
103
|
|
69
104
|
mapResponseToProduct: function (response, market, locale) {
|