@things-factory/integration-marketplace 4.2.1 → 4.2.5

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.
Files changed (37) hide show
  1. package/dist-server/controllers/magento/apis/get-store-order.js +20 -0
  2. package/dist-server/controllers/magento/apis/get-store-order.js.map +1 -0
  3. package/dist-server/controllers/magento/apis/get-store-orders.js +33 -4
  4. package/dist-server/controllers/magento/apis/get-store-orders.js.map +1 -1
  5. package/dist-server/controllers/magento/apis/get-store-product-categories.js +47 -0
  6. package/dist-server/controllers/magento/apis/get-store-product-categories.js.map +1 -0
  7. package/dist-server/controllers/magento/apis/get-store-products.js +29 -11
  8. package/dist-server/controllers/magento/apis/get-store-products.js.map +1 -1
  9. package/dist-server/controllers/magento/apis/get-store-stock-item.js +1 -1
  10. package/dist-server/controllers/magento/apis/get-store-stock-item.js.map +1 -1
  11. package/dist-server/controllers/magento/apis/index.js +5 -0
  12. package/dist-server/controllers/magento/apis/index.js.map +1 -1
  13. package/dist-server/controllers/magento/apis/update-order-status.js +82 -0
  14. package/dist-server/controllers/magento/apis/update-order-status.js.map +1 -0
  15. package/dist-server/controllers/magento/apis/update-store-product-price.js +28 -0
  16. package/dist-server/controllers/magento/apis/update-store-product-price.js.map +1 -0
  17. package/dist-server/controllers/magento/apis/update-store-product-stock.js +1 -1
  18. package/dist-server/controllers/magento/apis/update-store-product-stock.js.map +1 -1
  19. package/dist-server/controllers/magento/apis/update-store-product-variation-price.js +28 -0
  20. package/dist-server/controllers/magento/apis/update-store-product-variation-price.js.map +1 -0
  21. package/dist-server/controllers/magento/apis/update-store-product-variation-stock.js +1 -1
  22. package/dist-server/controllers/magento/apis/update-store-product-variation-stock.js.map +1 -1
  23. package/dist-server/controllers/woocommerce/apis/update-order-status.js +17 -15
  24. package/dist-server/controllers/woocommerce/apis/update-order-status.js.map +1 -1
  25. package/package.json +2 -2
  26. package/server/controllers/magento/apis/get-store-order.ts +15 -0
  27. package/server/controllers/magento/apis/get-store-orders.ts +35 -4
  28. package/server/controllers/magento/apis/get-store-product-categories.ts +43 -0
  29. package/server/controllers/magento/apis/get-store-products.ts +35 -11
  30. package/server/controllers/magento/apis/get-store-stock-item.ts +1 -1
  31. package/server/controllers/magento/apis/index.ts +5 -0
  32. package/server/controllers/magento/apis/update-order-status.ts +81 -0
  33. package/server/controllers/magento/apis/update-store-product-price.ts +24 -0
  34. package/server/controllers/magento/apis/update-store-product-stock.ts +1 -1
  35. package/server/controllers/magento/apis/update-store-product-variation-price.ts +24 -0
  36. package/server/controllers/magento/apis/update-store-product-variation-stock.ts +1 -1
  37. package/server/controllers/woocommerce/apis/update-order-status.ts +18 -14
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getStoreOrder = void 0;
4
+ function getStoreOrder() {
5
+ return {
6
+ path: '/orders/{id}',
7
+ method: 'get',
8
+ denormalize(req) {
9
+ let { id } = req;
10
+ return {
11
+ resource: { id }
12
+ };
13
+ },
14
+ normalize(res) {
15
+ return res;
16
+ }
17
+ };
18
+ }
19
+ exports.getStoreOrder = getStoreOrder;
20
+ //# sourceMappingURL=get-store-order.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-store-order.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/get-store-order.ts"],"names":[],"mappings":";;;AAAA,SAAgB,aAAa;IAC3B,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,MAAM,EAAE,KAAK;QACb,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,EAAE,EAAE,GAAG,GAAG,CAAA;YAChB,OAAO;gBACL,QAAQ,EAAE,EAAE,EAAE,EAAE;aACjB,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAdD,sCAcC"}
@@ -49,14 +49,18 @@ function getStoreOrders() {
49
49
  let result;
50
50
  let docRefNo = orderNo;
51
51
  let orderItems = items.map(item => {
52
- var { item_id: name, product_id, qty_ordered: qty, price } = item;
52
+ var { item_id: name, product_id, qty_ordered: qty, price, original_price, price, tax_amount, tax_invoiced } = item;
53
53
  return {
54
54
  name,
55
55
  variationId: product_id,
56
56
  qty,
57
57
  paidPrice: price,
58
58
  orderNo,
59
- docRefNo
59
+ docRefNo,
60
+ total: price,
61
+ totalTax: tax_invoiced,
62
+ subtotal: original_price,
63
+ subtotalTax: tax_amount
60
64
  };
61
65
  });
62
66
  result = {
@@ -83,14 +87,39 @@ function getStoreOrders() {
83
87
  postCode: postcode,
84
88
  city,
85
89
  country: country_id === 'MY' ? 'Malaysia' : country_id,
86
- collectionCurrency: null,
90
+ collectionCurrency: order.order_currency_code,
87
91
  attentionTo: `${firstname} ${middlename} ${lastname}`
88
92
  };
89
93
  result.orderShipping = orderShipping;
94
+ // For SC mapping
95
+ result.shipping = {
96
+ address_1: street,
97
+ postcode: postcode,
98
+ country: country_id,
99
+ city,
100
+ first_name: firstname,
101
+ last_name: lastname,
102
+ phone: telephone,
103
+ email: order.customer_email
104
+ };
105
+ let billingAddress = order === null || order === void 0 ? void 0 : order.billing_address;
106
+ result.billing = {
107
+ address_1: billingAddress.street,
108
+ postcode: billingAddress.postcode,
109
+ country: billingAddress.country_id,
110
+ city: billingAddress.city,
111
+ first_name: billingAddress.firstname,
112
+ last_name: billingAddress.lastname,
113
+ phone: billingAddress.telephone,
114
+ email: billingAddress.email
115
+ };
116
+ result.firstName = order.customer_firstname;
117
+ result.lastName = order.customer_lastname;
90
118
  }
91
119
  return result;
92
120
  });
93
- return { results };
121
+ let more = res.search_criteria.page_size * res.search_criteria.current_page < res.total_count || false;
122
+ return { results, more };
94
123
  }
95
124
  };
96
125
  }
