fc-landmark 1.0.4 → 1.0.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.
package/dist/axios.js CHANGED
@@ -1,30 +1,30 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const axios_1 = __importDefault(require("axios"));
7
- const globals_1 = require("./globals");
8
- const injectRequestId = (data) => {
9
- if (data) {
10
- data.requestId = globals_1.MyGlobal.requestId;
11
- data.rootRequestId = globals_1.MyGlobal.rootRequestId;
12
- }
13
- return data;
14
- };
15
- let axiosMiddleware = {
16
- get: (urlPath, configs) => {
17
- return axios_1.default.get(urlPath, configs);
18
- },
19
- put: (urlPath, data, configs) => {
20
- return axios_1.default.put(urlPath, data, configs);
21
- },
22
- post: (urlPath, data, configs) => {
23
- return axios_1.default.post(urlPath, data, configs);
24
- },
25
- delete: (urlPath, configs) => {
26
- return axios_1.default.delete(urlPath, configs);
27
- },
28
- };
29
- exports.default = axiosMiddleware;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const axios_1 = __importDefault(require("axios"));
7
+ const globals_1 = require("./globals");
8
+ const injectRequestId = (data) => {
9
+ if (data) {
10
+ data.requestId = globals_1.MyGlobal.requestId;
11
+ data.rootRequestId = globals_1.MyGlobal.rootRequestId;
12
+ }
13
+ return data;
14
+ };
15
+ let axiosMiddleware = {
16
+ get: (urlPath, configs) => {
17
+ return axios_1.default.get(urlPath, configs);
18
+ },
19
+ put: (urlPath, data, configs) => {
20
+ return axios_1.default.put(urlPath, data, configs);
21
+ },
22
+ post: (urlPath, data, configs) => {
23
+ return axios_1.default.post(urlPath, data, configs);
24
+ },
25
+ delete: (urlPath, configs) => {
26
+ return axios_1.default.delete(urlPath, configs);
27
+ },
28
+ };
29
+ exports.default = axiosMiddleware;
30
30
  //# sourceMappingURL=axios.js.map
