@nuskin/ns-product-lib 2.11.0-cx24-5092.19 → 2.11.0-cx24-5092.21

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [2.11.0-cx24-5092.21](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.20...v2.11.0-cx24-5092.21) (2023-09-14)
2
+
3
+
4
+ ### New
5
+
6
+ * Moving from AEM to CS for EQ markets ([ff40018](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/ff400181cdb045fcb904ce0c2aa22a03f5f1ab22))
7
+
8
+ # [2.11.0-cx24-5092.20](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.19...v2.11.0-cx24-5092.20) (2023-09-14)
9
+
10
+
11
+ ### New
12
+
13
+ * Moving from AEM to CS for EQ markets ([a8fe3f7](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/commit/a8fe3f7c832a00bb4cbf29528633ea7542f065d0))
14
+
1
15
  # [2.11.0-cx24-5092.19](https://code.tls.nuskin.io/ns-am/product/js-libs/ns-product-lib/compare/v2.11.0-cx24-5092.18...v2.11.0-cx24-5092.19) (2023-09-14)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/ns-product-lib",
3
- "version": "2.11.0-cx24-5092.19",
3
+ "version": "2.11.0-cx24-5092.21",
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": {
@@ -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 = await 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
  } else {
@@ -27,9 +27,9 @@ const ProductGraphQL = {
27
27
  return "https://www.nuskin.com/product-api/graphql";
28
28
  }
29
29
  },
30
- getProductFromGraphQL: async function (id, market, locale) {
31
-
30
+ getProductFromGraphQL: async function (id, market, locale, config) {
32
31
 
32
+ console.log(config)
33
33
  const url = this.getProductGraphqlUrl();
34
34
  const payload = {
35
35
  query: getProductGql,
@@ -45,9 +45,11 @@ const ProductGraphQL = {
45
45
  responseType: 'json'
46
46
  });
47
47
 
48
- console.log(response.data)
49
48
  let products = [];
50
- products.push(this.mapResponseToProduct(response.data.data.productById, market, locale))
49
+ let mappedResponse = await this.mapResponseToProduct(response.data.data.productById, market, locale, config)
50
+ products.push(mappedResponse)
51
+
52
+
51
53
 
52
54
  return {
53
55
  data: {
@@ -96,7 +98,8 @@ const ProductGraphQL = {
96
98
 
97
99
  },
98
100
 
99
- mapResponseToProduct: function (response, market, locale) {
101
+ mapResponseToProduct: async function (response, market, locale, config) {
102
+ console.log('RESPONSE ' + JSON.stringify(response))
100
103
  let res = {
101
104
  "sku": response.variants[0].sku,
102
105
  "globalProductID": response.id,
@@ -127,19 +130,19 @@ const ProductGraphQL = {
127
130
  "WADW-WRTL": response.variants[0].totalPrice.retailSubscription,
128
131
  "WADR": response.variants[0].totalPrice.retailSubscription, //retail ADR (subscription) price
129
132
  "RTL": response.variants[0].totalPrice.retail,
130
- "WWHL": response.variants[0].totalPrice.wholeSale,
133
+ "WWHL": response.variants[0].totalPrice.wholesale,
131
134
  "WADW": response.variants[0].totalPrice.wholesaleSubscription,//wholesale ADR (subscription price)
132
- "WHL": response.variants[0].totalPrice.wholeSale
135
+ "WHL": response.variants[0].totalPrice.wholesale
133
136
  },
134
137
  "cvMap": {
135
- "WWHL": response.variants[0].totalPoints.wholeSale.cv,
136
- "WADW": response.variants[0].totalPoints.subscription.cv,
137
- "WHL": response.variants[0].totalPoints.wholeSale.cv
138
+ "WWHL": response.variants[0].points.wholesale.cv,
139
+ "WADW": response.variants[0].points.subscription.cv,
140
+ "WHL": response.variants[0].points.wholesale.cv
138
141
  },
139
142
  "pvMap": {
140
- "WWHL": response.variants[0].totalPoints.wholeSale.pv,
141
- "WADW": response.variants[0].totalPoints.subscription.pv,
142
- "WHL": response.variants[0].totalPoints.wholeSale.pv
143
+ "WWHL": response.variants[0].points.wholesale.pv,
144
+ "WADW": response.variants[0].points.subscription.pv,
145
+ "WHL": response.variants[0].points.wholesale.pv
143
146
  },
144
147
  "orderTypes": this._setOrderType(response.variants[0].purchaseTypes),
145
148
  "custTypes": {},
@@ -163,6 +166,8 @@ const ProductGraphQL = {
163
166
  "equinoxProductId": response.id,
164
167
  "properties": {}
165
168
  }
169
+ const promotions = await this.getProductPromotions(response.variants[0].sku, response.variants[0].id, config, locale)
170
+ console.log(promotions)
166
171
  return res;
167
172
  },
168
173
  /**