@@ -1 +1 @@
1
- {"version":3,"file":"get-store-orders.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/get-store-orders.ts"],"names":[],"mappings":";AAAA,gGAAgG;;;AAEhG,SAAgB,cAAc;IAC5B,OAAO;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E,QAAQ;wBAClB,IAAI;wBACJ,OAAO,EAAE,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU;wBACtD,kBAAkB,EAAE,IAAI;wBACxB,WAAW,EAAE,GAAG,SAAS,IAAI,UAAU,IAAI,QAAQ,EAAE;qBACtD,CAAA;oBAED,MAAM,CAAC,aAAa,GAAG,aAAa,CAAA;iBACrC;gBAED,OAAO,MAAM,CAAA;YACf,CAAC,CAAC,CAAA;YAEF,OAAO,EAAE,OAAO,EAAE,CAAA;QACpB,CAAC;KACF,CAAA;AACH,CAAC;AA3HD,wCA2HC"}
1
+ {"version":3,"file":"get-store-orders.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/get-store-orders.ts"],"names":[],"mappings":";AAAA,gGAAgG;;;AAEhG,SAAgB,cAAc;IAC5B,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,SAAS;QACf,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,GAAG,IAAI,EAAE,CAAA;YAChD,IAAI,EAAE,IAAI,GAAG,CAAC,EAAE,KAAK,GAAG,GAAG,EAAE,GAAG,UAAU,IAAI,EAAE,CAAA;YAEhD,IAAI,cAAc,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAA;YACrD,IAAI,cAAc,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAA;YACnD,kEAAkE;YAClE,oCAAoC;YACpC,2BAA2B;YAE3B,IAAI,OAAO,GAAQ;gBACjB,WAAW,EAAE,IAAI;gBACjB,QAAQ,EAAE,KAAK;gBACf,aAAa,EAAE;oBACb;wBACE,OAAO,EAAE;4BACP;gCACE,KAAK,EAAE,YAAY;gCACnB,KAAK,EAAE,cAAc;gCACrB,cAAc,EAAE,MAAM;6BACvB;yBACF;qBACF;oBACD;wBACE,OAAO,EAAE;4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AAI,cAAc,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,eAAe,CAAA;oBAC3C,MAAM,CAAC,OAAO,GAAG;wBACf,SAAS,EAAE,cAAc,CAAC,MAAM;wBAChC,QAAQ,EAAE,cAAc,CAAC,QAAQ;wBACjC,OAAO,EAAE,cAAc,CAAC,UAAU;wBAClC,IAAI,EAAE,cAAc,CAAC,IAAI;wBACzB,UAAU,EAAE,cAAc,CAAC,SAAS;wBACpC,SAAS,EAAE,cAAc,CAAC,QAAQ;wBAClC,KAAK,EAAE,cAAc,CAAC,SAAS;wBAC/B,KAAK,EAAE,cAAc,CAAC,KAAK;qBAC5B,CAAA;oBACD,MAAM,CAAC,SAAS,GAAG,KAAK,CAAC,kBAAkB,CAAA;oBAC3C,MAAM,CAAC,QAAQ,GAAG,KAAK,CAAC,iBAAiB,CAAA;iBAC1C;gBAED,OAAO,MAAM,CAAA;YACf,CAAC,CAAC,CAAA;YAEF,IAAI,IAAI,GAAG,GAAG,CAAC,eAAe,CAAC,SAAS,GAAG,GAAG,CAAC,eAAe,CAAC,YAAY,GAAG,GAAG,CAAC,WAAW,IAAI,KAAK,CAAA;YAEtG,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;QAC1B,CAAC;KACF,CAAA;AACH,CAAC;AA1JD,wCA0JC"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getStoreProductCategories = void 0;
4
+ function getStoreProductCategories() {
5
+ return {
6
+ method: 'get',
7
+ path: '/categories/list',
8
+ denormalize(req) {
9
+ var { pagination } = req || {};
10
+ var { page = 0, limit = 100 } = pagination || {};
11
+ const resource = {};
12
+ const payload = {
13
+ pageSize: limit,
14
+ currentPage: page
15
+ };
16
+ return { resource, payload };
17
+ },
18
+ normalize(res) {
19
+ let results = res.items;
20
+ results = mapCategories(results, []);
21
+ results = results.map(result => {
22
+ let { id, name, parent_id, is_active, children_data } = result;
23
+ return {
24
+ id,
25
+ name,
26
+ parent: parent_id,
27
+ isActive: is_active
28
+ // childrenCategories: children_data
29
+ };
30
+ });
31
+ results = results.filter(cat => cat.parent != 0);
32
+ return { results: results };
33
+ }
34
+ };
35
+ }
36
+ exports.getStoreProductCategories = getStoreProductCategories;
37
+ function mapCategories(results, arr) {
38
+ var _a;
39
+ for (let result of results) {
40
+ if (((_a = result.children_data) === null || _a === void 0 ? void 0 : _a.length) > 0) {
41
+ mapCategories(result.children_data, arr);
42
+ }
43
+ arr.push(result);
44
+ }
45
+ return arr;
46
+ }
47
+ //# sourceMappingURL=get-store-product-categories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-store-product-categories.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/get-store-product-categories.ts"],"names":[],"mappings":";;;AAAA,SAAgB,yBAAyB;IACvC,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,kBAAkB;QACxB,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,UAAU,EAAE,GAAG,GAAG,IAAI,EAAE,CAAA;YAC9B,IAAI,EAAE,IAAI,GAAG,CAAC,EAAE,KAAK,GAAG,GAAG,EAAE,GAAG,UAAU,IAAI,EAAE,CAAA;YAEhD,MAAM,QAAQ,GAAQ,EAAE,CAAA;YACxB,MAAM,OAAO,GAAQ;gBACnB,QAAQ,EAAE,KAAK;gBACf,WAAW,EAAE,IAAI;aAClB,CAAA;YACD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAA;QAC9B,CAAC;QACD,SAAS,CAAC,GAAG;YACX,IAAI,OAAO,GAAG,GAAG,CAAC,KAAK,CAAA;YACvB,OAAO,GAAG,aAAa,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;YACpC,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;gBAC7B,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,MAAM,CAAA;gBAC9D,OAAO;oBACL,EAAE;oBACF,IAAI;oBACJ,MAAM,EAAE,SAAS;oBACjB,QAAQ,EAAE,SAAS;oBACrB,sCAAsC;iBACrC,CAAA;YACH,CAAC,CAAC,CAAA;YACF,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CAAA;YAChD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAA;QAC7B,CAAC;KACF,CAAA;AACH,CAAC;AAhCD,8DAgCC;AAED,SAAS,aAAa,CAAC,OAAO,EAAE,GAAG;;IACjC,KAAK,IAAI,MAAM,IAAI,OAAO,EAAE;QACxB,IAAI,CAAA,MAAA,MAAM,CAAC,aAAa,0CAAE,MAAM,IAAG,CAAC,EAAE;YACpC,aAAa,CAAC,MAAM,CAAC,aAAa,EAAE,GAAG,CAAC,CAAA;SACzC;QACD,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;KACnB;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
@@ -17,8 +17,10 @@ function getStoreProducts() {
17
17
  return { payload };
18
18
  },