package/dist/axios.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"axios.js","sourceRoot":"","sources":["../src/axios.ts"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAE1B,uCAA4C;AAG5C,MAAM,eAAe,GAAG,CAAC,IAAkB,EAAE,EAAE;IAC3C,IAAG,IAAI,EAAE;QACL,IAAI,CAAC,SAAS,GAAG,kBAAG,CAAC,SAAS,CAAC;QAC/B,IAAI,CAAC,aAAa,GAAG,kBAAG,CAAC,aAAa,CAAC;KAC1C;IACD,OAAO,IAAI,CAAC;AAChB,CAAC,CAAA;AAED,IAAI,eAAe,GAAwB;IACvC,GAAG,EAAE,CAAC,OAAe,EAAE,OAAqB,EAAE,EAAE;QAC5C,OAAO,eAAK,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;IACD,GAAG,EAAE,CAAC,OAAe,EAAE,IAAkB,EAAE,OAAqB,EAAE,EAAE;QAChE,OAAO,eAAK,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;IACD,IAAI,EAAE,CAAC,OAAe,EAAE,IAAkB,EAAE,OAAqB,EAAE,EAAE;QACjE,OAAO,eAAK,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IACD,MAAM,EAAE,CAAC,OAAe,EAAE,OAAqB,EAAE,EAAE;QAC/C,OAAO,eAAK,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;CACJ,CAAA;AAED,kBAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"axios.js","sourceRoot":"","sources":["../src/axios.ts"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAE1B,uCAA4C;AAG5C,MAAM,eAAe,GAAG,CAAC,IAAkB,EAAE,EAAE;IAC3C,IAAG,IAAI,EAAE,CAAC;QACN,IAAI,CAAC,SAAS,GAAG,kBAAG,CAAC,SAAS,CAAC;QAC/B,IAAI,CAAC,aAAa,GAAG,kBAAG,CAAC,aAAa,CAAC;IAC3C,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC,CAAA;AAED,IAAI,eAAe,GAAwB;IACvC,GAAG,EAAE,CAAC,OAAe,EAAE,OAAqB,EAAE,EAAE;QAC5C,OAAO,eAAK,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;IACD,GAAG,EAAE,CAAC,OAAe,EAAE,IAAkB,EAAE,OAAqB,EAAE,EAAE;QAChE,OAAO,eAAK,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;IACD,IAAI,EAAE,CAAC,OAAe,EAAE,IAAkB,EAAE,OAAqB,EAAE,EAAE;QACjE,OAAO,eAAK,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IACD,MAAM,EAAE,CAAC,OAAe,EAAE,OAAqB,EAAE,EAAE;QAC/C,OAAO,eAAK,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;CACJ,CAAA;AAED,kBAAe,eAAe,CAAC"}
package/dist/core.js CHANGED
@@ -1,19 +1,19 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.setRequredGlobals = void 0;
7
- const globals_1 = require("./globals");
8
- const axios_1 = __importDefault(require("./axios"));
9
- const setRequredGlobals = (logger, flclerror, rootRequestId, requestId) => {
10
- globals_1.MyGlobal.logger = logger || undefined;
11
- globals_1.MyGlobal.flclError = flclerror || undefined;
12
- globals_1.MyGlobal.rootRequestId = rootRequestId || '';
13
- globals_1.MyGlobal.requestId = requestId || '';
14
- globals_1.MyGlobal.axios = axios_1.default;
15
- globals_1.MyGlobal.ship_url = "https://api.landmarkglobal.com/v2/Import.php",
16
- globals_1.MyGlobal.track_url = "https://api.landmarkglobal.com/v2/Track.php";
17
- };
18
- exports.setRequredGlobals = setRequredGlobals;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.setRequredGlobals = void 0;
7
+ const globals_1 = require("./globals");
8
+ const axios_1 = __importDefault(require("./axios"));
9
+ const setRequredGlobals = (logger, flclerror, rootRequestId, requestId) => {
10
+ globals_1.MyGlobal.logger = logger || undefined;
11
+ globals_1.MyGlobal.flclError = flclerror || undefined;
12
+ globals_1.MyGlobal.rootRequestId = rootRequestId || '';
13
+ globals_1.MyGlobal.requestId = requestId || '';
14
+ globals_1.MyGlobal.axios = axios_1.default;
15
+ globals_1.MyGlobal.ship_url = "https://api.landmarkglobal.com/v2/Import.php",
16
+ globals_1.MyGlobal.track_url = "https://api.landmarkglobal.com/v2/Track.php";
17
+ };
18
+ exports.setRequredGlobals = setRequredGlobals;
19
19
  //# sourceMappingURL=core.js.map
package/dist/globals.js CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MyGlobal = void 0;
4
- exports.MyGlobal = {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MyGlobal = void 0;
4
+ exports.MyGlobal = {};
5
5
  //# sourceMappingURL=globals.js.map
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LandMark = void 0;
4
- var landmark_1 = require("./landmark");
5
- Object.defineProperty(exports, "LandMark", { enumerable: true, get: function () { return landmark_1.LandMark; } });
6
- //export default ECMS;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LandMark = void 0;
4
+ var landmark_1 = require("./landmark");
5
+ Object.defineProperty(exports, "LandMark", { enumerable: true, get: function () { return landmark_1.LandMark; } });
6
+ //export default ECMS;
7
7
  //# sourceMappingURL=index.js.map
package/dist/landmark.js CHANGED
@@ -1,76 +1,76 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.LandMark = void 0;
16
- const shipment_1 = __importDefault(require("./shipment"));
17
- const tracking_1 = __importDefault(require("./tracking"));
18
- const core_1 = require("./core");
19
- const globals_1 = require("./globals");
20
- class LandMark {
21
- constructor(username, password, clientId, test, vendorEORINumber, vendorIOSSNumber, logger, flclerror, rootRequestId, requestId) {
22
- this.username = username;
23
- this.password = password;
24
- this.test = test;
25
- this.clientId = clientId;
26
- this.vendorEORINumber = vendorEORINumber;
27
- this.vendorIOSSNumber = vendorIOSSNumber;
28
- (0, core_1.setRequredGlobals)(logger, flclerror, rootRequestId, requestId);
29
- }
30
- createShipmet(args) {
31
- var _a, _b, _c, _d;
32
- return __awaiter(this, void 0, void 0, function* () {
33
- try {
34
- let shipObj = new shipment_1.default();
35
- (_a = globals_1.MyGlobal.logger) === null || _a === void 0 ? void 0 : _a.info({ npm: 'fc-landmark', className: 'Landmark', methodName: 'createShipmet', propertyName: 'landMarkShipmentInput', propertyValue: args });
36
- let landmarkShipmentRequest = shipObj.buildShipmentRequest(args, this.username, this.password, this.test, this.clientId, this.vendorEORINumber, this.vendorIOSSNumber);
37
- (_b = globals_1.MyGlobal.logger) === null || _b === void 0 ? void 0 : _b.info({ npm: 'fc-landmark', className: 'Landmark', methodName: 'createShipmet', propertyName: 'landMarkShipmentRequest', propertyValue: landmarkShipmentRequest });
38
- let landmarkShipmentRes = yield shipObj.createShipment(landmarkShipmentRequest);
39
- if (landmarkShipmentRes.hasOwnProperty("ImportResponse") && landmarkShipmentRes['ImportResponse']['Errors']) {
40
- throw new Error(landmarkShipmentRes['ImportResponse']['Errors']['Error']['ErrorMessage']['_text']);
41
- }
42
- let response = shipObj.buildResponse(landmarkShipmentRes, args);
43
- (_c = globals_1.MyGlobal.logger) === null || _c === void 0 ? void 0 : _c.info({ npm: 'fc-landmark', className: 'Landmark', methodName: 'createShipmet', propertyName: 'response', propertyValue: response });
44
- return response;
45
- }
46
- catch (e) {
47
- (_d = globals_1.MyGlobal.logger) === null || _d === void 0 ? void 0 : _d.error(globals_1.MyGlobal.flclError.create({ npm: 'fc-landmark', className: 'Landmark', methodName: 'createShipmet', propertyName: 'landMark_ERROR', cause: e, message: 'Exception while creating shipment in Landmark' }));
48
- throw e;
49
- }
50
- });
51
- }
52
- getTrackingInfo(args) {
53
- var _a, _b, _c, _d;
54
- return __awaiter(this, void 0, void 0, function* () {
55
- try {
56
- let trackObj = new tracking_1.default();
57
- (_a = globals_1.MyGlobal.logger) === null || _a === void 0 ? void 0 : _a.info({ npm: 'fc-landmark', className: 'Landmark', methodName: 'getTrackingInfo', propertyName: 'LandmarkInput', propertyValue: args });
58
- let landmarkTrackRequest = trackObj.buildTrackingRequest(args, this.username, this.password, this.test, this.clientId);
59
- (_b = globals_1.MyGlobal.logger) === null || _b === void 0 ? void 0 : _b.info({ npm: 'fc-landmark', className: 'Landmark', methodName: 'getTrackingInfo', propertyName: 'LandmarkTrackRequest', propertyValue: landmarkTrackRequest });
60
- let landMarkTrackingRes = yield trackObj.trackInfo(landmarkTrackRequest);
61
- if (landMarkTrackingRes.hasOwnProperty("TrackResponse") && landMarkTrackingRes['TrackResponse']['Errors']) {
62
- throw new Error(landMarkTrackingRes['TrackResponse']['Errors']['Error']['ErrorMessage']['_text']);
63
- }
64
- let response = trackObj.buildResponse(landMarkTrackingRes, args);
65
- (_c = globals_1.MyGlobal.logger) === null || _c === void 0 ? void 0 : _c.info({ npm: 'fc-landmark', className: 'Landmark', methodName: 'getTrackingInfo', propertyName: 'response', propertyValue: response });
66
- return response;
67
- }
68
- catch (e) {
69
- (_d = globals_1.MyGlobal.logger) === null || _d === void 0 ? void 0 : _d.error(globals_1.MyGlobal.flclError.create({ npm: 'fc-landmark', className: 'Landmark', methodName: 'getTrackingInfo', propertyName: 'landMark_ERROR', cause: e, message: 'Exception while get trackinfo in Landmark' }));
70
- throw e;
71
- }
72
- });
73
- }
74
- }
75
- exports.LandMark = LandMark;
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.LandMark = void 0;
16
+ const shipment_1 = __importDefault(require("./shipment"));
17
+ const tracking_1 = __importDefault(require("./tracking"));
18
+ const core_1 = require("./core");
19
+ const globals_1 = require("./globals");
20
+ class LandMark {
21
+ constructor(username, password, clientId, test, vendorEORINumber, vendorIOSSNumber, logger, flclerror, rootRequestId, requestId) {
22
+ this.username = username;
23
+ this.password = password;
24
+ this.test = test;
25
+ this.clientId = clientId;
26
+ this.vendorEORINumber = vendorEORINumber;
27
+ this.vendorIOSSNumber = vendorIOSSNumber;
28
+ (0, core_1.setRequredGlobals)(logger, flclerror, rootRequestId, requestId);
29
+ }
30
+ createShipmet(args_1) {
31
+ return __awaiter(this, arguments, void 0, function* (args, dangerousGoodsDeatils = "") {
32
+ var _a, _b, _c, _d;
33
+ try {
34
+ let shipObj = new shipment_1.default();
35
+ (_a = globals_1.MyGlobal.logger) === null || _a === void 0 ? void 0 : _a.info({ npm: 'fc-landmark', className: 'Landmark', methodName: 'createShipmet', propertyName: 'landMarkShipmentInput', propertyValue: args });
36
+ let landmarkShipmentRequest = shipObj.buildShipmentRequest(args, dangerousGoodsDeatils, this.username, this.password, this.test, this.clientId, this.vendorEORINumber, this.vendorIOSSNumber);
37
+ (_b = globals_1.MyGlobal.logger) === null || _b === void 0 ? void 0 : _b.info({ npm: 'fc-landmark', className: 'Landmark', methodName: 'createShipmet', propertyName: 'landMarkShipmentRequest', propertyValue: landmarkShipmentRequest });
38
+ let landmarkShipmentRes = yield shipObj.createShipment(landmarkShipmentRequest);
39
+ if (landmarkShipmentRes.hasOwnProperty("ImportResponse") && landmarkShipmentRes['ImportResponse']['Errors']) {
40
+ throw new Error(landmarkShipmentRes['ImportResponse']['Errors']['Error']['ErrorMessage']['_text']);
41
+ }
42
+ let response = shipObj.buildResponse(landmarkShipmentRes, args);
43
+ (_c = globals_1.MyGlobal.logger) === null || _c === void 0 ? void 0 : _c.info({ npm: 'fc-landmark', className: 'Landmark', methodName: 'createShipmet', propertyName: 'response', propertyValue: response });
44
+ return response;
45
+ }
46
+ catch (e) {
47
+ (_d = globals_1.MyGlobal.logger) === null || _d === void 0 ? void 0 : _d.error(globals_1.MyGlobal.flclError.create({ npm: 'fc-landmark', className: 'Landmark', methodName: 'createShipmet', propertyName: 'landMark_ERROR', cause: e, message: 'Exception while creating shipment in Landmark' }));
48
+ throw e;
49
+ }
50
+ });
51
+ }
52
+ getTrackingInfo(args) {
53
+ return __awaiter(this, void 0, void 0, function* () {
54
+ var _a, _b, _c, _d;
55
+ try {
56
+ let trackObj = new tracking_1.default();
57
+ (_a = globals_1.MyGlobal.logger) === null || _a === void 0 ? void 0 : _a.info({ npm: 'fc-landmark', className: 'Landmark', methodName: 'getTrackingInfo', propertyName: 'LandmarkInput', propertyValue: args });
58
+ let landmarkTrackRequest = trackObj.buildTrackingRequest(args, this.username, this.password, this.test, this.clientId);
59
+ (_b = globals_1.MyGlobal.logger) === null || _b === void 0 ? void 0 : _b.info({ npm: 'fc-landmark', className: 'Landmark', methodName: 'getTrackingInfo', propertyName: 'LandmarkTrackRequest', propertyValue: landmarkTrackRequest });
60
+ let landMarkTrackingRes = yield trackObj.trackInfo(landmarkTrackRequest);
61
+ if (landMarkTrackingRes.hasOwnProperty("TrackResponse") && landMarkTrackingRes['TrackResponse']['Errors']) {
62
+ throw new Error(landMarkTrackingRes['TrackResponse']['Errors']['Error']['ErrorMessage']['_text']);
63
+ }
64
+ let response = trackObj.buildResponse(landMarkTrackingRes, args);
65
+ (_c = globals_1.MyGlobal.logger) === null || _c === void 0 ? void 0 : _c.info({ npm: 'fc-landmark', className: 'Landmark', methodName: 'getTrackingInfo', propertyName: 'response', propertyValue: response });
66
+ return response;
67
+ }
68
+ catch (e) {
69
+ (_d = globals_1.MyGlobal.logger) === null || _d === void 0 ? void 0 : _d.error(globals_1.MyGlobal.flclError.create({ npm: 'fc-landmark', className: 'Landmark', methodName: 'getTrackingInfo', propertyName: 'landMark_ERROR', cause: e, message: 'Exception while get trackinfo in Landmark' }));
70
+ throw e;
71
+ }
72
+ });
73
+ }
74
+ }
75
+ exports.LandMark = LandMark;
76
76
  //# sourceMappingURL=landmark.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"landmark.js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AAC,OAAO,CAAC,CAAC,CAAG;gBACxG,CAAC;gBACD,IAAI,QAAQ,GAAiC,QAAQ,CAAC,aAAa,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC;gBAC/F,MAAA,kBAAG,CAAC,MAAM,0CAAE,IAAI,CAAC,EAAC,GAAG,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,iBAAiB,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAC,CAAC,CAAC;gBAChJ,OAAO,QAAQ,CAAC;YACpB,CAAC;YAAC,OAAM,CAAC,EAAE,CAAC;gBACR,MAAA,kBAAG,CAAC,MAAM,0CAAE,KAAK,CAAC,kBAAG,CAAC,SAAU,CAAC,MAAM,CAAC,EAAC,GAAG,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,iBAAiB,EAAE,YAAY,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,2CAA2C,EAAC,CAAC,CAAC,CAAC;gBACrN,MAAM,CAAC,CAAC;YACZ,CAAC;QACL,CAAC;KAAA;CACJ;AAxDD,4BAwDC"}
package/dist/shipment.js CHANGED
@@ -1,188 +1,200 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const globals_1 = require("./globals");
13
- const xml_js_1 = require("xml-js");
14
- class Shipment {
15
- constructor() {
16
- }
17
- getConsignee(shipto_address, targetToCountry) {
18
- const combinedAddress = shipto_address.address_line_1 + shipto_address.address_line_2 + shipto_address.address_line_3;
19
- let consignee = {
20
- "Name": shipto_address.name.slice(0, 50),
21
- "Attention": shipto_address.attention_name.slice(0, 50),
22
- "Address1": combinedAddress.substring(0, 60),
23
- "Address2": combinedAddress.substring(61, 120),
24
- "Address3": combinedAddress.substring(121, 180),
25
- "City": shipto_address.city,
26
- "State": shipto_address.state,
27
- "PostalCode": shipto_address.zip,
28
- "Country": targetToCountry ? targetToCountry : shipto_address.country,
29
- "Phone": shipto_address.phone.toString(),
30
- "Email": shipto_address.email,
31
- "ConsigneeTaxID": shipto_address.federal_tax_id ? shipto_address.federal_tax_id : ""
32
- };
33
- return consignee;
34
- }
35
- getShipperInfo(shipfrom_address, targetFromCountry) {
36
- const combinedAddress = shipfrom_address.address_line_1 + shipfrom_address.address_line_2 + shipfrom_address.address_line_3;
37
- let shipper = {
38
- "Name": shipfrom_address.name.slice(0, 50),
39
- "Attention": shipfrom_address.attention_name.slice(0, 50),
40
- "Address1": combinedAddress.substring(0, 60),
41
- "Address2": combinedAddress.substring(61, 120),
42
- "Address3": combinedAddress.substring(121, 180),
43
- "City": shipfrom_address.city,
44
- "State": shipfrom_address.state,
45
- "PostalCode": shipfrom_address.zip,
46
- "Country": targetFromCountry ? targetFromCountry : shipfrom_address.country,
47
- "Phone": shipfrom_address.phone.toString(),
48
- "Email": shipfrom_address.email
49
- };
50
- return shipper;
51
- }
52
- getVendorInfo(shipfrom_address, targetFromCountry, eroiNumber, iossNumber) {
53
- const combinedAddress = shipfrom_address.address_line_1 + shipfrom_address.address_line_2 + shipfrom_address.address_line_3;
54
- let shipper = {
55
- "VendorName": shipfrom_address.name.slice(0, 50),
56
- "Attention": shipfrom_address.attention_name.slice(0, 50),
57
- "VendorAddress1": combinedAddress.substring(0, 60),
58
- "VendorAddress2": combinedAddress.substring(61, 120),
59
- "VendorAddress3": combinedAddress.substring(121, 180),
60
- "VendorCity": shipfrom_address.city,
61
- "VendorState": shipfrom_address.state,
62
- "VendorPostalCode": shipfrom_address.zip,
63
- "VendorCountry": targetFromCountry ? targetFromCountry : shipfrom_address.country,
64
- "VendorPhone": shipfrom_address.phone.toString(),
65
- "VendorEmail": shipfrom_address.email,
66
- "VendorBusinessNumber": "",
67
- "VendorRGRNumber": "",
68
- "VendorIOSSNumber": iossNumber,
69
- "VendorEORINumber": eroiNumber
70
- };
71
- return shipper;
72
- }
73
- buildShipmentRequest(args, username, password, test, clientId, vendorEORINumber, vendorIOSSNumber) {
74
- try {
75
- const EUCountries = ["BE", "BG", "CZ", "DK", "DE", "EE", "IE", "EL", "ES", "FR", "HR", "IT", "CY", "LV", "LT", "LU", "HU", "MT", "NL", "AT", "PL", "PT", "RO", "SI", "SK", "FI", "SE"];
76
- let iossNumber = "";
77
- if (EUCountries.indexOf(args.shipto_address.country.toUpperCase()) != -1 || EUCountries.indexOf(args.targetToCountry.toUpperCase()) != -1) {
78
- iossNumber = vendorIOSSNumber;
79
- }
80
- let eroiNumber = "";
81
- if (args.shipto_address.country.toUpperCase() == "GB" || args.shipto_address.country.toUpperCase() == "UK") {
82
- eroiNumber = vendorEORINumber;
83
- }
84
- let importRequest = {
85
- "Login": {
86
- "Username": username,
87
- "Password": password
88
- },
89
- "Test": test,
90
- "ClientID": clientId,
91
- "Reference": args.reference,
92
- "ShipTo": this.getConsignee(args.shipto_address, args.targetToCountry),
93
- "ShippingLane": {
94
- "Region": "Landmark BUF"
95
- },
96
- "ShipMethod": args._carrierRateObj.servicecode,
97
- "OrderTotal": args.shipment_total_usd,
98
- "ItemsCurrency": args.currency,
99
- "ProduceLabel": true,
100
- "LabelFormat": args.label_format,
101
- "LabelEncoding": args.label_format.toLowerCase() == "zpl" ? "ZPL" : "LINKS",
102
- "Packages": {
103
- "Package": {
104
- "WeightUnit": args.weight_unit,
105
- "Weight": args.package.weight,
106
- "DimensionsUnit": args.dimension_unit,
107
- "Length": args.package.length,
108
- "Width": args.package.width,
109
- "Height": args.package.height,
110
- "PackageReference": args.reference
111
- }
112
- },
113
- "SendReturnToAddress": this.getShipperInfo(args.shipfrom_address, args.targetFromCountry),
114
- "VendorInformation": this.getVendorInfo(args.shipfrom_address, args.targetFromCountry, eroiNumber, iossNumber),
115
- "IsCommercialShipment": args.b2b ? 1 : 0,
116
- };
117
- // let items = args.pieces.map((item:any)=>{
118
- // return {"Item":{
119
- // "Sku": item.sku || 12345,
120
- // "Description": item.description.substr(0,100),
121
- // "Quantity": item.quantity,
122
- // "UnitPrice": (item.sale_price == 0) ? 0.01 : item.sale_price,
123
- // "HSCode": item.hs_code,
124
- // "CountryOfOrigin": item.origin_country_code
125
- // }
126
- // }
127
- // })
128
- let items = args.pieces.map((item) => {
129
- return {
130
- "Sku": item.sku || 12345,
131
- "Description": item.description.substr(0, 100),
132
- "Quantity": item.quantity,
133
- "UnitPrice": (item.sale_price == 0) ? 0.01 : item.sale_price,
134
- "HSCode": item.hs_code,
135
- "CountryOfOrigin": item.origin_country_code
136
- };
137
- });
138
- importRequest["Items"] = { "Item": items };
139
- let request = {
140
- "ImportRequest": importRequest
141
- };
142
- const xmlData = (0, xml_js_1.js2xml)(request, { compact: true, ignoreComment: true, spaces: 4 });
143
- return xmlData;
144
- }
145
- catch (e) {
146
- throw globals_1.MyGlobal.FlclError.create({ className: 'Shipment', methodName: '_buildRequest', message: 'Exception while building the LandMark shipment request', cause: e, appendChildMsg: true });
147
- }
148
- }
149
- createShipment(ShipmentRequest) {
150
- var _a, _b, _c;
151
- return __awaiter(this, void 0, void 0, function* () {
152
- try {
153
- let configs = {
154
- headers: {
155
- 'Content-Type': 'application/xml'
156
- }
157
- };
158
- let resp = yield globals_1.MyGlobal.axios.post(globals_1.MyGlobal.ship_url, ShipmentRequest, configs);
159
- console.log(resp.data);
160
- (_a = globals_1.MyGlobal.logger) === null || _a === void 0 ? void 0 : _a.info({ npm: 'fc-landmark', className: 'Landmark', methodName: 'createShipmet', propertyName: 'Landmark-RAW-RESPOSNE', propertyValue: resp.data });
161
- let responsejson = (0, xml_js_1.xml2json)(resp.data, { compact: true, spaces: 4 });
162
- return JSON.parse(responsejson);
163
- }
164
- catch (e) {
165
- (_b = globals_1.MyGlobal.logger) === null || _b === void 0 ? void 0 : _b.info({ npm: 'fc-landmark', className: 'Landmark', methodName: 'createShipmet', propertyName: 'Landmark-RAW-RESPOSNE', data: { error: e } });
166
- (_c = globals_1.MyGlobal.logger) === null || _c === void 0 ? void 0 : _c.error(globals_1.MyGlobal.flclError.create({ npm: 'fc-landmark', className: 'Shipment', methodName: 'createShipment', propertyName: 'CREDITS_ERROR', cause: e }));
167
- throw e;
168
- }
169
- });
170
- }
171
- buildResponse(resp, args) {
172
- let response = {
173
- provider_name: 'Landmark',
174
- shipping_provider: 'Landmark',
175
- carrier: 'Landmark',
176
- tracking_number: resp['ImportResponse']['Result']['Packages']['Package']['TrackingNumber']['_text'],
177
- provider_tracking_number: resp['ImportResponse']['Result']['Packages']['Package']['TrackingNumber']['_text'],
178
- shipping_label: args.label_format.toLowerCase() == "zpl" ? resp['ImportResponse']['Result']['Packages']['Package']['LabelImages']['LabelImage']['_text'] : resp['ImportResponse']['Result']['ShipmentLabelLink']['_text'],
179
- label_type: args.label_format.toLowerCase() == "zpl" ? "zplenc" : "url",
180
- gross_weight: args.total_weight,
181
- gross_weight_unit: args.weight_unit,
182
- submitted_electronically: true
183
- };
184
- return response;
185
- }
186
- }
187
- exports.default = Shipment;
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const globals_1 = require("./globals");
13
+ const xml_js_1 = require("xml-js");
14
+ class Shipment {
15
+ constructor() {
16
+ }
17
+ getConsignee(shipto_address, targetToCountry) {
18
+ const combinedAddress = shipto_address.address_line_1 + shipto_address.address_line_2 + shipto_address.address_line_3;
19
+ let consignee = {
20
+ "Name": shipto_address.name.slice(0, 50),
21
+ "Attention": shipto_address.attention_name.slice(0, 50),
22
+ "Address1": combinedAddress.substring(0, 60),
23
+ "Address2": combinedAddress.substring(61, 120),
24
+ "Address3": combinedAddress.substring(121, 180),
25
+ "City": shipto_address.city,
26
+ "State": shipto_address.state,
27
+ "PostalCode": shipto_address.zip,
28
+ "Country": targetToCountry ? targetToCountry : shipto_address.country,
29
+ "Phone": shipto_address.phone.toString(),
30
+ "Email": shipto_address.email,
31
+ "ConsigneeTaxID": shipto_address.federal_tax_id ? shipto_address.federal_tax_id : ""
32
+ };
33
+ return consignee;
34
+ }
35
+ getShipperInfo(shipfrom_address, targetFromCountry) {
36
+ const combinedAddress = shipfrom_address.address_line_1 + shipfrom_address.address_line_2 + shipfrom_address.address_line_3;
37
+ let shipper = {
38
+ "Name": shipfrom_address.name.slice(0, 50),
39
+ "Attention": shipfrom_address.attention_name.slice(0, 50),
40
+ "Address1": combinedAddress.substring(0, 60),
41
+ "Address2": combinedAddress.substring(61, 120),
42
+ "Address3": combinedAddress.substring(121, 180),
43
+ "City": shipfrom_address.city,
44
+ "State": shipfrom_address.state,
45
+ "PostalCode": shipfrom_address.zip,
46
+ "Country": targetFromCountry ? targetFromCountry : shipfrom_address.country,
47
+ "Phone": shipfrom_address.phone.toString(),
48
+ "Email": shipfrom_address.email
49
+ };
50
+ return shipper;
51
+ }
52
+ getVendorInfo(shipfrom_address, targetFromCountry, eroiNumber, iossNumber) {
53
+ const combinedAddress = shipfrom_address.address_line_1 + shipfrom_address.address_line_2 + shipfrom_address.address_line_3;
54
+ let shipper = {
55
+ "VendorName": shipfrom_address.name.slice(0, 50),
56
+ "Attention": shipfrom_address.attention_name.slice(0, 50),
57
+ "VendorAddress1": combinedAddress.substring(0, 60),
58
+ "VendorAddress2": combinedAddress.substring(61, 120),
59
+ "VendorAddress3": combinedAddress.substring(121, 180),
60
+ "VendorCity": shipfrom_address.city,
61
+ "VendorState": shipfrom_address.state,
62
+ "VendorPostalCode": shipfrom_address.zip,
63
+ "VendorCountry": targetFromCountry ? targetFromCountry : shipfrom_address.country,
64
+ "VendorPhone": shipfrom_address.phone.toString(),
65
+ "VendorEmail": shipfrom_address.email,
66
+ "VendorBusinessNumber": "",
67
+ "VendorRGRNumber": "",
68
+ "VendorIOSSNumber": iossNumber,
69
+ "VendorEORINumber": eroiNumber
70
+ };
71
+ return shipper;
72
+ }
73
+ buildShipmentRequest(args, dangerousGoodsDeatils = "", username, password, test, clientId, vendorEORINumber, vendorIOSSNumber) {
74
+ try {
75
+ const EUCountries = ["BE", "BG", "CZ", "DK", "DE", "EE", "IE", "EL", "ES", "FR", "HR", "IT", "CY", "LV", "LT", "LU", "HU", "MT", "NL", "AT", "PL", "PT", "RO", "SI", "SK", "FI", "SE"];
76
+ let iossNumber = "";
77
+ if (EUCountries.indexOf(args.shipto_address.country.toUpperCase()) != -1 || EUCountries.indexOf(args.targetToCountry.toUpperCase()) != -1) {
78
+ iossNumber = vendorIOSSNumber;
79
+ }
80
+ let eroiNumber = "";
81
+ if (args.shipto_address.country.toUpperCase() == "GB" || args.shipto_address.country.toUpperCase() == "UK") {
82
+ eroiNumber = vendorEORINumber;
83
+ }
84
+ let importRequest = {
85
+ "Login": {
86
+ "Username": username,
87
+ "Password": password
88
+ },
89
+ "Test": test,
90
+ "ClientID": clientId,
91
+ "Reference": args.reference,
92
+ "ShipTo": this.getConsignee(args.shipto_address, args.targetToCountry),
93
+ "ShippingLane": {
94
+ "Region": "Landmark BUF"
95
+ },
96
+ "ShipMethod": args._carrierRateObj.servicecode,
97
+ "OrderTotal": args.shipment_total_usd,
98
+ "ItemsCurrency": args.currency,
99
+ "ProduceLabel": true,
100
+ "LabelFormat": args.label_format,
101
+ "LabelEncoding": args.label_format.toLowerCase() == "zpl" ? "ZPL" : "LINKS",
102
+ "Packages": {
103
+ "Package": {
104
+ "WeightUnit": args.weight_unit,
105
+ "Weight": args.package.weight,
106
+ "DimensionsUnit": args.dimension_unit,
107
+ "Length": args.package.length,
108
+ "Width": args.package.width,
109
+ "Height": args.package.height,
110
+ "PackageReference": args.reference
111
+ }
112
+ },
113
+ "SendReturnToAddress": this.getShipperInfo(args.shipfrom_address, args.targetFromCountry),
114
+ "VendorInformation": this.getVendorInfo(args.shipfrom_address, args.targetFromCountry, eroiNumber, iossNumber),
115
+ "IsCommercialShipment": args.b2b ? 1 : 0,
116
+ };
117
+ // let items = args.pieces.map((item:any)=>{
118
+ // return {"Item":{
119
+ // "Sku": item.sku || 12345,
120
+ // "Description": item.description.substr(0,100),
121
+ // "Quantity": item.quantity,
122
+ // "UnitPrice": (item.sale_price == 0) ? 0.01 : item.sale_price,
123
+ // "HSCode": item.hs_code,
124
+ // "CountryOfOrigin": item.origin_country_code
125
+ // }
126
+ // }
127
+ // })
128
+ let items = args.pieces.map((item) => {
129
+ let itemObj = {
130
+ "Sku": item.sku || 12345,
131
+ "Description": item.description.substr(0, 100),
132
+ "Quantity": item.quantity,
133
+ "UnitPrice": (item.sale_price == 0) ? 0.01 : item.sale_price,
134
+ "HSCode": item.hs_code,
135
+ "CountryOfOrigin": item.origin_country_code
136
+ };
137
+ if (dangerousGoodsDeatils && dangerousGoodsDeatils[item.sku] && dangerousGoodsDeatils[item.sku]['UNCode']) {
138
+ let dangerousGoodInformation = {
139
+ "ContainsDangerousGoods": 1,
140
+ "UNCode": dangerousGoodsDeatils[item.sku]['UNCode'] || "",
141
+ "PackingGroup": dangerousGoodsDeatils[item.sku]['CategoryCode'] || "",
142
+ "PackingInstructions": dangerousGoodsDeatils[item.sku]['PackingInstructions'] || "",
143
+ "ItemWeight": item.weight,
144
+ "ItemWeightUnit": args.weight_unit
145
+ };
146
+ itemObj["DangerousGoodsInformation"] = dangerousGoodInformation;
147
+ }
148
+ return itemObj;
149
+ });
150
+ importRequest["Items"] = { "Item": items };
151
+ let request = {
152
+ "ImportRequest": importRequest
153
+ };
154
+ const xmlData = (0, xml_js_1.js2xml)(request, { compact: true, ignoreComment: true, spaces: 4 });
155
+ return xmlData;
156
+ }
157
+ catch (e) {
158
+ throw globals_1.MyGlobal.FlclError.create({ className: 'Shipment', methodName: '_buildRequest', message: 'Exception while building the LandMark shipment request', cause: e, appendChildMsg: true });
159
+ }
160
+ }
161
+ createShipment(ShipmentRequest) {
162
+ return __awaiter(this, void 0, void 0, function* () {
163
+ var _a, _b, _c;
164
+ try {
165
+ let configs = {
166
+ headers: {
167
+ 'Content-Type': 'application/xml'
168
+ }
169
+ };
170
+ let resp = yield globals_1.MyGlobal.axios.post(globals_1.MyGlobal.ship_url, ShipmentRequest, configs);
171
+ console.log(resp.data);
172
+ (_a = globals_1.MyGlobal.logger) === null || _a === void 0 ? void 0 : _a.info({ npm: 'fc-landmark', className: 'Landmark', methodName: 'createShipmet', propertyName: 'Landmark-RAW-RESPOSNE', propertyValue: resp.data });
173
+ let responsejson = (0, xml_js_1.xml2json)(resp.data, { compact: true, spaces: 4 });
174
+ return JSON.parse(responsejson);
175
+ }
176
+ catch (e) {
177
+ (_b = globals_1.MyGlobal.logger) === null || _b === void 0 ? void 0 : _b.info({ npm: 'fc-landmark', className: 'Landmark', methodName: 'createShipmet', propertyName: 'Landmark-RAW-RESPOSNE', data: { error: e } });
178
+ (_c = globals_1.MyGlobal.logger) === null || _c === void 0 ? void 0 : _c.error(globals_1.MyGlobal.flclError.create({ npm: 'fc-landmark', className: 'Shipment', methodName: 'createShipment', propertyName: 'CREDITS_ERROR', cause: e }));
179
+ throw e;
180
+ }
181
+ });
182
+ }
183
+ buildResponse(resp, args) {
184
+ let response = {
185
+ provider_name: 'Landmark',
186
+ shipping_provider: 'Landmark',
187
+ carrier: 'Landmark',
188
+ tracking_number: resp['ImportResponse']['Result']['Packages']['Package']['TrackingNumber']['_text'],
189
+ provider_tracking_number: resp['ImportResponse']['Result']['Packages']['Package']['TrackingNumber']['_text'],
190
+ shipping_label: args.label_format.toLowerCase() == "zpl" ? resp['ImportResponse']['Result']['Packages']['Package']['LabelImages']['LabelImage']['_text'] : resp['ImportResponse']['Result']['ShipmentLabelLink']['_text'],
191
+ label_type: args.label_format.toLowerCase() == "zpl" ? "zplenc" : "url",
192
+ gross_weight: args.total_weight,
193
+ gross_weight_unit: args.weight_unit,
194
+ submitted_electronically: true
195
+ };
196
+ return response;
197
+ }
198
+ }
199
+ exports.default = Shipment;
188
200
  //# sourceMappingURL=shipment.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shipment.js","sourceRoot":"","sources":["../src/shipment.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,uCAA4C;AAC5C,mCAA0C;AAE1C,MAAqB,QAAQ;IACzB;IAEA,CAAC;IACD,YAAY,CAAC,cAAmB,EAAC,eAAmB;QAEhD,MAAM,eAAe,GAAG,cAAc,CAAC,cAAc,GAAG,cAAc,CAAC,cAAc,GAAG,cAAc,CAAC,cAAc,CAAC;QACtH,IAAI,SAAS,GAAQ;YACjB,MAAM,EAAE,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;YACxC,WAAW,EAAE,cAAc,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;YACvD,UAAU,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC,EAAC,EAAE,CAAC;YAC3C,UAAU,EAAE,eAAe,CAAC,SAAS,CAAC,EAAE,EAAC,GAAG,CAAC;YAC7C,UAAU,EAAE,eAAe,CAAC,SAAS,CAAC,GAAG,EAAC,GAAG,CAAC;YAC9C,MAAM,EAAE,cAAc,CAAC,IAAI;YAC3B,OAAO,EAAE,cAAc,CAAC,KAAK;YAC7B,YAAY,EAAE,cAA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,CAAC,CAAC,OAAO,CAAC;YACzN,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,IAAI,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK;YACvE,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,iBAAiB,EAAE,IAAI,CAAC,WAAW;YACnC,wBAAwB,EAAE,IAAI;SACjC,CAAC;QACF,OAAO,QAAQ,CAAC;IACpB,CAAC;CAEJ;AA3LD,2BA2LC"}
package/dist/tracking.js CHANGED
@@ -1,93 +1,93 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const globals_1 = require("./globals");
13
- const xml_js_1 = require("xml-js");
14
- class Tracking {
15
- constructor() {
16
- }
17
- buildTrackingRequest(args, username, password, test, clientId) {
18
- try {
19
- let trackRequest = {
20
- "Login": {
21
- "Username": username,
22
- "Password": password
23
- },
24
- "Test": test,
25
- "ClientID": clientId,
26
- "TrackingNumber": args.tracking_number,
27
- "RetrievalType": "Historical"
28
- };
29
- let request = {
30
- "TrackRequest": trackRequest
31
- };
32
- const xmlData = (0, xml_js_1.js2xml)(request, { compact: true, ignoreComment: true, spaces: 4 });
33
- return xmlData;
34
- }
35
- catch (e) {
36
- throw globals_1.MyGlobal.FlclError.create({ className: 'Tracking', methodName: '_buildRequest', message: 'Exception while building the LandMark Tracking request', cause: e, appendChildMsg: true });
37
- }
38
- }
39
- trackInfo(ShipmentRequest) {
40
- var _a, _b, _c;
41
- return __awaiter(this, void 0, void 0, function* () {
42
- try {
43
- let configs = {
44
- headers: {
45
- 'Content-Type': 'application/xml'
46
- }
47
- };
48
- let resp = yield globals_1.MyGlobal.axios.post(globals_1.MyGlobal.track_url, ShipmentRequest, configs);
49
- (_a = globals_1.MyGlobal.logger) === null || _a === void 0 ? void 0 : _a.info({ npm: 'fc-landmark', className: 'Tracking', methodName: 'trackInfo', propertyName: 'landmark-RAW-RESPOSNE', propertyValue: resp.data });
50
- let responsejson = (0, xml_js_1.xml2json)(resp.data, { compact: true, spaces: 4 });
51
- return JSON.parse(responsejson);
52
- }
53
- catch (e) {
54
- (_b = globals_1.MyGlobal.logger) === null || _b === void 0 ? void 0 : _b.info({ npm: 'fc-landmark', className: 'Tracking', methodName: 'trackInfo', propertyName: 'landmar-RAW-RESPOSNE', data: { error: e } });
55
- (_c = globals_1.MyGlobal.logger) === null || _c === void 0 ? void 0 : _c.error(globals_1.MyGlobal.flclError.create({ npm: 'fc-landmark', className: 'Tracking', methodName: 'trackInfo', propertyName: 'CREDITS_ERROR', cause: e }));
56
- throw e;
57
- }
58
- });
59
- }
60
- buildResponse(resp, args) {
61
- let response = {
62
- reference: args.reference,
63
- tracking_number: args.tracking_number,
64
- tracking_history: []
65
- };
66
- if (!Array.isArray(resp['TrackResponse']['Result']['Packages']['Package']['Events']['Event'])) {
67
- resp['TrackResponse']['Result']['Packages']['Package']['Events']['Event'] = [resp['TrackResponse']['Result']['Packages']['Package']['Events']['Event']];
68
- }
69
- for (let i = 0; i < resp['TrackResponse']['Result']['Packages']['Package']['Events']['Event'].length; i++) {
70
- let history = {};
71
- let code = resp['TrackResponse']['Result']['Packages']['Package']['Events']['Event'][i]['EventCode']['_text'];
72
- if (code == '50' || code == '60') {
73
- history.status = "In Progress";
74
- }
75
- else if (code == '500') {
76
- history.status = "Delivered";
77
- }
78
- else {
79
- history.status = "In Transit";
80
- }
81
- history.status_date = resp['TrackResponse']['Result']['Packages']['Package']['Events']['Event'][i]['DateTime']['_text'];
82
- let dateofevent = new Date(history.status_date);
83
- history.event_date = dateofevent.getTime();
84
- history.status_detail = resp['TrackResponse']['Result']['Packages']['Package']['Events']['Event'][i]['Status']['_text'] || "";
85
- history.location = resp['TrackResponse']['Result']['Packages']['Package']['Events']['Event'][i]['Location']['_text'] || '';
86
- history.country = '';
87
- response.tracking_history.push(history);
88
- }
89
- return response;
90
- }
91
- }
92
- exports.default = Tracking;
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const globals_1 = require("./globals");
13
+ const xml_js_1 = require("xml-js");
14
+ class Tracking {
15
+ constructor() {
16
+ }
17
+ buildTrackingRequest(args, username, password, test, clientId) {
18
+ try {
19
+ let trackRequest = {
20
+ "Login": {
21
+ "Username": username,
22
+ "Password": password
23
+ },
24
+ "Test": test,
25
+ "ClientID": clientId,
26
+ "TrackingNumber": args.tracking_number,
27
+ "RetrievalType": "Historical"
28
+ };
29
+ let request = {
30
+ "TrackRequest": trackRequest
31
+ };
32
+ const xmlData = (0, xml_js_1.js2xml)(request, { compact: true, ignoreComment: true, spaces: 4 });
33
+ return xmlData;
34
+ }
35
+ catch (e) {
36
+ throw globals_1.MyGlobal.FlclError.create({ className: 'Tracking', methodName: '_buildRequest', message: 'Exception while building the LandMark Tracking request', cause: e, appendChildMsg: true });
37
+ }
38
+ }
39
+ trackInfo(ShipmentRequest) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ var _a, _b, _c;
42
+ try {
43
+ let configs = {
44
+ headers: {
45
+ 'Content-Type': 'application/xml'
46
+ }
47
+ };
48
+ let resp = yield globals_1.MyGlobal.axios.post(globals_1.MyGlobal.track_url, ShipmentRequest, configs);
49
+ (_a = globals_1.MyGlobal.logger) === null || _a === void 0 ? void 0 : _a.info({ npm: 'fc-landmark', className: 'Tracking', methodName: 'trackInfo', propertyName: 'landmark-RAW-RESPOSNE', propertyValue: resp.data });
50
+ let responsejson = (0, xml_js_1.xml2json)(resp.data, { compact: true, spaces: 4 });
51
+ return JSON.parse(responsejson);
52
+ }
53
+ catch (e) {
54
+ (_b = globals_1.MyGlobal.logger) === null || _b === void 0 ? void 0 : _b.info({ npm: 'fc-landmark', className: 'Tracking', methodName: 'trackInfo', propertyName: 'landmar-RAW-RESPOSNE', data: { error: e } });
55
+ (_c = globals_1.MyGlobal.logger) === null || _c === void 0 ? void 0 : _c.error(globals_1.MyGlobal.flclError.create({ npm: 'fc-landmark', className: 'Tracking', methodName: 'trackInfo', propertyName: 'CREDITS_ERROR', cause: e }));
56
+ throw e;
57
+ }
58
+ });
59
+ }
60
+ buildResponse(resp, args) {
61
+ let response = {
62
+ reference: args.reference,
63
+ tracking_number: args.tracking_number,
64
+ tracking_history: []
65
+ };
66
+ if (!Array.isArray(resp['TrackResponse']['Result']['Packages']['Package']['Events']['Event'])) {
67
+ resp['TrackResponse']['Result']['Packages']['Package']['Events']['Event'] = [resp['TrackResponse']['Result']['Packages']['Package']['Events']['Event']];
68
+ }
69
+ for (let i = 0; i < resp['TrackResponse']['Result']['Packages']['Package']['Events']['Event'].length; i++) {
70
+ let history = {};
71
+ let code = resp['TrackResponse']['Result']['Packages']['Package']['Events']['Event'][i]['EventCode']['_text'];
72
+ if (code == '50' || code == '60') {
73
+ history.status = "In Progress";
74
+ }
75
+ else if (code == '500') {
76
+ history.status = "Delivered";
77
+ }
78
+ else {
79
+ history.status = "In Transit";
80
+ }
81
+ history.status_date = resp['TrackResponse']['Result']['Packages']['Package']['Events']['Event'][i]['DateTime']['_text'];
82
+ let dateofevent = new Date(history.status_date);
83
+ history.event_date = dateofevent.getTime();
84
+ history.status_detail = resp['TrackResponse']['Result']['Packages']['Package']['Events']['Event'][i]['Status']['_text'] || "";
85
+ history.location = resp['TrackResponse']['Result']['Packages']['Package']['Events']['Event'][i]['Location']['_text'] || '';
86
+ history.country = '';
87
+ response.tracking_history.push(history);
88
+ }
89
+ return response;
90
+ }
91
+ }
92
+ exports.default = Tracking;
93
93
  //# sourceMappingURL=tracking.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tracking.js","sourceRoot":"","sources":["../src/tracking.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,uCAA4C;AAC5C,mCAA0C;AAE1C,MAAqB,QAAQ;IACzB;IAEA,CAAC;IAED,oBAAoB,CAAC,IAAS,EAAC,QAAgB,EAAC,QAAgB,EAAE,IAAY,EAAC,QAAe;QAC1F,IAAI;YACA,IAAI,YAAY,GAAQ;gBACpB,OAAO,EAAE;oBACL,UAAU,EAAE,QAAQ;oBACpB,UAAU,EAAE,QAAQ;iBACvB;gBACD,MAAM,EAAE,IAAI;gBACZ,UAAU,EAAE,QAAQ;gBACpB,gBAAgB,EAAE,IAAI,CAAC,eAAe;gBACtC,eAAe,EAAC,YAAY;aAE/B,CAAC;YACF,IAAI,OAAO,GAAQ;gBACf,cAAc,EAAE,YAAY;aAC/B,CAAA;YACD,MAAM,OAAO,GAAG,IAAA,eAAM,EAAC,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;YACnF,OAAO,OAAO,CAAC;SAClB;QAAC,OAAM,CAAC,EAAE;YACP,MAAM,kBAAG,CAAC,SAAU,CAAC,MAAM,CAAC,EAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,wDAAwD,EAAE,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a,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,IAAG,EAAE,CAAC;YAC7H,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAC3H,OAAO,CAAC,OAAO,GAAG,EAAE,CAAC;YACrB,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC5C,CAAC;QACL,OAAO,QAAQ,CAAC;IAChB,CAAC;CACJ;AA9ED,2BA8EC"}
