@things-factory/integration-sellercraft 5.0.0-alpha.4 → 5.0.0-alpha.40
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/index.js +1 -0
- package/dist-server/constants/index.js.map +1 -1
- package/dist-server/constants/order-status-mapping.js +28 -0
- package/dist-server/constants/order-status-mapping.js.map +1 -0
- package/dist-server/constants/platform.js +3 -1
- package/dist-server/constants/platform.js.map +1 -1
- package/dist-server/controllers/index.js +2 -0
- package/dist-server/controllers/index.js.map +1 -1
- package/dist-server/controllers/sellercraft-channel-integration/apis/ingest-channel-categories.js +19 -20
- 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 +29 -19
- 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 +24 -40
- 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 +9 -5
- package/dist-server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.js.map +1 -1
- package/dist-server/routers/sellercraft-router.js +220 -84
- package/dist-server/routers/sellercraft-router.js.map +1 -1
- package/dist-server/service/index.js +5 -1
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/marketplace-channel/index.js +9 -0
- package/dist-server/service/marketplace-channel/index.js.map +1 -0
- package/dist-server/service/marketplace-channel/marketplace-channel-order-mutation.js +364 -0
- package/dist-server/service/marketplace-channel/marketplace-channel-order-mutation.js.map +1 -0
- package/dist-server/service/marketplace-channel/marketplace-channel-product-mutation.js +207 -0
- package/dist-server/service/marketplace-channel/marketplace-channel-product-mutation.js.map +1 -0
- package/dist-server/service/marketplace-channel/marketplace-channel.js +88 -0
- package/dist-server/service/marketplace-channel/marketplace-channel.js.map +1 -0
- package/dist-server/service/sellercraft/sellercraft.js +1 -1
- package/package.json +15 -15
- package/server/constants/index.ts +2 -1
- package/server/constants/order-status-mapping.ts +25 -0
- package/server/constants/platform.ts +3 -1
- package/server/controllers/index.ts +2 -0
- package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-categories.ts +19 -20
- 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 +30 -19
- package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-product.ts +32 -47
- package/server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.ts +9 -5
- package/server/routers/sellercraft-router.ts +225 -87
- package/server/service/index.ts +6 -1
- package/server/service/marketplace-channel/index.ts +6 -0
- package/server/service/marketplace-channel/marketplace-channel-order-mutation.ts +412 -0
- package/server/service/marketplace-channel/marketplace-channel-product-mutation.ts +218 -0
- package/server/service/marketplace-channel/marketplace-channel.ts +68 -0
- package/server/service/sellercraft/sellercraft.ts +1 -1
@@ -0,0 +1,88 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
|
+
};
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
10
|
+
};
|
11
|
+
var _a, _b, _c;
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
13
|
+
exports.MarketplaceChannel = void 0;
|
14
|
+
const type_graphql_1 = require("type-graphql");
|
15
|
+
const typeorm_1 = require("typeorm");
|
16
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
17
|
+
const shell_1 = require("@things-factory/shell");
|
18
|
+
let MarketplaceChannel = class MarketplaceChannel {
|
19
|
+
};
|
20
|
+
__decorate([
|
21
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
22
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID),
|
23
|
+
__metadata("design:type", String)
|
24
|
+
], MarketplaceChannel.prototype, "id", void 0);
|
25
|
+
__decorate([
|
26
|
+
(0, typeorm_1.ManyToOne)(type => shell_1.Domain),
|
27
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
28
|
+
__metadata("design:type", typeof (_a = typeof shell_1.Domain !== "undefined" && shell_1.Domain) === "function" ? _a : Object)
|
29
|
+
], MarketplaceChannel.prototype, "domain", void 0);
|
30
|
+
__decorate([
|
31
|
+
(0, typeorm_1.RelationId)((marketplaceChannel) => marketplaceChannel.domain),
|
32
|
+
__metadata("design:type", String)
|
33
|
+
], MarketplaceChannel.prototype, "domainId", void 0);
|
34
|
+
__decorate([
|
35
|
+
(0, typeorm_1.Column)(),
|
36
|
+
(0, type_graphql_1.Field)(),
|
37
|
+
__metadata("design:type", String)
|
38
|
+
], MarketplaceChannel.prototype, "name", void 0);
|
39
|
+
__decorate([
|
40
|
+
(0, typeorm_1.Column)(),
|
41
|
+
(0, type_graphql_1.Field)(),
|
42
|
+
__metadata("design:type", String)
|
43
|
+
], MarketplaceChannel.prototype, "channelCode", void 0);
|
44
|
+
__decorate([
|
45
|
+
(0, typeorm_1.Column)(),
|
46
|
+
(0, type_graphql_1.Field)(),
|
47
|
+
__metadata("design:type", String)
|
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);
|
54
|
+
__decorate([
|
55
|
+
(0, typeorm_1.CreateDateColumn)(),
|
56
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
57
|
+
__metadata("design:type", Date)
|
58
|
+
], MarketplaceChannel.prototype, "createdAt", void 0);
|
59
|
+
__decorate([
|
60
|
+
(0, typeorm_1.UpdateDateColumn)(),
|
61
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
62
|
+
__metadata("design:type", Date)
|
63
|
+
], MarketplaceChannel.prototype, "updatedAt", void 0);
|
64
|
+
__decorate([
|
65
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
66
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
67
|
+
__metadata("design:type", typeof (_b = typeof auth_base_1.User !== "undefined" && auth_base_1.User) === "function" ? _b : Object)
|
68
|
+
], MarketplaceChannel.prototype, "creator", void 0);
|
69
|
+
__decorate([
|
70
|
+
(0, typeorm_1.RelationId)((marketplaceChannel) => marketplaceChannel.creator),
|
71
|
+
__metadata("design:type", String)
|
72
|
+
], MarketplaceChannel.prototype, "creatorId", void 0);
|
73
|
+
__decorate([
|
74
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
75
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
76
|
+
__metadata("design:type", typeof (_c = typeof auth_base_1.User !== "undefined" && auth_base_1.User) === "function" ? _c : Object)
|
77
|
+
], MarketplaceChannel.prototype, "updater", void 0);
|
78
|
+
__decorate([
|
79
|
+
(0, typeorm_1.RelationId)((marketplaceChannel) => marketplaceChannel.updater),
|
80
|
+
__metadata("design:type", String)
|
81
|
+
], MarketplaceChannel.prototype, "updaterId", void 0);
|
82
|
+
MarketplaceChannel = __decorate([
|
83
|
+
(0, typeorm_1.Entity)(),
|
84
|
+
(0, typeorm_1.Index)('ix_marketplace_channel_0 ', (marketplaceChannel) => [marketplaceChannel.domain, marketplaceChannel.name], { unique: true }),
|
85
|
+
(0, type_graphql_1.ObjectType)({ description: 'Entity for Marketplace Channel' })
|
86
|
+
], MarketplaceChannel);
|
87
|
+
exports.MarketplaceChannel = MarketplaceChannel;
|
88
|
+
//# sourceMappingURL=marketplace-channel.js.map
|
@@ -0,0 +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;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,IAAA,oBAAK,GAAE;;uDACW;AAInB;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,GAAE;;qDACS;AAIjB;IAFC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IACzB,IAAA,oBAAK,GAAE;;oDACS;AAIjB;IAFC,IAAA,0BAAgB,GAAE;IAClB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;8BACd,IAAI;qDAAA;AAIhB;IAFC,IAAA,0BAAgB,GAAE;IAClB,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;8BACd,IAAI;qDAAA;AAIhB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;kDAChB,gBAAI,oBAAJ,gBAAI;mDAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,kBAAsC,EAAE,EAAE,CAAC,kBAAkB,CAAC,OAAO,CAAC;;qDACjE;AAIlB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;kDAChB,gBAAI,oBAAJ,gBAAI;mDAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,kBAAsC,EAAE,EAAE,CAAC,kBAAkB,CAAC,OAAO,CAAC;;qDACjE;AAhDP,kBAAkB;IAH9B,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,2BAA2B,EAAE,CAAC,kBAAsC,EAAE,EAAE,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IACtJ,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC;GACjD,kBAAkB,CAiD9B;AAjDY,gDAAkB"}
|
@@ -99,7 +99,7 @@ __decorate([
|
|
99
99
|
__metadata("design:type", typeof (_c = typeof auth_base_1.User !== "undefined" && auth_base_1.User) === "function" ? _c : Object)
|
100
100
|
], Sellercraft.prototype, "updater", void 0);
|
101
101
|
__decorate([
|
102
|
-
(0, typeorm_1.RelationId)((sellercraft) => sellercraft.
|
102
|
+
(0, typeorm_1.RelationId)((sellercraft) => sellercraft.updater),
|
103
103
|
__metadata("design:type", String)
|
104
104
|
], Sellercraft.prototype, "updaterId", void 0);
|
105
105
|
Sellercraft = __decorate([
|
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.40",
|
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.40",
|
28
|
+
"@things-factory/auth-ui": "^5.0.0-alpha.40",
|
29
|
+
"@things-factory/biz-base": "^5.0.0-alpha.40",
|
30
|
+
"@things-factory/code-ui": "^5.0.0-alpha.40",
|
31
|
+
"@things-factory/context-ui": "^5.0.0-alpha.40",
|
32
|
+
"@things-factory/grist-ui": "^5.0.0-alpha.40",
|
33
|
+
"@things-factory/i18n-base": "^5.0.0-alpha.40",
|
34
|
+
"@things-factory/integration-marketplace": "^5.0.0-alpha.40",
|
35
|
+
"@things-factory/integration-ui": "^5.0.0-alpha.40",
|
36
|
+
"@things-factory/more-ui": "^5.0.0-alpha.40",
|
37
|
+
"@things-factory/resource-ui": "^5.0.0-alpha.40",
|
38
|
+
"@things-factory/setting-ui": "^5.0.0-alpha.40",
|
39
|
+
"@things-factory/system-ui": "^5.0.0-alpha.40",
|
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": "c64462e85c9b744250f5649d28c0ec4bd56a1b38"
|
55
55
|
}
|
@@ -1 +1,2 @@
|
|
1
|
-
export * from './platform'
|
1
|
+
export * from './platform'
|
2
|
+
export * from './order-status-mapping'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
export const ORDER_STATUS = {
|
2
|
+
pending: 'CONFIRMED',
|
3
|
+
processing: 'CONFIRMED',
|
4
|
+
completed: 'DELIVERED',
|
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'
|
25
|
+
}
|
package/server/controllers/sellercraft-channel-integration/apis/ingest-channel-categories.ts
CHANGED
@@ -7,28 +7,10 @@ export function ingestChannelCategories() {
|
|
7
7
|
denormalize(req) {
|
8
8
|
const { categories } = req
|
9
9
|
|
10
|
-
let newCategories = categories
|
11
|
-
return {
|
12
|
-
channel_id: category.channelId,
|
13
|
-
native_category_id: category.categoryId,
|
14
|
-
category_name: category.categoryName,
|
15
|
-
is_leaf: category.isLeaf,
|
16
|
-
is_active: category.isActive,
|
17
|
-
children_categories: category.childrenCategories.map(childrenCategory => {
|
18
|
-
return {
|
19
|
-
channel_id: childrenCategory.channelId,
|
20
|
-
native_category_id: childrenCategory.categoryId,
|
21
|
-
category_name: childrenCategory.categoryName,
|
22
|
-
is_leaf: childrenCategory.isLeaf,
|
23
|
-
is_active: childrenCategory.isActive,
|
24
|
-
children_categories: {}
|
25
|
-
}
|
26
|
-
})
|
27
|
-
}
|
28
|
-
})
|
10
|
+
let newCategories = mapCategories(categories)
|
29
11
|
|
30
12
|
return {
|
31
|
-
payload:
|
13
|
+
payload: [...newCategories]
|
32
14
|
}
|
33
15
|
},
|
34
16
|
normalize(res) {
|
@@ -36,3 +18,20 @@ export function ingestChannelCategories() {
|
|
36
18
|
}
|
37
19
|
}
|
38
20
|
}
|
21
|
+
|
22
|
+
function mapCategories(categories) {
|
23
|
+
if (!categories) return null
|
24
|
+
categories = categories.map(category => {
|
25
|
+
let children_categories = mapCategories(category.childrenCategories)
|
26
|
+
return {
|
27
|
+
native_category_id: category.categoryId.toString(),
|
28
|
+
channel_code: category.channelCode,
|
29
|
+
channel_country: category.countryCode,
|
30
|
+
category_name: category.categoryName,
|
31
|
+
is_leaf: children_categories.length == 0 ? true : false,
|
32
|
+
is_active: category.isActive,
|
33
|
+
children_categories
|
34
|
+
}
|
35
|
+
})
|
36
|
+
return categories
|
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,6 @@
|
|
1
|
-
/* https://docs.sellercraft.co/docs/api-integrations/
|
1
|
+
/* https://docs.sellercraft.co/docs/api-integrations/b3A6MjQzODQ4OTg-ingest-channel-order */
|
2
|
+
|
3
|
+
import { ORDER_STATUS } from '../../../constants'
|
2
4
|
|
3
5
|
export function ingestChannelOrder() {
|
4
6
|
return {
|
@@ -11,13 +13,20 @@ export function ingestChannelOrder() {
|
|
11
13
|
return {
|
12
14
|
organisation_id: order.organisationId,
|
13
15
|
channel_shop_id: order.channelShopId,
|
14
|
-
native_order_id: order.id,
|
15
|
-
ordered_at_date: order.createdAt,
|
16
|
-
ordered_at_time: order.createdAt,
|
17
|
-
updated_at_date: order.updatedAt,
|
18
|
-
updated_at_time: order.updatedAt,
|
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',
|
19
21
|
customer_first_name: order.custFirstName,
|
20
22
|
customer_last_name: order.custLastName,
|
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
|
+
}),
|
21
30
|
address_shipping: {
|
22
31
|
first_name: order.shipFirstName,
|
23
32
|
last_name: order.shipLastName,
|
@@ -46,30 +55,32 @@ export function ingestChannelOrder() {
|
|
46
55
|
phone_1: order.billPhone1,
|
47
56
|
phone_2: order.billPhone2
|
48
57
|
},
|
49
|
-
order_items: order.
|
58
|
+
order_items: order.mappedOrderItems.map(orderItem => {
|
50
59
|
return {
|
51
|
-
native_item_id: orderItem.id,
|
52
|
-
native_variant_id: orderItem.variationId,
|
60
|
+
native_item_id: orderItem.id.toString(),
|
61
|
+
native_variant_id: orderItem.variationId.toString(),
|
53
62
|
currency_code: orderItem.currency,
|
54
|
-
ordered_at_date: order.createdAt,
|
55
|
-
ordered_at_time: order.createdAt,
|
56
|
-
updated_at_date: order.updatedAt,
|
57
|
-
updated_at_time: order.updatedAt,
|
58
|
-
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,
|
59
68
|
charges: orderItem.charges.map(charge => {
|
60
69
|
return {
|
61
70
|
charge_type_value: charge.name,
|
62
|
-
amount_gross: charge.grossAmount,
|
63
|
-
amount_nett: charge.nettAmount
|
71
|
+
amount_gross: parseFloat(charge.grossAmount) || 0,
|
72
|
+
amount_nett: parseFloat(charge.nettAmount) || 0
|
64
73
|
}
|
65
|
-
})
|
74
|
+
}),
|
75
|
+
order_status_value: ORDER_STATUS[`${order.status}`]
|
66
76
|
}
|
67
|
-
})
|
77
|
+
}),
|
78
|
+
seller_logistics: order?.isSOF
|
68
79
|
}
|
69
80
|
})
|
70
81
|
|
71
82
|
return {
|
72
|
-
payload:
|
83
|
+
payload: [...newOrders]
|
73
84
|
}
|
74
85
|
},
|
75
86
|
normalize(res) {
|
@@ -11,35 +11,27 @@ export function ingestChannelProduct() {
|
|
11
11
|
let productVariations: any[] = product.variations.map(variant => {
|
12
12
|
return {
|
13
13
|
seller_sku: variant.variationSku,
|
14
|
-
native_variant_id: variant.variationId,
|
14
|
+
native_variant_id: variant.variationId.toString(),
|
15
15
|
label: variant.name,
|
16
|
-
is_enabled: variant.isEnabled,
|
17
|
-
is_sellable: variant.isSellable,
|
16
|
+
is_enabled: variant.isEnabled || true,
|
17
|
+
is_sellable: variant.isSellable || true,
|
18
|
+
is_deleted: false, // default
|
18
19
|
variant_attributes: variant?.attributes
|
19
|
-
? variant
|
20
|
+
? variant?.attributes.map(attribute => {
|
20
21
|
return {
|
21
|
-
|
22
|
-
|
22
|
+
...attribute,
|
23
|
+
native_attribute_id: attribute.native_attribute_id.toString()
|
23
24
|
}
|
24
25
|
})
|
25
26
|
: [],
|
26
27
|
stock_locked: variant?.stockLocked ? variant.stockLocked : 0,
|
27
28
|
native_stock_reported: variant?.stockReported ? variant.stockReported : 0,
|
28
|
-
price_full: variant.fullPrice,
|
29
|
-
price_discounted: variant.priceDiscounted,
|
30
|
-
price_discounts: variant?.product_discounts
|
31
|
-
? variant.product_discounts.map(discount => {
|
32
|
-
return {
|
33
|
-
price_discounted: discount.priceDiscounted,
|
34
|
-
native_discount_id: discount.id,
|
35
|
-
name: discount.name
|
36
|
-
}
|
37
|
-
})
|
38
|
-
: [],
|
29
|
+
price_full: variant.fullPrice || 0,
|
30
|
+
price_discounted: variant.priceDiscounted || variant.fullPrice || 0,
|
39
31
|
inventory_products: variant?.inventoryProducts
|
40
32
|
? variant.inventoryProducts.map(inventoryProduct => {
|
41
33
|
return {
|
42
|
-
quantity: inventoryProduct.qty,
|
34
|
+
quantity: inventoryProduct.qty || 0,
|
43
35
|
name: inventoryProduct.name,
|
44
36
|
inventory_sku: inventoryProduct.sku,
|
45
37
|
product_versions: inventoryProduct?.productVersions
|
@@ -68,43 +60,36 @@ export function ingestChannelProduct() {
|
|
68
60
|
channel_shop_id: product.channelShopId,
|
69
61
|
channel_code: product.channelCode,
|
70
62
|
channel_country: product.channelCountry,
|
71
|
-
native_category_id: product.categoryId,
|
72
|
-
native_product_id: product.productId,
|
63
|
+
native_category_id: product.categoryId.toString(),
|
64
|
+
native_product_id: product.productId.toString(),
|
73
65
|
label: product.name,
|
74
|
-
brand: product.brand,
|
75
|
-
is_verified: product.isVerified,
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
66
|
+
brand: product.brand || '',
|
67
|
+
is_verified: product.isVerified || true,
|
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
|
87
84
|
}
|
88
85
|
})
|
89
86
|
|
90
87
|
return {
|
91
|
-
payload:
|
88
|
+
payload: [...newProducts]
|
92
89
|
}
|
93
90
|
},
|
94
91
|
normalize(res) {
|
95
|
-
|
96
|
-
handover_type: handOverType,
|
97
|
-
pickup_time: pickupTime,
|
98
|
-
pickup_address: pickupAddress,
|
99
|
-
dropoff_address: dropoffAddress
|
100
|
-
} = res.data
|
101
|
-
|
102
|
-
return {
|
103
|
-
handOverType,
|
104
|
-
pickupTime,
|
105
|
-
pickupAddress,
|
106
|
-
dropoffAddress
|
107
|
-
}
|
92
|
+
return res
|
108
93
|
}
|
109
94
|
}
|
110
95
|
}
|
package/server/controllers/sellercraft-channel-integration/sellercraft-channel-integration.ts
CHANGED
@@ -38,15 +38,17 @@ export class SellercraftChannelIntegration {
|
|
38
38
|
headers: {
|
39
39
|
'Content-Type': 'application/json',
|
40
40
|
request_id: requestId,
|
41
|
-
'
|
41
|
+
'X-Api-Key': apiKey
|
42
42
|
},
|
43
43
|
body: jsondata
|
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
|
}
|