19
19
  async normalize(res, { store }) {
20
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
20
21
  // return res.products
21
22
  let { items, total_count } = res;
23
+ let parentLinkList = (_a = items.map(e => { return { id: e.id, children: e.extension_attributes.configurable_product_links }; })) === null || _a === void 0 ? void 0 : _a.filter(e => e.children);
22
24
  let activeMarketplaceDistributors = [];
23
25
  if (store === null || store === void 0 ? void 0 : store.marketplaceDistributors) {
24
26
  activeMarketplaceDistributors = store.marketplaceDistributors.filter(marketplaceDistributor => marketplaceDistributor.status === 'ACTIVE');
@@ -26,16 +28,19 @@ function getStoreProducts() {
26
28
  let results = [];
27
29
  for (var i = 0; i < items.length; i++) {
28
30
  const product = items[i];
29
- const stockItems = await store_api_1.StoreAPI.getStoreStockItem(store, {
30
- sku: product.sku,
31
- distributors: activeMarketplaceDistributors
32
- });
33
31
  let totalProductQty = 0;
34
- stockItems.map(stockItem => {
35
- if (stockItem.sku === product.sku) {
36
- totalProductQty += stockItem.qty;
37
- }
38
- });
32
+ try {
33
+ const stockItems = await store_api_1.StoreAPI.getStoreStockItem(store, {
34
+ sku: product.sku,
35
+ distributors: activeMarketplaceDistributors
36
+ });
37
+ stockItems.map(stockItem => {
38
+ if (stockItem.sku === product.sku) {
39
+ totalProductQty += stockItem.qty;
40
+ }
41
+ });
42
+ }
43
+ catch (e) { }
39
44
  const productVariations = await store_api_1.StoreAPI.getStoreProductVariations(store, { sku: product.sku });
40
45
  const result = {
41
46
  itemId: product.id,
@@ -44,6 +49,12 @@ function getStoreProducts() {
44
49
  type: product.type_id,
45
50
  hasVariation: false,
46
51
  attributes: [],
52
+ images: ((_c = (_b = product === null || product === void 0 ? void 0 : product.custom_attributes) === null || _b === void 0 ? void 0 : _b.find(att => att.attribute_code == 'image')) === null || _c === void 0 ? void 0 : _c.value)
53
+ ? [
54
+ `${store.storeURL}pub/media/catalog/product${(_e = (_d = product === null || product === void 0 ? void 0 : product.custom_attributes) === null || _d === void 0 ? void 0 : _d.find(att => att.attribute_code == 'image')) === null || _e === void 0 ? void 0 : _e.value}`
55
+ ]
56
+ : [],
57
+ categoryId: (_f = product === null || product === void 0 ? void 0 : product.custom_attributes) === null || _f === void 0 ? void 0 : _f.find(att => att.attribute_code == 'category_ids').value[0],
47
58
  variations: productVariations.length > 0
48
59
  ? productVariations.map(variant => {
49
60
  const { stock_id: variantStockId, qty: variantQty } = variant.extension_attributes.stock_item;
@@ -72,13 +83,20 @@ function getStoreProducts() {
72
83
  sellPrice: product.price,
73
84
  marketplaceStatus: product.status,
74
85
  primaryUnit: 'lbs',
75
- primaryUnitValue: product.weight
86
+ primaryUnitValue: product.weight,
87
+ length: ((_h = (_g = product === null || product === void 0 ? void 0 : product.custom_attributes) === null || _g === void 0 ? void 0 : _g.find(att => att.attribute_code == 'ts_dimensions_length')) === null || _h === void 0 ? void 0 : _h.value) *
88
+ 25.4 || 0,
89
+ width: ((_k = (_j = product === null || product === void 0 ? void 0 : product.custom_attributes) === null || _j === void 0 ? void 0 : _j.find(att => att.attribute_code == 'ts_dimensions_width')) === null || _k === void 0 ? void 0 : _k.value) *
90
+ 25.4 || 0,
91
+ height: ((_m = (_l = product === null || product === void 0 ? void 0 : product.custom_attributes) === null || _l === void 0 ? void 0 : _l.find(att => att.attribute_code == 'ts_dimensions_height')) === null || _m === void 0 ? void 0 : _m.value) *
92
+ 25.4 || 0,
93
+ weight: product.weight * 453.59237 || 0
76
94
  }
77
95
  ]
78
96
  };
79
97
  results.push(Object.assign({}, result));
80
98
  }
81
- return { results, total: total_count };
99
+ return { results, total: total_count, parentLinkList };
82
100
  }
83
101
  };
84
102
  }
@@ -1 +1 @@
1
- {"version":3,"file":"get-store-products.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/get-store-products.ts"],"names":[],"mappings":";AAAA,2GAA2G;;;AAE3G,+CAA0C;AAE1C,SAAgB,gBAAgB;IAC9B,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,WAAW;QACjB,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,UAAU,EAAE,GAAG,GAAG,IAAI,EAAE,CAAA;YAC9B,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,UAAU,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAA;YAE3D,IAAI,OAAO,GAAQ;gBACjB,WAAW,EAAE,IAAI,GAAG,CAAC;gBACrB,QAAQ,EAAE,KAAK;aAChB,CAAA;YAED,OAAO,EAAE,OAAO,EAAE,CAAA;QACpB,CAAC;QACD,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE;YAC5B,sBAAsB;YACtB,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,GAAG,CAAA;YAEhC,IAAI,6BAA6B,GAAU,EAAE,CA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CAAC,EAAE;4BAC9B,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,UAAU,CAAA;4BAE7F,OAAO;gCACL,WAAW,EAAE,OAAO,CAAC,EAAE;gCACvB,YAAY,EAAE,OAAO,CAAC,GAAG;gCACzB,UAAU,EAAE,OAAO,CAAC,GAAG;gCACvB,IAAI,EAAE,OAAO,CAAC,IAAI;gCAClB,GAAG,EAAE,UAAU;gCACf,eAAe,EAAE,cAAc;gCAC/B,SAAS,EAAE,OAAO,CAAC,KAAK;gCACxB,SAAS,EAAE,OAAO,CAAC,KAAK;gCACxB,iBAAiB,EAAE,OAAO,CAAC,MAAM;gCACjC,WAAW,EAAE,KAAK;gCAClB,gBAAgB,EAAE,OAAO,CAAC,MAAM;6BACjC,CAAA;wBACH,CAAC,CAAC;wBACJ,CAAC,CAAC;4BACE;gCACE,WAAW,EAAE,OAAO,CAAC,EAAE;gCACvB,YAAY,EAAE,OAAO,CAAC,GAAG;gCACzB,UAAU,EAAE,OAAO,CAAC,GAAG;gCACvB,IAAI,EAAE,OAAO,CAAC,IAAI;gCAClB,GAAG,EAAE,eAAe;gCACpB,SAAS,EAAE,OAAO,CAAC,KAAK;gCACxB,SAAS,EAAE,OAAO,CAAC,KAAK;gCACxB,iBAAiB,EAAE,OAAO,CAAC,MAAM;gCACjC,WAAW,EAAE,KAAK;gCAClB,gBAAgB,EAAE,OAAO,CAAC,MAAM;6BACjC;yBACF;iBACR,CAAA;gBAED,OAAO,CAAC,IAAI,mBAAM,MAAM,EAAG,CAAA;aAC5B;YAED,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,CAAA;QACxC,CAAC;KACF,CAAA;AACH,CAAC;AA3FD,4CA2FC"}
1
+ {"version":3,"file":"get-store-products.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/get-store-products.ts"],"names":[],"mappings":";AAAA,2GAA2G;;;AAE3G,+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;gCAChC,MAAM,EACJ,CAAA,MAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,iBAAiB,0CAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,cAAc,IAAI,sBAAsB,CAAC,0CAAE,KAAK;oCAC5F,IAAI,IAAI,CAAC;gCACX,KAAK,EACH,CAAA,MAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,iBAAiB,0CAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,cAAc,IAAI,qBAAqB,CAAC,0CAAE,KAAK;oCAC3F,IAAI,IAAI,CAAC;gCACX,MAAM,EACJ,CAAA,MAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,iBAAiB,0CAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,cAAc,IAAI,sBAAsB,CAAC,0CAAE,KAAK;oCAC5F,IAAI,IAAI,CAAC;gCACX,MAAM,EAAE,OAAO,CAAC,MAAM,GAAG,SAAS,IAAI,CAAC;6BACxC;yBACF;iBACR,CAAA;gBAED,OAAO,CAAC,IAAI,mBAAM,MAAM,EAAG,CAAA;aAC5B;YAED,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,CAAA;QACxD,CAAC;KACF,CAAA;AACH,CAAC;AAnHD,4CAmHC"}
@@ -19,7 +19,7 @@ function getStoreStockItem() {
19
19
  ]
20
20
  }
21
21
  ];
