@things-factory/integration-sellercraft 5.0.0-alpha.36 → 5.0.0-alpha.39
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/dist-server/constants/order-status-mapping.js +21 -3
- package/dist-server/constants/order-status-mapping.js.map +1 -1
- package/dist-server/constants/platform.js +3 -1
- package/dist-server/constants/platform.js.map +1 -1
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-categories.js +3 -2
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-categories.js.map +1 -1
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order-package.js +5 -2
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order-package.js.map +1 -1
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.js +21 -14
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.js.map +1 -1
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.js +15 -11
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.js.map +1 -1
- package/dist-server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.js +8 -4
- package/dist-server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.js.map +1 -1
- package/dist-server/routers/sellercraft-router.js +195 -75
- package/dist-server/routers/sellercraft-router.js.map +1 -1
- package/dist-server/service/marketplace-channel/marketplace-channel-order-mutation.js +317 -103
- package/dist-server/service/marketplace-channel/marketplace-channel-order-mutation.js.map +1 -1
- package/dist-server/service/marketplace-channel/marketplace-channel-product-mutation.js +83 -25
- package/dist-server/service/marketplace-channel/marketplace-channel-product-mutation.js.map +1 -1
- package/dist-server/service/marketplace-channel/marketplace-channel.js +5 -0
- package/dist-server/service/marketplace-channel/marketplace-channel.js.map +1 -1
- package/package.json +15 -15
- package/server/constants/order-status-mapping.ts +21 -2
- package/server/constants/platform.ts +3 -1
- package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-categories.ts +4 -3
- package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-order-package.ts +6 -2
- package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-order.ts +22 -15
- package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.ts +26 -21
- package/server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.ts +8 -4
- package/server/routers/sellercraft-router.ts +199 -79
- package/server/service/marketplace-channel/marketplace-channel-order-mutation.ts +379 -149
- package/server/service/marketplace-channel/marketplace-channel-product-mutation.ts +83 -26
- package/server/service/marketplace-channel/marketplace-channel.ts +4 -0
@@ -15,15 +15,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.MarketplaceChannelProductMutation = void 0;
|
16
16
|
const type_graphql_1 = require("type-graphql");
|
17
17
|
const typeorm_1 = require("typeorm");
|
18
|
-
const marketplace_channel_1 = require("./marketplace-channel");
|
19
18
|
const env_1 = require("@things-factory/env");
|
20
19
|
const integration_marketplace_1 = require("@things-factory/integration-marketplace");
|
21
20
|
const sellercraft_channel_integration_api_1 = require("../../controllers/sellercraft-channel-integration-api");
|
21
|
+
const marketplace_channel_1 = require("./marketplace-channel");
|
22
22
|
let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation {
|
23
23
|
async syncAllMarketplaceChannelProducts(context) {
|
24
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
24
25
|
const sellercraftChannelIntegrationConfig = env_1.config.get('sellercraftChannelIntegrationConfig', {});
|
25
26
|
const { tokenCraftApiKey: apiKey, getShopsTokenCraftUrl } = sellercraftChannelIntegrationConfig;
|
26
|
-
const channels = await (0, typeorm_1.getRepository)(marketplace_channel_1.MarketplaceChannel).find();
|
27
|
+
const channels = await (0, typeorm_1.getRepository)(marketplace_channel_1.MarketplaceChannel).find({ where: { isActive: true } });
|
27
28
|
for (var i = 0; i < channels.length; i++) {
|
28
29
|
var channelsFullPath = getShopsTokenCraftUrl + '?channel_id=' + channels[i].channelId;
|
29
30
|
const channelResponse = await fetch(channelsFullPath, {
|
@@ -40,23 +41,46 @@ let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation
|
|
40
41
|
var shops = shopsResponse.shops;
|
41
42
|
for (var j = 0; j < shops.length; j++) {
|
42
43
|
var store = {
|
43
|
-
accessKey: shops[j].credential.consumer_key,
|
44
|
-
accessSecret: shops[j].credential.consumer_secret,
|
45
|
-
storeURL: shops[j].credential.store_url,
|
44
|
+
accessKey: ((_b = (_a = shops[j]) === null || _a === void 0 ? void 0 : _a.credential) === null || _b === void 0 ? void 0 : _b.consumer_key) || '',
|
45
|
+
accessSecret: ((_d = (_c = shops[j]) === null || _c === void 0 ? void 0 : _c.credential) === null || _d === void 0 ? void 0 : _d.consumer_secret) || '',
|
46
|
+
storeURL: ((_f = (_e = shops[j]) === null || _e === void 0 ? void 0 : _e.credential) === null || _f === void 0 ? void 0 : _f.store_url) || '',
|
46
47
|
platform: channels[i].name,
|
47
|
-
accessToken: shops[j].credential.access_token
|
48
|
+
accessToken: (_h = (_g = shops[j]) === null || _g === void 0 ? void 0 : _g.credential) === null || _h === void 0 ? void 0 : _h.access_token,
|
49
|
+
channelShopId: (_j = shops[j]) === null || _j === void 0 ? void 0 : _j.channel_shop_id
|
48
50
|
};
|
49
51
|
let countryCode = shops[j].country_code;
|
50
52
|
let channelCode = shops[j].org_prefix;
|
51
53
|
let organisationId = shops[j].account_id;
|
52
54
|
let channelShopId = shops[j].channel_shop_id;
|
53
55
|
var sellercraftStore = Object.assign(Object.assign({}, store), { platform: 'sellercraftChannelIntegration' });
|
54
|
-
const productResult =
|
55
|
-
|
56
|
-
let
|
56
|
+
const productResult = [];
|
57
|
+
let totalPages = 1;
|
58
|
+
let limit = 50;
|
59
|
+
let parentLinks = [];
|
60
|
+
for (let page = 0; page < totalPages; page++) {
|
61
|
+
const { results, total, parentLinkList } = await integration_marketplace_1.StoreAPI.getStoreProducts(store, {
|
62
|
+
pagination: { page, limit }
|
63
|
+
});
|
64
|
+
totalPages = Math.ceil(total / limit);
|
65
|
+
productResult.push(...results);
|
66
|
+
if (store.platform == 'magento')
|
67
|
+
parentLinks.push(...parentLinkList);
|
68
|
+
}
|
69
|
+
const categoryResult = [];
|
70
|
+
let totalPagesCategory = 1;
|
71
|
+
let limitCategory = 100;
|
72
|
+
for (let page = 0; page < totalPagesCategory; page++) {
|
73
|
+
const { results, total } = await integration_marketplace_1.StoreAPI.getStoreProductCategories(store, {
|
74
|
+
pagination: { page, limitCategory }
|
75
|
+
});
|
76
|
+
totalPagesCategory = Math.ceil(total / limitCategory);
|
77
|
+
categoryResult.push(...results);
|
78
|
+
}
|
79
|
+
let mappedProducts = productResult.map(item => {
|
80
|
+
var _a;
|
57
81
|
let { categoryId, itemId: productId, name, brand, isVerified, images, attributes, variations } = item;
|
58
82
|
variations = variations.map(variation => {
|
59
|
-
let { variationSku, variationId, name, isEnabled: isEnabled,
|
83
|
+
let { variationSku, variationId, name, isEnabled: isEnabled, isSellable: isSellable, attributes, stockLocked, qty: stockReported, costPrice: fullPrice, sellPrice: priceDiscounted, length, width, height, weight } = variation;
|
60
84
|
return {
|
61
85
|
variationSku,
|
62
86
|
variationId,
|
@@ -70,7 +94,7 @@ let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation
|
|
70
94
|
priceDiscounted,
|
71
95
|
inventoryProducts: [
|
72
96
|
{
|
73
|
-
qty:
|
97
|
+
qty: 1,
|
74
98
|
name: `${name} - ${variationSku}`,
|
75
99
|
sku: variationSku,
|
76
100
|
productVersions: [
|
@@ -80,7 +104,7 @@ let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation
|
|
80
104
|
packageWidthMM: width,
|
81
105
|
packageHeightMM: height,
|
82
106
|
packageWeightGram: weight,
|
83
|
-
qty:
|
107
|
+
qty: stockReported
|
84
108
|
}
|
85
109
|
]
|
86
110
|
}
|
@@ -98,7 +122,7 @@ let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation
|
|
98
122
|
channelCode: channels[i].channelCode,
|
99
123
|
channelCountry: shops[j].country_code,
|
100
124
|
categoryId,
|
101
|
-
productId,
|
125
|
+
productId: ((_a = parentLinks.find(e => e.children.includes(productId))) === null || _a === void 0 ? void 0 : _a.id) || productId,
|
102
126
|
name,
|
103
127
|
brand,
|
104
128
|
isVerified,
|
@@ -107,32 +131,66 @@ let MarketplaceChannelProductMutation = class MarketplaceChannelProductMutation
|
|
107
131
|
variations
|
108
132
|
};
|
109
133
|
});
|
110
|
-
let mappedCategories = categoryResult.
|
134
|
+
let mappedCategories = categoryResult.map(category => {
|
111
135
|
let { id: categoryId, name: categoryName, parent, isActive } = category;
|
112
136
|
return {
|
113
137
|
categoryId,
|
114
138
|
categoryName,
|
115
139
|
parent,
|
116
|
-
isLeaf: parent == 0 ? false : true,
|
117
140
|
isActive: isActive || true,
|
118
141
|
channelCode,
|
119
142
|
countryCode,
|
120
143
|
childrenCategories: []
|
121
144
|
};
|
122
145
|
});
|
123
|
-
|
124
|
-
|
125
|
-
|
146
|
+
if (store.platform == 'magento') {
|
147
|
+
let newList = [];
|
148
|
+
for (let np of mappedProducts) {
|
149
|
+
if (np.productId == np.variations[0].variationId) {
|
150
|
+
let vars = mappedProducts
|
151
|
+
.filter(e => e.productId == np.productId)
|
152
|
+
.map(e => {
|
153
|
+
return e.variations[0];
|
154
|
+
});
|
155
|
+
np.variations = vars;
|
156
|
+
if (np.variations.length > 1) {
|
157
|
+
np.variations = np.variations.filter(v => v.variationId != np.productId);
|
158
|
+
}
|
159
|
+
newList.push(np);
|
160
|
+
}
|
126
161
|
}
|
127
|
-
|
128
|
-
}
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
162
|
+
mappedProducts = newList;
|
163
|
+
}
|
164
|
+
try {
|
165
|
+
let filterList = [];
|
166
|
+
mappedCategories = mappedCategories.map(category => {
|
167
|
+
if (mappedCategories.filter(e => e.parent == category.categoryId).length > 0) {
|
168
|
+
category.childrenCategories = mappedCategories.filter(e => e.parent == category.categoryId);
|
169
|
+
filterList.push(...mappedCategories.filter(e => e.parent == category.categoryId));
|
170
|
+
}
|
171
|
+
return category;
|
172
|
+
});
|
173
|
+
mappedCategories = mappedCategories.map(mc => {
|
174
|
+
if (filterList.indexOf(mc) == -1) {
|
175
|
+
return mc;
|
176
|
+
}
|
177
|
+
}).filter(e => e);
|
178
|
+
await sellercraft_channel_integration_api_1.SellercraftChannelIntegrationAPI.ingestChannelCategories(sellercraftStore, {
|
179
|
+
categories: mappedCategories
|
180
|
+
});
|
181
|
+
}
|
182
|
+
catch (e) { }
|
183
|
+
try {
|
184
|
+
for (let k = 0, l = mappedProducts.length; k < l; k++) {
|
185
|
+
await sellercraft_channel_integration_api_1.SellercraftChannelIntegrationAPI.ingestChannelProduct(sellercraftStore, {
|
186
|
+
products: [mappedProducts[k]]
|
187
|
+
});
|
188
|
+
}
|
189
|
+
}
|
190
|
+
catch (e) { }
|
133
191
|
}
|
134
|
-
return true;
|
135
192
|
}
|
193
|
+
return true;
|
136
194
|
}
|
137
195
|
};
|
138
196
|
__decorate([
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"marketplace-channel-product-mutation.js","sourceRoot":"","sources":["../../../server/service/marketplace-channel/marketplace-channel-product-mutation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAsD;AACtD,qCAAuC;AAEvC
|
1
|
+
{"version":3,"file":"marketplace-channel-product-mutation.js","sourceRoot":"","sources":["../../../server/service/marketplace-channel/marketplace-channel-product-mutation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAsD;AACtD,qCAAuC;AAEvC,6CAA4C;AAC5C,qFAAkE;AAElE,+GAAwG;AACxG,+DAA0D;AAG1D,IAAa,iCAAiC,GAA9C,MAAa,iCAAiC;IAE5C,KAAK,CAAC,iCAAiC,CAAQ,OAAY;;QACzD,MAAM,mCAAmC,GAAG,YAAM,CAAC,GAAG,CAAC,qCAAqC,EAAE,EAAE,CAAC,CAAA;QACjG,MAAM,EAAE,gBAAg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
|
__metadata("design:type", String)
|
48
48
|
], MarketplaceChannel.prototype, "channelId", void 0);
|
49
|
+
__decorate([
|
50
|
+
(0, typeorm_1.Column)({ default: true }),
|
51
|
+
(0, type_graphql_1.Field)(),
|
52
|
+
__metadata("design:type", Boolean)
|
53
|
+
], MarketplaceChannel.prototype, "isActive", void 0);
|
49
54
|
__decorate([
|
50
55
|
(0, typeorm_1.CreateDateColumn)(),
|
51
56
|
(0, type_graphql_1.Field)({ nullable: true }),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"marketplace-channel.js","sourceRoot":"","sources":["../../../server/service/marketplace-channel/marketplace-channel.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,+CAAoD;AACpD,qCASgB;AAEhB,yDAAgD;AAChD,iDAA8C;AAK9C,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;
|
1
|
+
{"version":3,"file":"marketplace-channel.js","sourceRoot":"","sources":["../../../server/service/marketplace-channel/marketplace-channel.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,+CAAoD;AACpD,qCASgB;AAEhB,yDAAgD;AAChD,iDAA8C;AAK9C,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;CAiD9B,CAAA;AA9CC;IAFC,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;8CACC;AAInB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;kDACjB,cAAM,oBAAN,cAAM;kDAAA;AAGf;IADC,IAAA,oBAAU,EAAC,CAAC,kBAAsC,EAAE,EAAE,CAAC,kBAAkB,CAAC,MAAM,CAAC;;oDACjE;AAIjB;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,GAAE;;gDACI;AAIZ;IAFC,IAAA,gBAAM,GAAE;IACR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I,EAAE,CAAC;IACtJ,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC;GACjD,kBAAkB,CAiD9B;AAjDY,gDAAkB"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@things-factory/integration-sellercraft",
|
3
|
-
"version": "5.0.0-alpha.
|
3
|
+
"version": "5.0.0-alpha.39",
|
4
4
|
"main": "dist-server/index.js",
|
5
5
|
"browser": "client/index.js",
|
6
6
|
"things-factory": true,
|
@@ -24,19 +24,19 @@
|
|
24
24
|
"migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
|
25
25
|
},
|
26
26
|
"dependencies": {
|
27
|
-
"@things-factory/apptool-ui": "^5.0.0-alpha.
|
28
|
-
"@things-factory/auth-ui": "^5.0.0-alpha.
|
29
|
-
"@things-factory/biz-base": "^5.0.0-alpha.
|
30
|
-
"@things-factory/code-ui": "^5.0.0-alpha.
|
31
|
-
"@things-factory/context-ui": "^5.0.0-alpha.
|
32
|
-
"@things-factory/grist-ui": "^5.0.0-alpha.
|
33
|
-
"@things-factory/i18n-base": "^5.0.0-alpha.
|
34
|
-
"@things-factory/integration-marketplace": "^5.0.0-alpha.
|
35
|
-
"@things-factory/integration-ui": "^5.0.0-alpha.
|
36
|
-
"@things-factory/more-ui": "^5.0.0-alpha.
|
37
|
-
"@things-factory/resource-ui": "^5.0.0-alpha.
|
38
|
-
"@things-factory/setting-ui": "^5.0.0-alpha.
|
39
|
-
"@things-factory/system-ui": "^5.0.0-alpha.
|
27
|
+
"@things-factory/apptool-ui": "^5.0.0-alpha.39",
|
28
|
+
"@things-factory/auth-ui": "^5.0.0-alpha.39",
|
29
|
+
"@things-factory/biz-base": "^5.0.0-alpha.39",
|
30
|
+
"@things-factory/code-ui": "^5.0.0-alpha.39",
|
31
|
+
"@things-factory/context-ui": "^5.0.0-alpha.39",
|
32
|
+
"@things-factory/grist-ui": "^5.0.0-alpha.39",
|
33
|
+
"@things-factory/i18n-base": "^5.0.0-alpha.39",
|
34
|
+
"@things-factory/integration-marketplace": "^5.0.0-alpha.39",
|
35
|
+
"@things-factory/integration-ui": "^5.0.0-alpha.39",
|
36
|
+
"@things-factory/more-ui": "^5.0.0-alpha.39",
|
37
|
+
"@things-factory/resource-ui": "^5.0.0-alpha.39",
|
38
|
+
"@things-factory/setting-ui": "^5.0.0-alpha.39",
|
39
|
+
"@things-factory/system-ui": "^5.0.0-alpha.39",
|
40
40
|
"debug": "^4.1.1",
|
41
41
|
"node-fetch": "^2.6.0",
|
42
42
|
"querystring": "^0.2.1"
|
@@ -51,5 +51,5 @@
|
|
51
51
|
"nock": "^13.0.2",
|
52
52
|
"should": "^13.2.3"
|
53
53
|
},
|
54
|
-
"gitHead": "
|
54
|
+
"gitHead": "23e58562a4724f157c3bc492cdedb7e32efee6a1"
|
55
55
|
}
|
@@ -1,6 +1,25 @@
|
|
1
1
|
export const ORDER_STATUS = {
|
2
|
-
pending: '
|
2
|
+
pending: 'CONFIRMED',
|
3
3
|
processing: 'CONFIRMED',
|
4
4
|
completed: 'DELIVERED',
|
5
|
-
cancelled: 'CANCELLED'
|
5
|
+
cancelled: 'CANCELLED',
|
6
|
+
canceled: 'CANCELLED',
|
7
|
+
refunded: 'REFUND_COMPLETE',
|
8
|
+
failed: 'SHIPMENT_LOST_OR_DAMAGED',
|
9
|
+
refund: 'REFUND_COMPLETE',
|
10
|
+
ttk_100: 'PAYMENT_PENDING', // UNPAID
|
11
|
+
ttk_111: 'CONFIRMED', // AWAITING_SHIPMENT
|
12
|
+
ttk_112: 'READY_TO_SHIP', // AWAITING_COLLECTION
|
13
|
+
ttk_121: 'SHIPPED', // IN_TRANSIT
|
14
|
+
ttk_122: 'DELIVERED', // DELIVERED
|
15
|
+
ttk_130: 'CLOSED', // COMPLETED
|
16
|
+
ttk_140: 'CANCELLED', // CANCELLED
|
17
|
+
ttk_201: 'INITIATED_CANCELLATION', // CANCEL_PENDING
|
18
|
+
ttk_202: '', // CANCEL_REJECT
|
19
|
+
ttk_203: 'CANCELLED' // CANCEL_COMPLETED
|
20
|
+
}
|
21
|
+
|
22
|
+
export const SHIPPING_TYPE = {
|
23
|
+
DROP_SHIPPING: 'DROP_SHIPPING',
|
24
|
+
CROSS_DOCKING_PICKUP: 'CROSS_DOCKING_PICKUP'
|
6
25
|
}
|
package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-categories.ts
CHANGED
@@ -22,15 +22,16 @@ export function ingestChannelCategories() {
|
|
22
22
|
function mapCategories(categories) {
|
23
23
|
if (!categories) return null
|
24
24
|
categories = categories.map(category => {
|
25
|
+
let children_categories = mapCategories(category.childrenCategories)
|
25
26
|
return {
|
26
27
|
native_category_id: category.categoryId.toString(),
|
27
28
|
channel_code: category.channelCode,
|
28
29
|
channel_country: category.countryCode,
|
29
30
|
category_name: category.categoryName,
|
30
|
-
is_leaf:
|
31
|
+
is_leaf: children_categories.length == 0 ? true : false,
|
31
32
|
is_active: category.isActive,
|
32
|
-
children_categories
|
33
|
+
children_categories
|
33
34
|
}
|
34
35
|
})
|
35
36
|
return categories
|
36
|
-
}
|
37
|
+
}
|
package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-order-package.ts
CHANGED
@@ -38,10 +38,10 @@ export function ingestChannelOrderPackage() {
|
|
38
38
|
name: shipper_last_mile.name
|
39
39
|
}
|
40
40
|
|
41
|
-
|
41
|
+
let newOrderPackage: any = {
|
42
42
|
channel_shop_id,
|
43
43
|
native_order_id,
|
44
|
-
native_package_id,
|
44
|
+
native_package_id: native_package_id.toString(),
|
45
45
|
shipping_tracking_code,
|
46
46
|
shipping_type_value,
|
47
47
|
warehouse_code,
|
@@ -50,6 +50,10 @@ export function ingestChannelOrderPackage() {
|
|
50
50
|
shipper_last_mile,
|
51
51
|
order_item_ids
|
52
52
|
}
|
53
|
+
|
54
|
+
return {
|
55
|
+
payload: { ...newOrderPackage }
|
56
|
+
}
|
53
57
|
},
|
54
58
|
normalize(res) {
|
55
59
|
return res
|
@@ -1,4 +1,4 @@
|
|
1
|
-
/* https://docs.sellercraft.co/docs/api-integrations/
|
1
|
+
/* https://docs.sellercraft.co/docs/api-integrations/b3A6MjQzODQ4OTg-ingest-channel-order */
|
2
2
|
|
3
3
|
import { ORDER_STATUS } from '../../../constants'
|
4
4
|
|
@@ -13,14 +13,20 @@ export function ingestChannelOrder() {
|
|
13
13
|
return {
|
14
14
|
organisation_id: order.organisationId,
|
15
15
|
channel_shop_id: order.channelShopId,
|
16
|
-
native_order_id: order.id,
|
17
|
-
ordered_at_date: new Date(order.createdAt).toISOString(),
|
18
|
-
ordered_at_time: new Date(order.createdAt).toISOString(),
|
19
|
-
updated_at_date: new Date(order.updatedAt).toISOString(),
|
20
|
-
updated_at_time: new Date(order.updatedAt).toISOString(),
|
16
|
+
native_order_id: order.id.toString(),
|
17
|
+
ordered_at_date: new Date(order.createdAt).toISOString().slice(0, -5) + 'Z',
|
18
|
+
ordered_at_time: new Date(order.createdAt).toISOString().slice(0, -5) + 'Z',
|
19
|
+
updated_at_date: new Date(order.updatedAt).toISOString().slice(0, -5) + 'Z',
|
20
|
+
updated_at_time: new Date(order.updatedAt).toISOString().slice(0, -5) + 'Z',
|
21
21
|
customer_first_name: order.custFirstName,
|
22
22
|
customer_last_name: order.custLastName,
|
23
|
-
charges:
|
23
|
+
charges: order.charges.map(charge => {
|
24
|
+
return {
|
25
|
+
charge_type_value: charge.name,
|
26
|
+
amount_gross: parseFloat(charge.grossAmount) || 0,
|
27
|
+
amount_nett: parseFloat(charge.nettAmount) || 0
|
28
|
+
}
|
29
|
+
}),
|
24
30
|
address_shipping: {
|
25
31
|
first_name: order.shipFirstName,
|
26
32
|
last_name: order.shipLastName,
|
@@ -49,16 +55,16 @@ export function ingestChannelOrder() {
|
|
49
55
|
phone_1: order.billPhone1,
|
50
56
|
phone_2: order.billPhone2
|
51
57
|
},
|
52
|
-
order_items: order.
|
58
|
+
order_items: order.mappedOrderItems.map(orderItem => {
|
53
59
|
return {
|
54
60
|
native_item_id: orderItem.id.toString(),
|
55
61
|
native_variant_id: orderItem.variationId.toString(),
|
56
62
|
currency_code: orderItem.currency,
|
57
|
-
ordered_at_date: new Date(order.createdAt).toISOString(),
|
58
|
-
ordered_at_time: new Date(order.createdAt).toISOString(),
|
59
|
-
updated_at_date: new Date(order.updatedAt).toISOString(),
|
60
|
-
updated_at_time: new Date(order.updatedAt).toISOString(),
|
61
|
-
sla_expires_at:
|
63
|
+
ordered_at_date: new Date(order.createdAt).toISOString().slice(0, -5) + 'Z',
|
64
|
+
ordered_at_time: new Date(order.createdAt).toISOString().slice(0, -5) + 'Z',
|
65
|
+
updated_at_date: new Date(order.updatedAt).toISOString().slice(0, -5) + 'Z',
|
66
|
+
updated_at_time: new Date(order.updatedAt).toISOString().slice(0, -5) + 'Z',
|
67
|
+
sla_expires_at: orderItem?.slaExpiresAt ? new Date(orderItem.slaExpiresAt).toISOString() : null,
|
62
68
|
charges: orderItem.charges.map(charge => {
|
63
69
|
return {
|
64
70
|
charge_type_value: charge.name,
|
@@ -68,12 +74,13 @@ export function ingestChannelOrder() {
|
|
68
74
|
}),
|
69
75
|
order_status_value: ORDER_STATUS[`${order.status}`]
|
70
76
|
}
|
71
|
-
})
|
77
|
+
}),
|
78
|
+
seller_logistics: order?.isSOF
|
72
79
|
}
|
73
80
|
})
|
74
81
|
|
75
82
|
return {
|
76
|
-
payload: [
|
83
|
+
payload: [...newOrders]
|
77
84
|
}
|
78
85
|
},
|
79
86
|
normalize(res) {
|
@@ -16,12 +16,14 @@ export function ingestChannelProduct() {
|
|
16
16
|
is_enabled: variant.isEnabled || true,
|
17
17
|
is_sellable: variant.isSellable || true,
|
18
18
|
is_deleted: false, // default
|
19
|
-
variant_attributes: variant?.attributes
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
variant_attributes: variant?.attributes
|
20
|
+
? variant?.attributes.map(attribute => {
|
21
|
+
return {
|
22
|
+
...attribute,
|
23
|
+
native_attribute_id: attribute.native_attribute_id.toString()
|
24
|
+
}
|
25
|
+
})
|
26
|
+
: [],
|
25
27
|
stock_locked: variant?.stockLocked ? variant.stockLocked : 0,
|
26
28
|
native_stock_reported: variant?.stockReported ? variant.stockReported : 0,
|
27
29
|
price_full: variant.fullPrice || 0,
|
@@ -29,7 +31,7 @@ export function ingestChannelProduct() {
|
|
29
31
|
inventory_products: variant?.inventoryProducts
|
30
32
|
? variant.inventoryProducts.map(inventoryProduct => {
|
31
33
|
return {
|
32
|
-
quantity: inventoryProduct.qty ||
|
34
|
+
quantity: inventoryProduct.qty || 0,
|
33
35
|
name: inventoryProduct.name,
|
34
36
|
inventory_sku: inventoryProduct.sku,
|
35
37
|
product_versions: inventoryProduct?.productVersions
|
@@ -43,7 +45,7 @@ export function ingestChannelProduct() {
|
|
43
45
|
package_weight_gram: productVersion?.packageWeightGram
|
44
46
|
? productVersion.packageWeightGram
|
45
47
|
: 0,
|
46
|
-
stock_available: productVersion.qty
|
48
|
+
stock_available: productVersion.qty
|
47
49
|
}
|
48
50
|
})
|
49
51
|
: []
|
@@ -63,19 +65,22 @@ export function ingestChannelProduct() {
|
|
63
65
|
label: product.name,
|
64
66
|
brand: product.brand || '',
|
65
67
|
is_verified: product.isVerified || true,
|
66
|
-
flexible_attributes: product.channelCode == 'WCM' ? true : false, // add channels that do not support category_attributes ingestion
|
67
|
-
images:
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
68
|
+
flexible_attributes: product.channelCode == 'WCM' || product.channelCode == 'MGT' ? true : false, // add channels that do not support category_attributes ingestion
|
69
|
+
images:
|
70
|
+
product?.images?.map(image => {
|
71
|
+
return {
|
72
|
+
file_url: image.url
|
73
|
+
}
|
74
|
+
}) || [],
|
75
|
+
product_attributes:
|
76
|
+
product?.attributes?.map(attribute => {
|
77
|
+
return {
|
78
|
+
...attribute,
|
79
|
+
native_attribute_id: attribute.native_attribute_id.toString()
|
80
|
+
}
|
81
|
+
}) || [],
|
82
|
+
variants: productVariations,
|
83
|
+
has_all_variants: product.channelCode == 'MGT' ? false : true
|
79
84
|
}
|
80
85
|
})
|
81
86
|
|
package/server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.ts
CHANGED
@@ -44,9 +44,11 @@ export class SellercraftChannelIntegration {
|
|
44
44
|
})
|
45
45
|
|
46
46
|
if (response.ok) {
|
47
|
-
|
47
|
+
const result = await response.json()
|
48
|
+
return result
|
48
49
|
} else {
|
49
|
-
|
50
|
+
const result = await response.json()
|
51
|
+
throw new Error(`(${response.status}) ${result.detail}`)
|
50
52
|
}
|
51
53
|
}
|
52
54
|
|
@@ -71,7 +73,8 @@ export class SellercraftChannelIntegration {
|
|
71
73
|
if (response.ok) {
|
72
74
|
return await response.json()
|
73
75
|
} else {
|
74
|
-
|
76
|
+
const result = await response.json()
|
77
|
+
throw new Error(`(${response.status}) ${result.message}`)
|
75
78
|
}
|
76
79
|
}
|
77
80
|
|
@@ -100,7 +103,8 @@ export class SellercraftChannelIntegration {
|
|
100
103
|
if (response.ok) {
|
101
104
|
return await response.json()
|
102
105
|
} else {
|
103
|
-
|
106
|
+
const result = await response.json()
|
107
|
+
throw new Error(`(${response.status}) ${result.message}`)
|
104
108
|
}
|
105
109
|
}
|
106
110
|
}
|