package/dist/types.js CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=types.js.map
package/package.json CHANGED
@@ -1,31 +1,31 @@
1
- {
2
- "name": "fc-landmark",
3
- "version": "1.0.4",
4
- "description": "landmark Shipment and Tracking API.",
5
- "main": "./dist/index.js",
6
- "scripts": {
7
- "build": "rm -rf ./dist && tsc",
8
- "test": "echo \"Error: no test specified\" && exit 1"
9
- },
10
- "author": "Midhun",
11
- "license": "ISC",
12
- "dependencies": {
13
- "@types/xml2js": "0.4.11",
14
- "@types/redis": "^2.8.25",
15
- "@types/redlock": "^4.0.1",
16
- "@types/uuid": "^8.3.0",
17
- "app-root-path": "^3.0.0",
18
- "axios": "^0.19.0",
19
- "fc-logger": "^4.2.0",
20
- "fs": "0.0.1-security",
21
- "redis": "^3.0.2",
22
- "redlock": "^4.1.0",
23
- "request": "^2.88.2",
24
- "uuid": "^8.3.0",
25
- "xml-js": "1.6.11"
26
- },
27
- "devDependencies": {
28
- "@types/request": "^2.48.7",
29
- "typescript": "^4.9.5"
30
- }
31
- }
1
+ {
2
+ "name": "fc-landmark",
3
+ "version": "1.0.5",
4
+ "description": "landmark Shipment and Tracking API.",
5
+ "main": "./dist/index.js",
6
+ "scripts": {
7
+ "build": "rm -rf ./dist && tsc",
8
+ "test": "echo \"Error: no test specified\" && exit 1"
9
+ },
10
+ "author": "Midhun",
11
+ "license": "ISC",
12
+ "dependencies": {
13
+ "@types/xml2js": "0.4.11",
14
+ "@types/redis": "^2.8.25",
15
+ "@types/redlock": "^4.0.1",
16
+ "@types/uuid": "^8.3.0",
17
+ "app-root-path": "^3.0.0",
18
+ "axios": "^0.19.0",
19
+ "fc-logger": "^4.2.0",
20
+ "fs": "0.0.1-security",
21
+ "redis": "^3.0.2",
22
+ "redlock": "^4.1.0",
23
+ "request": "^2.88.2",
24
+ "uuid": "^8.3.0",
25
+ "xml-js": "1.6.11"
26
+ },
27
+ "devDependencies": {
28
+ "@types/request": "^2.48.7",
29
+ "typescript": "^4.9.5"
30
+ }
31
+ }
package/src/landmark.ts CHANGED
@@ -21,12 +21,12 @@ export class LandMark {
21
21
  setRequredGlobals(logger, flclerror, rootRequestId, requestId);
22
22
  }