22
- if (distributors) {
22
+ if (distributors.length > 0) {
23
23
  const distributorsArr = distributors.map(distributor => distributor.name);
24
24
  filterGroups.push({
25
25
  filters: [
@@ -1 +1 @@
1
- {"version":3,"file":"get-store-stock-item.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/get-store-stock-item.ts"],"names":[],"mappings":";AAAA,iIAAiI;;;AAEjI,SAAgB,iBAAiB;IAC/B,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EA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ACf,CAAC;KACF,CAAA;AACH,CAAC;AA/DD,8CA+DC"}
1
+ {"version":3,"file":"get-store-stock-item.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/get-store-stock-item.ts"],"names":[],"mappings":";AAAA,iIAAiI;;;AAEjI,SAAgB,iBAAiB;IAC/B,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,yBAAyB;QAC/B,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,GAAG,CAAA;YAEjC,IAAI,YAAY,GAAQ;gBACtB;oBACE,OAAO,EAAE;wBACP;4BACE,KAAK,EAAE,KAAK;4BACZ,KAAK,EAAE,GAAG;4BACV,cAAc,EAAE,IAAI;yBACrB;qBACF;iBACF;aACF,CAAA;YAED,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC3B,MAAM,eAAe,GAAG,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;gBAEzE,YAAY,CAAC,IAAI,CAAC;oBAChB,OAAO,EAAE;wBACP;4BACE,KAAK,EAAE,aAAa;4BACpB,KAAK,EAAE,eAAe,CAAC,QAAQ,EAAE;4BACjC,cAAc,EAAE,IAAI;yBACrB;qBACF;iBACF,CAAC,CAAA;aACH;YAED,IAAI,OAAO,GAAQ;gBACjB,aAAa,EAAE,YAAY;aAC5B,CAAA;YACD,OAAO,EAAE,OAAO,EAAE,CAAA;QACpB,CAAC;QACD,SAAS,CAAC,GAAG;YACX,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,CAAA;YACrB,IAAI,MAAM,GAAU;gBAClB;oBACE,GAAG,EAAE,EAAE;oBACP,UAAU,EAAE,EAAE;oBACd,GAAG,EAAE,CAAC;oBACN,MAAM,EAAE,EAAE;iBACX;aACF,CAAA;YAED,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;gBACpB,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;oBACxB,OAAO;wBACL,GAAG,EAAE,IAAI,CAAC,GAAG;wBACb,UAAU,EAAE,IAAI,CAAC,WAAW;wBAC5B,GAAG,EAAE,IAAI,CAAC,QAAQ;wBAClB,MAAM,EAAE,IAAI,CAAC,MAAM;qBACpB,CAAA;gBACH,CAAC,CAAC,CAAA;aACH;YAED,OAAO,MAAM,CAAA;QACf,CAAC;KACF,CAAA;AACH,CAAC;AA/DD,8CA+DC"}
@@ -21,4 +21,9 @@ __exportStar(require("./create-order-refund"), exports);
21
21
  __exportStar(require("./create-order-ship"), exports);
22
22
  __exportStar(require("./update-store-product-stock"), exports);
23
23
  __exportStar(require("./update-store-product-variation-stock"), exports);
24
+ __exportStar(require("./get-store-product-categories"), exports);
25
+ __exportStar(require("./update-order-status"), exports);
26
+ __exportStar(require("./get-store-order"), exports);
27
+ __exportStar(require("./update-store-product-price"), exports);
28
+ __exportStar(require("./update-store-product-variation-price"), exports);
24
29
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAsB;AACtB,sDAAmC;AACnC,uDAAoC;AACpC,iEAA8C;AAC9C,qDAAkC;AAClC,yDAAsC;AACtC,yDAAsC;AACtC,wDAAqC;AACrC,sDAAmC;AACnC,+DAA4C;AAC5C,yEAAsD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAsB;AACtB,sDAAmC;AACnC,uDAAoC;AACpC,iEAA8C;AAC9C,qDAAkC;AAClC,yDAAsC;AACtC,yDAAsC;AACtC,wDAAqC;AACrC,sDAAmC;AACnC,+DAA4C;AAC5C,yEAAsD;AACtD,iEAA8C;AAC9C,wDAAqC;AACrC,oDAAiC;AACjC,+DAA4C;AAC5C,yEAAsD"}
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateOrderStatus = void 0;
4
+ function updateOrderStatus() {
5
+ return {
6
+ method: 'post',
7
+ path: '/{subpath}',
8
+ async denormalize(req, { store }) {
9
+ let { orderId, status, trackingNo, carrier, orderItems } = req;
10
+ let pr;
11
+ if (status == 'SHIPPED' || status == 'READY_TO_SHIP' || status == 'PROCESSING' || status == 'PACKED') {
12
+ pr = {
13
+ resource: {
14
+ subpath: `order/${orderId}/ship`
15
+ },
16
+ payload: {
17
+ items: unmapOrderItems(orderItems),
18
+ tracks: [
19
+ {
20
+ carrier_code: carrier,
21
+ track_number: trackingNo,
22
+ title: carrier
23
+ }
24
+ ],
25
+ arguments: {
26
+ extension_attributes: {
27
+ source_code: 'default'
28
+ }
29
+ }
30
+ }
31
+ };
32
+ }
33
+ else if (status == 'DELIVERED' || status == 'CLOSED') {
34
+ pr = {
35
+ resource: {
36
+ subpath: `order/${orderId}/invoice`
37
+ }
38
+ };
39
+ }
40
+ else if (status == 'REFUND_COMPLETE' || status == 'RETURN_COMPLETE') {
41
+ pr = {
42
+ resource: {
43
+ subpath: `order/${orderId}/refund`
44
+ }
45
+ };
46
+ }
47
+ else if (status == 'CANCELLED') {
48
+ pr = {
49
+ resource: {
50
+ subpath: `orders/${orderId}/cancel`
51
+ }
52
+ };
53
+ }
54
+ return pr;
55
+ },
56
+ normalize(res) {
57
+ return res;
58
+ }
59
+ };
60
+ }
61
+ exports.updateOrderStatus = updateOrderStatus;
62
+ function unmapOrderItems(orderItems) {
63
+ let itemsList = [];
64
+ let res = orderItems.map(e => {
65
+ return e.split('-')[0];
66
+ });
67
+ for (let item of res) {
68
+ let count = 0;
69
+ res.forEach(element => {
70
+ if (element === item) {
71
+ count += 1;
72
+ }
73
+ });
74
+ itemsList.push({
75
+ order_item_id: item,
76
+ qty: count
77
+ });
78
+ }
79
+ itemsList = itemsList.filter((value, index, self) => index === self.findIndex(t => t.order_item_id === value.order_item_id));
80
+ return itemsList;
81
+ }
82
+ //# sourceMappingURL=update-order-status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-order-status.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/update-order-status.ts"],"names":[],"mappings":";;;AAEA,SAAgB,iBAAiB;IAC/B,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,YAAY;QAClB,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE;YAC9B,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,GAAG,CAAA;YAC9D,IAAI,EAAO,CAAA;YACX,IAAI,MAAM,IAAI,SAAS,IAAI,MAAM,IAAI,eAAe,IAAI,MAAM,IAAI,YAAY,IAAI,MAAM,IAAI,QAAQ,EAAE;gBACpG,EAAE,GAAG;oBACH,QAAQ,EAAE;wBACR,OAAO,EAAE,SAAS,OAAO,OAAO;qBACjC;oBACD,OAAO,EAAE;wBACP,KAAK,EAAE,eAAe,CAAC,UAAU,CAAC;wBAClC,MAAM,EAAE;4BACN;gCACE,YAAY,EAAE,OAAO;gCACrB,YAAY,EAAE,UAAU;gCACxB,KAAK,EAAE,OAAO;6BACf;yBACF;wBACD,SAAS,EAAE;4BACT,oBAAoB,EAAE;gCACpB,WAAW,EAAE,SAAS;6BACvB;yBACF;qBACF;iBACF,CAAA;aACF;iBAAM,IAAI,MAAM,IAAI,WAAW,IAAI,MAAM,IAAI,QAAQ,EAAE;gBACtD,EAAE,GAAG;oBACH,QAAQ,EAAE;wBACR,OAAO,EAAE,SAAS,OAAO,UAAU;qBACpC;iBACF,CAAA;aACF;iBAAM,IAAI,MAAM,IAAI,iBAAiB,IAAI,MAAM,IAAI,iBAAiB,EAAE;gBACrE,EAAE,GAAG;oBACH,QAAQ,EAAE;wBACR,OAAO,EAAE,SAAS,OAAO,SAAS;qBACnC;iBACF,CAAA;aACF;iBAAM,IAAI,MAAM,IAAI,WAAW,EAAE;gBAChC,EAAE,GAAG;oBACH,QAAQ,EAAE;wBACR,OAAO,EAAE,UAAU,OAAO,SAAS;qBACpC;iBACF,CAAA;aACF;YACD,OAAO,EAAE,CAAA;QACX,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AArDD,8CAqDC;AAED,SAAS,eAAe,CAAC,UAAU;IACjC,IAAI,SAAS,GAAG,EAAE,CAAA;IAClB,IAAI,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;QAC3B,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;IACxB,CAAC,CAAC,CAAA;IAEF,KAAK,IAAI,IAAI,IAAI,GAAG,EAAE;QACpB,IAAI,KAAK,GAAG,CAAC,CAAA;QAEb,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YACpB,IAAI,OAAO,KAAK,IAAI,EAAE;gBACpB,KAAK,IAAI,CAAC,CAAA;aACX;QACH,CAAC,CAAC,CAAA;QAEF,SAAS,CAAC,IAAI,CAAC;YACb,aAAa,EAAE,IAAI;YACnB,GAAG,EAAE,KAAK;SACX,CAAC,CAAA;KACH;IAED,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,KAAK,KAAK,CAAC,aAAa,CAAC,CAAC,CAAA;IAC5H,OAAO,SAAS,CAAA;AAClB,CAAC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateStoreProductPrice = void 0;
4
+ function updateStoreProductPrice() {
5
+ return {
6
+ path: '/products/base-prices',
7
+ method: 'post',
8
+ denormalize(req) {
9
+ let { sellPrice, variationSku } = req;
10
+ return {
11
+ payload: {
12
+ prices: [
13
+ {
14
+ price: sellPrice,
15
+ sku: variationSku,
16
+ store_id: 0
17
+ }
18
+ ]
19
+ }
20
+ };
21
+ },
22
+ normalize(res) {
23
+ return res;
24
+ }
25
+ };
26
+ }
27
+ exports.updateStoreProductPrice = updateStoreProductPrice;
28
+ //# sourceMappingURL=update-store-product-price.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-store-product-price.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/update-store-product-price.ts"],"names":[],"mappings":";;;AAAA,SAAgB,uBAAuB;IACrC,OAAO;QACL,IAAI,EAAE,uBAAuB;QAC7B,MAAM,EAAE,MAAM;QACd,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,GAAG,CAAA;YAErC,OAAO;gBACL,OAAO,EAAE;oBACP,MAAM,EAAE;wBACN;4BACE,KAAK,EAAE,SAAS;4BAChB,GAAG,EAAE,YAAY;4BACjB,QAAQ,EAAE,CAAC;yBACZ;qBACF;iBACF;aACF,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAvBD,0DAuBC"}
@@ -8,7 +8,7 @@ function updateStoreProductStock() {
8
8
  method: 'post',
9
9
  path: '/inventory/source-items',
10
10
  denormalize(req) {
11
- const { variationSku, qty, distributors } = req[0];
11
+ const { variationSku, qty, distributors } = (Array.isArray(req) ? req[0] : req) || {};
12
12
  let sourceItems = [];
13
13
  if (distributors.length > 0) {
14
14
  distributors.map(distributor => {
@@ -1 +1 @@
1
- {"version":3,"file":"update-store-product-stock.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/update-store-product-stock.ts"],"names":[],"mappings":";AAAA,uHAAuH;AACvH,6BAA6B;;;AAE7B,SAAgB,uBAAuB;IACrC,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,yBAAyB;QAC/B,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAA;YAElD,IAAI,WAAW,GAAU,EAAE,CAAA;YAE3B,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC3B,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;oBAC7B,WAAW,CAAC,IAAI,CAAC;wBACf,GAAG,EAAE,YAAY;wBACjB,WAAW,EAAE,WAAW,CAAC,IAAI;wBAC7B,QAAQ,EAAE,GAAG;wBACb,MAAM,EAAE,CAAC;qBACV,CAAC,CAAA;gBACJ,CAAC,CAAC,CAAA;aACH;iBAAM;gBACL,WAAW,GAAG;oBACZ;wBACE,GAAG,EAAE,YAAY;wBACjB,WAAW,EAAE,SAAS;wBACtB,QAAQ,EAAE,GAAG;wBACb,MAAM,EAAE,CAAC;qBACV;iBACF,CAAA;aACF;YAED,IAAI,OAAO,GAAQ;gBACjB,WAAW;aACZ,CAAA;YACD,OAAO,EAAE,OAAO,EAAE,CAAA;QACpB,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAtCD,0DAsCC"}
1
+ {"version":3,"file":"update-store-product-stock.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/update-store-product-stock.ts"],"names":[],"mappings":";AAAA,uHAAuH;AACvH,6BAA6B;;;AAE7B,SAAgB,uBAAuB;IACrC,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,yBAAyB;QAC/B,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,YAAY,EAAE,GAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;YAEtF,IAAI,WAAW,GAAU,EAAE,CAAA;YAE3B,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC3B,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;oBAC7B,WAAW,CAAC,IAAI,CAAC;wBACf,GAAG,EAAE,YAAY;wBACjB,WAAW,EAAE,WAAW,CAAC,IAAI;wBAC7B,QAAQ,EAAE,GAAG;wBACb,MAAM,EAAE,CAAC;qBACV,CAAC,CAAA;gBACJ,CAAC,CAAC,CAAA;aACH;iBAAM;gBACL,WAAW,GAAG;oBACZ;wBACE,GAAG,EAAE,YAAY;wBACjB,WAAW,EAAE,SAAS;wBACtB,QAAQ,EAAE,GAAG;wBACb,MAAM,EAAE,CAAC;qBACV;iBACF,CAAA;aACF;YAED,IAAI,OAAO,GAAQ;gBACjB,WAAW;aACZ,CAAA;YACD,OAAO,EAAE,OAAO,EAAE,CAAA;QACpB,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAtCD,0DAsCC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateStoreProductVariationPrice = void 0;
4
+ function updateStoreProductVariationPrice() {
5
+ return {
6
+ path: '/products/base-prices',
7
+ method: 'post',
8
+ denormalize(req) {
9
+ let { sellPrice, variationSku } = req;
10
+ return {
11
+ payload: {
12
+ prices: [
13
+ {
14
+ price: sellPrice,
15
+ sku: variationSku,
16
+ store_id: 0
17
+ }
18
+ ]
19
+ }
20
+ };
21
+ },
22
+ normalize(res) {
23
+ return res;
24
+ }
25
+ };
26
+ }
27
+ exports.updateStoreProductVariationPrice = updateStoreProductVariationPrice;
28
+ //# sourceMappingURL=update-store-product-variation-price.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-store-product-variation-price.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/update-store-product-variation-price.ts"],"names":[],"mappings":";;;AAAA,SAAgB,gCAAgC;IAC9C,OAAO;QACL,IAAI,EAAE,uBAAuB;QAC7B,MAAM,EAAE,MAAM;QACd,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,GAAG,CAAA;YAErC,OAAO;gBACL,OAAO,EAAE;oBACP,MAAM,EAAE;wBACN;4BACE,KAAK,EAAE,SAAS;4BAChB,GAAG,EAAE,YAAY;4BACjB,QAAQ,EAAE,CAAC;yBACZ;qBACF;iBACF;aACF,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAvBD,4EAuBC"}
@@ -8,7 +8,7 @@ function updateStoreProductVariationStock() {
8
8
  method: 'post',
9
9
  path: '/inventory/source-items',
10
10
  denormalize(req) {
11
- const { variationSku, qty, distributors } = req[0];
11
+ const { variationSku, qty, distributors } = (Array.isArray(req) ? req[0] : req) || {};
12
12
  let sourceItems = [];
13
13
  if (distributors.length > 0) {
14
14
  distributors.map(distributor => {
@@ -1 +1 @@
1
- {"version":3,"file":"update-store-product-variation-stock.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/update-store-product-variation-stock.ts"],"names":[],"mappings":";AAAA,uHAAuH;AACvH,6BAA6B;;;AAE7B,SAAgB,gCAAgC;IAC9C,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,yBAAyB;QAC/B,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAA;YAElD,IAAI,WAAW,GAAU,EAAE,CAAA;YAE3B,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC3B,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;oBAC7B,WAAW,CAAC,IAAI,CAAC;wBACf,GAAG,EAAE,YAAY;wBACjB,WAAW,EAAE,WAAW,CAAC,IAAI;wBAC7B,QAAQ,EAAE,GAAG;wBACb,MAAM,EAAE,CAAC;qBACV,CAAC,CAAA;gBACJ,CAAC,CAAC,CAAA;aACH;iBAAM;gBACL,WAAW,GAAG;oBACZ;wBACE,GAAG,EAAE,YAAY;wBACjB,WAAW,EAAE,SAAS;wBACtB,QAAQ,EAAE,GAAG;wBACb,MAAM,EAAE,CAAC;qBACV;iBACF,CAAA;aACF;YAED,IAAI,OAAO,GAAQ;gBACjB,WAAW;aACZ,CAAA;YACD,OAAO,EAAE,OAAO,EAAE,CAAA;QACpB,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAtCD,4EAsCC"}
1
+ {"version":3,"file":"update-store-product-variation-stock.js","sourceRoot":"","sources":["../../../../server/controllers/magento/apis/update-store-product-variation-stock.ts"],"names":[],"mappings":";AAAA,uHAAuH;AACvH,6BAA6B;;;AAE7B,SAAgB,gCAAgC;IAC9C,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,yBAAyB;QAC/B,WAAW,CAAC,GAAG;YACb,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;YAErF,IAAI,WAAW,GAAU,EAAE,CAAA;YAE3B,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC3B,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;oBAC7B,WAAW,CAAC,IAAI,CAAC;wBACf,GAAG,EAAE,YAAY;wBACjB,WAAW,EAAE,WAAW,CAAC,IAAI;wBAC7B,QAAQ,EAAE,GAAG;wBACb,MAAM,EAAE,CAAC;qBACV,CAAC,CAAA;gBACJ,CAAC,CAAC,CAAA;aACH;iBAAM;gBACL,WAAW,GAAG;oBACZ;wBACE,GAAG,EAAE,YAAY;wBACjB,WAAW,EAAE,SAAS;wBACtB,QAAQ,EAAE,GAAG;wBACb,MAAM,EAAE,CAAC;qBACV;iBACF,CAAA;aACF;YAED,IAAI,OAAO,GAAQ;gBACjB,WAAW;aACZ,CAAA;YACD,OAAO,EAAE,OAAO,EAAE,CAAA;QACpB,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAtCD,4EAsCC"}
@@ -4,6 +4,22 @@
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.updateOrderStatus = void 0;
6
6
  const store_api_1 = require("../../store-api");
7
+ const ORDER_STATUS = {
8
+ PAYMENT_PENDING: 'pending',
9
+ PROCESSING: 'processing',
10
+ PACKED: 'processing',
11
+ READY_TO_SHIP: 'processing',
12
+ SHIPPED: 'processing',
13
+ CONFIRMED: 'processing',
14
+ DELIVERED: 'completed',
15
+ CLOSED: 'completed',
16
+ CANCELLED: 'cancelled',
17
+ REFUND_COMPLETE: 'refunded',
18
+ RETURN_COMPLETE: 'refunded',
19
+ REVERSE_SHIPMENT_FAILED: 'failed',
20
+ SHIPMENT_LOST_OR_DAMAGED: 'failed',
21
+ PAYMENT_PENDING_TIMEOUT: 'failed'
22
+ };
7
23
  function updateOrderStatus(req) {
8
24
  return {
9
25
  method: 'put',
@@ -11,21 +27,7 @@ function updateOrderStatus(req) {
11
27
  async denormalize(req, { store }) {
12
28
  var { status, orderId } = req || {};
13
29
  const order = await store_api_1.StoreAPI.getStoreOrder(store, { orderId });
14
- let orderStatus = status;
15
- if (orderStatus == 'PACKED') {
16
- if (order.status == 'pending') {
17
- orderStatus = 'on-hold';
18
- }
19
- else {
20
- orderStatus = order.status;
21
- }
22
- }
23
- if (orderStatus == 'READY_TO_SHIP') {
24
- orderStatus = 'completed';
25
- }
26
- if (orderStatus == 'CANCELLED') {
27
- orderStatus = 'cancelled';
28
- }
30
+ let orderStatus = ORDER_STATUS[`${status}`] || order.status;
29
31
  return { resource: { orderId: orderId }, payload: { status: orderStatus } };
30
32
  },
31
33
  normalize(res) {
@@ -1 +1 @@
1
- {"version":3,"file":"update-order-status.js","sourceRoot":"","sources":["../../../../server/controllers/woocommerce/apis/update-order-status.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,gCAAgC;;;AAEhC,+CAA0C;AAE1C,SAAgB,iBAAiB,CAAC,GAAG;IACnC,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,mBAAmB;QACzB,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE;YAC9B,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,IAAI,EAAE,CAAA;YAEnC,MAAM,KAAK,GAAG,MAAM,oBAAQ,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,CAAA;YAE9D,IAAI,WAAW,GAAG,MAAM,CAAA;YACxB,IAAI,WAAW,IAAI,QAAQ,EAAE;gBAC3B,IAAI,KAAK,CAAC,MAAM,IAAI,SAAS,EAAE;oBAC7B,WAAW,GAAG,SAAS,CAAA;iBACxB;qBAAM;oBACL,WAAW,GAAG,KAAK,CAAC,MAAM,CAAA;iBAC3B;aACF;YACD,IAAI,WAAW,IAAI,eAAe,EAAE;gBAClC,WAAW,GAAG,WAAW,CAAA;aAC1B;YACD,IAAI,WAAW,IAAI,WAAW,EAAE;gBAC9B,WAAW,GAAG,WAAW,CAAA;aAC1B;YAED,OAAO,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,CAAA;QAC7E,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AA9BD,8CA8BC"}
1
+ {"version":3,"file":"update-order-status.js","sourceRoot":"","sources":["../../../../server/controllers/woocommerce/apis/update-order-status.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,gCAAgC;;;AAEhC,+CAA0C;AAE1C,MAAM,YAAY,GAAG;IACnB,eAAe,EAAE,SAAS;IAC1B,UAAU,EAAE,YAAY;IACxB,MAAM,EAAE,YAAY;IACpB,aAAa,EAAE,YAAY;IAC3B,OAAO,EAAE,YAAY;IACrB,SAAS,EAAE,YAAY;IACvB,SAAS,EAAE,WAAW;IACtB,MAAM,EAAE,WAAW;IACnB,SAAS,EAAE,WAAW;IACtB,eAAe,EAAE,UAAU;IAC3B,eAAe,EAAE,UAAU;IAC3B,uBAAuB,EAAE,QAAQ;IACjC,wBAAwB,EAAE,QAAQ;IAClC,uBAAuB,EAAE,QAAQ;CAClC,CAAA;AAED,SAAgB,iBAAiB,CAAC,GAAG;IACnC,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,mBAAmB;QACzB,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE;YAC9B,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,IAAI,EAAE,CAAA;YAEnC,MAAM,KAAK,GAAG,MAAM,oBAAQ,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,CAAA;YAE9D,IAAI,WAAW,GAAG,YAAY,CAAC,GAAG,MAAM,EAAE,CAAC,IAAI,KAAK,CAAC,MAAM,CAAA;YAE3D,OAAO,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,CAAA;QAC7E,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAjBD,8CAiBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/integration-marketplace",
3
- "version": "4.2.1",
3
+ "version": "4.2.5",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -52,5 +52,5 @@
52
52
  "nock": "^13.0.2",
53
53
  "should": "^13.2.3"
54
54
  },
55
- "gitHead": "1aeab216e97c010d738ed7e49302750f3534c462"
55
+ "gitHead": "e1447c2e0c5c1ad9375e84291f688b7ecdbeee40"
56
56
  }
@@ -0,0 +1,15 @@
1
+ export function getStoreOrder() {
2
+ return {
3
+ path: '/orders/{id}',
4
+ method: 'get',
5
+ denormalize(req) {
6
+ let { id } = req
7
+ return {
8
+ resource: { id }
9
+ }
10
+ },
11
+ normalize(res) {
12
+ return res
13
+ }
14
+ }
15
+ }
@@ -63,7 +63,7 @@ export function getStoreOrders() {
63
63
  let docRefNo = orderNo
64
64
 
65
65
  let orderItems = items.map(item => {
66
- var { item_id: name, product_id, qty_ordered: qty, price } = item
66
+ var { item_id: name, product_id, qty_ordered: qty, price, original_price, price, tax_amount, tax_invoiced } = item
67
67
 
68
68
  return {
69
69
  name,
@@ -71,7 +71,11 @@ export function getStoreOrders() {
71
71
  qty,
72
72
  paidPrice: price,
73
73
  orderNo,
74
- docRefNo
74
+ docRefNo,
75
+ total: price,
76
+ totalTax: tax_invoiced,
77
+ subtotal: original_price,
78
+ subtotalTax: tax_amount
75
79
  }
76
80
  })
77
81
 
@@ -110,17 +114,44 @@ export function getStoreOrders() {
110
114
  postCode: postcode,
111
115
  city,
112
116
  country: country_id === 'MY' ? 'Malaysia' : country_id,
113
- collectionCurrency: null,
117
+ collectionCurrency: order.order_currency_code,
114
118
  attentionTo: `${firstname} ${middlename} ${lastname}`
115
119
  }
116
120
 
117
121
  result.orderShipping = orderShipping
122
+
123
+ // For SC mapping
124
+ result.shipping = {
125
+ address_1: street,
126
+ postcode: postcode,
127
+ country: country_id,
128
+ city,
129
+ first_name: firstname,
130
+ last_name: lastname,
131
+ phone: telephone,
132
+ email: order.customer_email
133
+ }
134
+ let billingAddress = order?.billing_address
135
+ result.billing = {
136
+ address_1: billingAddress.street,
137
+ postcode: billingAddress.postcode,
138
+ country: billingAddress.country_id,
139
+ city: billingAddress.city,
140
+ first_name: billingAddress.firstname,
141
+ last_name: billingAddress.lastname,
142
+ phone: billingAddress.telephone,
143
+ email: billingAddress.email
144
+ }
145
+ result.firstName = order.customer_firstname
146
+ result.lastName = order.customer_lastname
118
147
  }
119
148
 
120
149
  return result
121
150
  })
122
151
 
123
- return { results }
152
+ let more = res.search_criteria.page_size * res.search_criteria.current_page < res.total_count || false
153
+
154
+ return { results, more }
124
155
  }
125
156
  }
126
157
  }
@@ -0,0 +1,43 @@
1
+ export function getStoreProductCategories() {
2
+ return {
3
+ method: 'get',
4
+ path: '/categories/list',
5
+ denormalize(req) {
6
+ var { pagination } = req || {}
7
+ var { page = 0, limit = 100 } = pagination || {}
8
+
9
+ const resource: any = {}
10
+ const payload: any = {
11
+ pageSize: limit,
12
+ currentPage: page
13
+ }
14
+ return { resource, payload }
15
+ },
16
+ normalize(res) {
17
+ let results = res.items
18
+ results = mapCategories(results, [])
19
+ results = results.map(result => {
20
+ let { id, name, parent_id, is_active, children_data } = result
21
+ return {
22
+ id,
23
+ name,
24
+ parent: parent_id,
25
+ isActive: is_active
26
+ // childrenCategories: children_data
27
+ }
28
+ })
29
+ results = results.filter(cat => cat.parent != 0)
30
+ return { results: results }
31
+ }
32
+ }
33
+ }
34
+
35
+ function mapCategories(results, arr) {
36
+ for (let result of results) {
37
+ if (result.children_data?.length > 0) {
38
+ mapCategories(result.children_data, arr)
39
+ }
40
+ arr.push(result)
41
+ }
42
+ return arr
43
+ }
@@ -21,6 +21,8 @@ export function getStoreProducts() {
21
21
  // return res.products
22
22
  let { items, total_count } = res
23
23
 
24
+ let parentLinkList = items.map(e => {return {id: e.id, children: e.extension_attributes.configurable_product_links}})?.filter(e => e.children)
25
+
24
26
  let activeMarketplaceDistributors: any[] = []
25
27
  if (store?.marketplaceDistributors) {
26
28
  activeMarketplaceDistributors = store.marketplaceDistributors.filter(
@@ -32,17 +34,21 @@ export function getStoreProducts() {
32
34
 
33
35
  for (var i = 0; i < items.length; i++) {
34
36
  const product: any = items[i]
35
- const stockItems: any[] = await StoreAPI.getStoreStockItem(store, {
36
- sku: product.sku,
37
- distributors: activeMarketplaceDistributors
38
- })
39
37
 
40
38
  let totalProductQty: number = 0
41
- stockItems.map(stockItem => {
42
- if (stockItem.sku === product.sku) {
43
- totalProductQty += stockItem.qty
44
- }
45
- })
39
+
40
+ try {
41
+ const stockItems: any[] = await StoreAPI.getStoreStockItem(store, {
42
+ sku: product.sku,
43
+ distributors: activeMarketplaceDistributors
44
+ })
45
+
46
+ stockItems.map(stockItem => {
47
+ if (stockItem.sku === product.sku) {
48
+ totalProductQty += stockItem.qty
49
+ }
50
+ })
51
+ } catch (e) {}
46
52
  const productVariations: any[] = await StoreAPI.getStoreProductVariations(store, { sku: product.sku })
47
53
 
48
54
  const result = {
@@ -52,6 +58,14 @@ export function getStoreProducts() {
52
58
  type: product.type_id,
53
59
  hasVariation: false,
54
60
  attributes: [],
61
+ images: product?.custom_attributes?.find(att => att.attribute_code == 'image')?.value
62
+ ? [
63
+ `${store.storeURL}pub/media/catalog/product${
64
+ product?.custom_attributes?.find(att => att.attribute_code == 'image')?.value
65
+ }`
66
+ ]
67
+ : [],
68
+ categoryId: product?.custom_attributes?.find(att => att.attribute_code == 'category_ids').value[0],
55
69
  variations:
56
70
  productVariations.length > 0
57
71
  ? productVariations.map(variant => {
@@ -82,7 +96,17 @@ export function getStoreProducts() {
82
96
  sellPrice: product.price,
83
97
  marketplaceStatus: product.status,
84
98
  primaryUnit: 'lbs',
85
- primaryUnitValue: product.weight
99
+ primaryUnitValue: product.weight,
100
+ length:
101
+ product?.custom_attributes?.find(att => att.attribute_code == 'ts_dimensions_length')?.value *
102
+ 25.4 || 0,
103
+ width:
104
+ product?.custom_attributes?.find(att => att.attribute_code == 'ts_dimensions_width')?.value *
105
+ 25.4 || 0,
106
+ height:
107
+ product?.custom_attributes?.find(att => att.attribute_code == 'ts_dimensions_height')?.value *
108
+ 25.4 || 0,
109
+ weight: product.weight * 453.59237 || 0
86
110
  }
87
111
  ]
88
112
  }
@@ -90,7 +114,7 @@ export function getStoreProducts() {
90
114
  results.push({ ...result })
91
115
  }
92
116
 
93
- return { results, total: total_count }
117
+ return { results, total: total_count, parentLinkList }
94
118
  }
95
119
  }
96
120
  }
@@ -19,7 +19,7 @@ export function getStoreStockItem() {
19
19
  }
20
20
  ]
21
21
 
22
- if (distributors) {
22
+ if (distributors.length > 0) {
23
23
  const distributorsArr = distributors.map(distributor => distributor.name)
24
24
 
25
25
  filterGroups.push({
@@ -9,3 +9,8 @@ export * from './create-order-refund'
9
9
  export * from './create-order-ship'
10
10
  export * from './update-store-product-stock'
11
11
  export * from './update-store-product-variation-stock'
12
+ export * from './get-store-product-categories'
13
+ export * from './update-order-status'
14
+ export * from './get-store-order'
15
+ export * from './update-store-product-price'
16
+ export * from './update-store-product-variation-price'
@@ -0,0 +1,81 @@
1
+ import { StoreAPI } from '../../store-api'
2
+
3
+ export function updateOrderStatus() {
4
+ return {
5
+ method: 'post',
6
+ path: '/{subpath}',
7
+ async denormalize(req, { store }) {
8
+ let { orderId, status, trackingNo, carrier, orderItems } = req
9
+ let pr: any
10
+ if (status == 'SHIPPED' || status == 'READY_TO_SHIP' || status == 'PROCESSING' || status == 'PACKED') {
11
+ pr = {
12
+ resource: {
13
+ subpath: `order/${orderId}/ship`
14
+ },
15
+ payload: {
16
+ items: unmapOrderItems(orderItems),
17
+ tracks: [
18
+ {
19
+ carrier_code: carrier,
20
+ track_number: trackingNo,
21
+ title: carrier
22
+ }
23
+ ],
24
+ arguments: {
25
+ extension_attributes: {
26
+ source_code: 'default'
27
+ }
28
+ }
29
+ }
30
+ }
31
+ } else if (status == 'DELIVERED' || status == 'CLOSED') {
32
+ pr = {
33
+ resource: {
34
+ subpath: `order/${orderId}/invoice`
35
+ }
36
+ }
37
+ } else if (status == 'REFUND_COMPLETE' || status == 'RETURN_COMPLETE') {
38
+ pr = {
39
+ resource: {
40
+ subpath: `order/${orderId}/refund`
41
+ }
42
+ }
43
+ } else if (status == 'CANCELLED') {
44
+ pr = {
45
+ resource: {
46
+ subpath: `orders/${orderId}/cancel`
47
+ }
48
+ }
49
+ }
50
+ return pr
51
+ },
52
+ normalize(res) {
53
+ return res
54
+ }
55
+ }
56
+ }
57
+
58
+ function unmapOrderItems(orderItems) {
59
+ let itemsList = []
60
+ let res = orderItems.map(e => {
61
+ return e.split('-')[0]
62
+ })
63
+
64
+ for (let item of res) {
65
+ let count = 0
66
+
67
+ res.forEach(element => {
68
+ if (element === item) {
69
+ count += 1
70
+ }
71
+ })
72
+
73
+ itemsList.push({
74
+ order_item_id: item,
75
+ qty: count
76
+ })
77
+ }
78
+
79
+ itemsList = itemsList.filter((value, index, self) => index === self.findIndex(t => t.order_item_id === value.order_item_id))
80
+ return itemsList
81
+ }
@@ -0,0 +1,24 @@
1
+ export function updateStoreProductPrice() {
2
+ return {
3
+ path: '/products/base-prices',
4
+ method: 'post',
5
+ denormalize(req) {
6
+ let { sellPrice, variationSku } = req
7
+
8
+ return {
9
+ payload: {
10
+ prices: [
11
+ {
12
+ price: sellPrice,
13
+ sku: variationSku,
14
+ store_id: 0
15
+ }
16
+ ]
17
+ }
18
+ }
19
+ },
20
+ normalize(res) {
21
+ return res
22
+ }
23
+ }
24
+ }
@@ -6,7 +6,7 @@ export function updateStoreProductStock() {
6
6
  method: 'post',
7
7
  path: '/inventory/source-items',
8
8
  denormalize(req) {
9
- const { variationSku, qty, distributors } = req[0]
9
+ const { variationSku, qty, distributors } = (Array.isArray(req) ? req[0] : req) || {}
10
10
 
11
11
  let sourceItems: any[] = []
12
12
 
@@ -0,0 +1,24 @@
1
+ export function updateStoreProductVariationPrice() {
2
+ return {
3
+ path: '/products/base-prices',
4
+ method: 'post',
5
+ denormalize(req) {
6
+ let { sellPrice, variationSku } = req
7
+
8
+ return {
9
+ payload: {
10
+ prices: [
11
+ {
12
+ price: sellPrice,
13
+ sku: variationSku,
14
+ store_id: 0
15
+ }
16
+ ]
17
+ }
18
+ }
19
+ },
20
+ normalize(res) {
21
+ return res
22
+ }
23
+ }
24
+ }
@@ -6,7 +6,7 @@ export function updateStoreProductVariationStock() {
6
6
  method: 'post',
7
7
  path: '/inventory/source-items',
8
8
  denormalize(req) {
9
- const { variationSku, qty, distributors } = req[0]
9
+ const { variationSku, qty, distributors } = (Array.isArray(req) ? req[0] : req) || {}
10
10
 
11
11
  let sourceItems: any[] = []
12
12
 
@@ -3,6 +3,23 @@
3
3
 
4
4
  import { StoreAPI } from '../../store-api'
5
5
 
6
+ const ORDER_STATUS = {
7
+ PAYMENT_PENDING: 'pending',
8
+ PROCESSING: 'processing',
9
+ PACKED: 'processing',
10
+ READY_TO_SHIP: 'processing',
11
+ SHIPPED: 'processing',
12
+ CONFIRMED: 'processing',
13
+ DELIVERED: 'completed',
14
+ CLOSED: 'completed',
15
+ CANCELLED: 'cancelled',
16
+ REFUND_COMPLETE: 'refunded',
17
+ RETURN_COMPLETE: 'refunded',
18
+ REVERSE_SHIPMENT_FAILED: 'failed',
19
+ SHIPMENT_LOST_OR_DAMAGED: 'failed',
20
+ PAYMENT_PENDING_TIMEOUT: 'failed'
21
+ }
22
+
6
23
  export function updateOrderStatus(req) {
7
24
  return {
8
25
  method: 'put',
@@ -12,20 +29,7 @@ export function updateOrderStatus(req) {
12
29
 
13
30
  const order = await StoreAPI.getStoreOrder(store, { orderId })
14
31
 
15
- let orderStatus = status
16
- if (orderStatus == 'PACKED') {
17
- if (order.status == 'pending') {
18
- orderStatus = 'on-hold'
19
- } else {
20
- orderStatus = order.status
21
- }
22
- }
23
- if (orderStatus == 'READY_TO_SHIP') {
24
- orderStatus = 'completed'
25
- }
26
- if (orderStatus == 'CANCELLED') {
27
- orderStatus = 'cancelled'
28
- }
32
+ let orderStatus = ORDER_STATUS[`${status}`] || order.status
29
33
 
30
34
  return { resource: { orderId: orderId }, payload: { status: orderStatus } }
31
35
  },