23
23
 
24
- async createShipmet(args: any) {
24
+ async createShipmet(args: any, dangerousGoodsDeatils: any = "") {
25
25
  try {
26
26
 
27
27
  let shipObj = new Shipment();
28
28
  app.logger?.info({npm: 'fc-landmark', className: 'Landmark', methodName: 'createShipmet', propertyName: 'landMarkShipmentInput', propertyValue: args});
29
- let landmarkShipmentRequest: string = shipObj.buildShipmentRequest(args,this.username,this.password,this.test,this.clientId,this.vendorEORINumber,this.vendorIOSSNumber);
29
+ let landmarkShipmentRequest: string = shipObj.buildShipmentRequest(args, dangerousGoodsDeatils, this.username,this.password,this.test,this.clientId,this.vendorEORINumber,this.vendorIOSSNumber);
30
30
  app.logger?.info({npm: 'fc-landmark', className: 'Landmark', methodName: 'createShipmet', propertyName: 'landMarkShipmentRequest', propertyValue: landmarkShipmentRequest});
31
31
  let landmarkShipmentRes: any = await shipObj.createShipment(landmarkShipmentRequest);
32
32
  if(landmarkShipmentRes.hasOwnProperty("ImportResponse") && landmarkShipmentRes['ImportResponse']['Errors']){
package/src/shipment.ts CHANGED
@@ -66,7 +66,7 @@ export default class Shipment {
66
66
  return shipper;
67
67
  }
68
68
 
69
- buildShipmentRequest(args: any,username:string,password:string,test:boolean,clientId:number,vendorEORINumber:any,vendorIOSSNumber:any): string{
69
+ buildShipmentRequest(args: any, dangerousGoodsDeatils: any = "", username:string,password:string,test:boolean,clientId:number,vendorEORINumber:any,vendorIOSSNumber:any): string{
70
70
  try {
71
71
  const EUCountries = ["BE", "BG", "CZ", "DK", "DE", "EE", "IE", "EL", "ES", "FR", "HR", "IT", "CY", "LV", "LT", "LU", "HU", "MT", "NL", "AT", "PL", "PT", "RO", "SI", "SK", "FI", "SE"];
72
72
  let iossNumber=""
@@ -122,7 +122,7 @@ export default class Shipment {
122
122
  // }
123
123
  // })
124
124
  let items = args.pieces.map((item:any) => {
125
- return {
125
+ let itemObj: any = {
126
126
  "Sku": item.sku || 12345,
127
127
  "Description": item.description.substr(0, 100),
128
128
  "Quantity": item.quantity,
@@ -130,6 +130,18 @@ export default class Shipment {
130
130
  "HSCode": item.hs_code,
131
131
  "CountryOfOrigin": item.origin_country_code
132
132
  };
133
+ if(dangerousGoodsDeatils && dangerousGoodsDeatils[item.sku] && dangerousGoodsDeatils[item.sku]['UNCode']){
134
+ let dangerousGoodInformation = {
135
+ "ContainsDangerousGoods": 1,
136
+ "UNCode": dangerousGoodsDeatils[item.sku]['UNCode'] || "",
137
+ "PackingGroup": dangerousGoodsDeatils[item.sku]['CategoryCode'] || "",
138
+ "PackingInstructions": dangerousGoodsDeatils[item.sku]['PackingInstructions'] || "",
139
+ "ItemWeight": item.weight,
140
+ "ItemWeightUnit": args.weight_unit
141
+ }
142
+ itemObj["DangerousGoodsInformation"] = dangerousGoodInformation;
143
+ }
144
+ return itemObj;
133
145
  });
134
146
  importRequest["Items"] = { "Item": items };
135
147
  let request :any = {
package/tests/shipment.js CHANGED
@@ -59,7 +59,7 @@ let request = {
59
59
  "origin_country_code": "US",
60
60
  "material": "wellbel glamlab Single International",
61
61
  "description": "wellbel glamlab Single International",
62
- "sku": "SKU",
62
+ "sku": "sku123",
63
63
  "category": [
64
64
  "wellbel glamlab - Single - International"
65
65
  ],
@@ -83,7 +83,7 @@ let request = {
83
83
  "origin_country_code": "US",
84
84
  "material": "wellbel glamlab Single International",
85
85
  "description": "wellbel glamlab Single International",
86
- "sku": "SKU",
86
+ "sku": "sku123",
87
87
  "category": [
88
88
  "wellbel glamlab - Single - International"
89
89
  ],
@@ -403,7 +403,7 @@ let request = {
403
403
  "providerrateid": 9437685,
404
404
  "hashkey": "ZpPGix",
405
405
  "carrier": "landmark",
406
- "servicecode": "APC.PRIUDC",
406
+ "servicecode": "LGINTSTDU",
407
407
  "flclservicecode": "standard",
408
408
  "termsoftrade": "DDU",
409
409
  "easypostreferenceid": "",
@@ -432,9 +432,16 @@ let request = {
432
432
  async function create(){
433
433
  try{
434
434
  console.log('sampel gift');
435
-
436
- let landmark = new LandMark("demoapi","demo123",false,'','','','');
437
- let res = await landmark.createShipmet(request);
435
+ let dangerousGoodDEtails = {
436
+ "sku123": {
437
+ "SKU": "sku123",
438
+ "UNCode": "UN3481",
439
+ "CategoryCode": "II",
440
+ "PackingInstructions": "PS967S1"
441
+ }
442
+ };
443
+ let landmark = new LandMark("flavorcloudapi","FCL@ndmark123", "2056", false,'','','','');
444
+ let res = await landmark.createShipmet(request, dangerousGoodDEtails);
438
445
  console.log(res);
439
446
  return res;
440
447