fc-landmark 1.0.0

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/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # Introduction
2
+ Landmark carrier Integration api
3
+
4
+ # Getting Started
5
+ 1. Installation process (npm install fc-landmark)
6
+ 2. Software dependencies
7
+ 3. Latest releases
8
+ 4. API references
9
+
10
+ # Build and Test
11
+ npm run bild and use tests folder
12
+
13
+ # Contribute
@@ -0,0 +1,45 @@
1
+ # Docker
2
+ # Build a Docker image
3
+ # https://docs.microsoft.com/azure/devops/pipelines/languages/docker
4
+
5
+
6
+ trigger:
7
+ batch: true
8
+ branches:
9
+ include:
10
+ - ppe
11
+ - feature_*
12
+ - hotfix_*
13
+
14
+ pr:
15
+ autoCancel: true
16
+ branches:
17
+ include:
18
+ - ppe
19
+ - hotfix_*
20
+ - feature_*
21
+
22
+ resources:
23
+ - repo: self
24
+
25
+ variables:
26
+ - group: FC-ECMS
27
+ - name: tag
28
+ value: '$(Build.BuildId)'
29
+
30
+ stages:
31
+ - stage: Publish_npm_package
32
+ displayName: Publish npm package
33
+ jobs:
34
+ - job: Publish
35
+ displayName: Publish package
36
+ timeoutInMinutes: 10
37
+ cancelTimeoutInMinutes: 2
38
+ pool:
39
+ name: flcl-agent-1
40
+ steps:
41
+ - bash: |
42
+ npm install -g npm-cli-login
43
+ npm-cli-login -u $(npm_username) -p $(npm_password) -e $(npm_email) -r http://registry.npmjs.org/
44
+ npm run build
45
+ npm publish
package/dist/axios.js ADDED
@@ -0,0 +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;
30
+ //# sourceMappingURL=axios.js.map
@@ -0,0 +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"}
package/dist/core.js ADDED
@@ -0,0 +1,18 @@
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
+ exports.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
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";;;;;;AAAA,uCAA4C;AAE5C,oDAAsC;AACzB,QAAA,iBAAiB,GAAG,CAAC,MAAmB,EAAE,SAAqB,EAAE,aAAsB,EAAE,SAAkB,EAAE,EAAE;IACxH,kBAAG,CAAC,MAAM,GAAG,MAAM,IAAI,SAAS,CAAC;IACjC,kBAAG,CAAC,SAAS,GAAG,SAAS,IAAI,SAAS,CAAC;IACvC,kBAAG,CAAC,aAAa,GAAG,aAAa,IAAI,EAAE,CAAC;IACxC,kBAAG,CAAC,SAAS,GAAG,SAAS,IAAI,EAAE,CAAC;IAChC,kBAAG,CAAC,KAAK,GAAG,eAAe,CAAC;IAC5B,kBAAG,CAAC,QAAQ,GAAG,8CAA8C;QAC7D,kBAAG,CAAC,SAAS,GAAG,6CAA6C,CAAA;AACjE,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MyGlobal = void 0;
4
+ exports.MyGlobal = {};
5
+ //# sourceMappingURL=globals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globals.js","sourceRoot":"","sources":["../src/globals.ts"],"names":[],"mappings":";;;AAEW,QAAA,QAAQ,GAAoB,EAEtC,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var landmark_1 = require("./landmark");
4
+ Object.defineProperty(exports, "LandMark", { enumerable: true, get: function () { return landmark_1.LandMark; } });
5
+ //export default ECMS;
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,uCAAuC;AAA7B,oGAAA,QAAQ,OAAA;AAElB,sBAAsB"}
@@ -0,0 +1,72 @@
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, logger, flclerror, rootRequestId, requestId) {
22
+ this.username = username;
23
+ this.password = password;
24
+ core_1.setRequredGlobals(logger, flclerror, rootRequestId, requestId);
25
+ }
26
+ createShipmet(args) {
27
+ var _a, _b, _c, _d;
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ try {
30
+ let shipObj = new shipment_1.default();
31
+ (_a = globals_1.MyGlobal.logger) === null || _a === void 0 ? void 0 : _a.info({ npm: 'fc-landmark', className: 'Landmark', methodName: 'createShipmet', propertyName: 'WIZMOShipmentInput', propertyValue: args });
32
+ let landmarkShipmentRequest = shipObj.buildShipmentRequest(args, this.username, this.password);
33
+ (_b = globals_1.MyGlobal.logger) === null || _b === void 0 ? void 0 : _b.info({ npm: 'fc-landmark', className: 'Landmark', methodName: 'createShipmet', propertyName: 'WIZMOShipmentRequest', propertyValue: landmarkShipmentRequest });
34
+ let landmarkShipmentRes = yield shipObj.createShipment(landmarkShipmentRequest);
35
+ if (landmarkShipmentRes.hasOwnProperty("ImportResponse") && landmarkShipmentRes['ImportResponse']['Errors']) {
36
+ throw new Error(landmarkShipmentRes['ImportResponse']['Errors']['Error']['ErrorMessage']['_text']);
37
+ }
38
+ let response = shipObj.buildResponse(landmarkShipmentRes, args);
39
+ (_c = globals_1.MyGlobal.logger) === null || _c === void 0 ? void 0 : _c.info({ npm: 'fc-landmark', className: 'Landmark', methodName: 'createShipmet', propertyName: 'response', propertyValue: response });
40
+ return response;
41
+ }
42
+ catch (e) {
43
+ (_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: 'WIZMO_ERROR', cause: e, message: 'Exception while creating shipment in Landmark' }));
44
+ throw e;
45
+ }
46
+ });
47
+ }
48
+ getTrackingInfo(args) {
49
+ var _a, _b, _c, _d;
50
+ return __awaiter(this, void 0, void 0, function* () {
51
+ try {
52
+ let trackObj = new tracking_1.default();
53
+ (_a = globals_1.MyGlobal.logger) === null || _a === void 0 ? void 0 : _a.info({ npm: 'fc-landmark', className: 'Landmark', methodName: 'getTrackingInfo', propertyName: 'LandmarkInput', propertyValue: args });
54
+ let landmarkTrackRequest = trackObj.buildTrackingRequest(args, this.username, this.password);
55
+ (_b = globals_1.MyGlobal.logger) === null || _b === void 0 ? void 0 : _b.info({ npm: 'fc-landmark', className: 'Landmark', methodName: 'createShipmet', propertyName: 'LandmarkTrackRequest', propertyValue: landmarkTrackRequest });
56
+ let wizmoTrackingRes = yield trackObj.trackInfo(landmarkTrackRequest);
57
+ if (wizmoTrackingRes.hasOwnProperty("TrackResponse") && wizmoTrackingRes['TrackResponse']['Errors']) {
58
+ throw new Error(wizmoTrackingRes['TrackResponse']['Errors']['Error']['ErrorMessage']['_text']);
59
+ }
60
+ let response = trackObj.buildResponse(wizmoTrackingRes, args);
61
+ (_c = globals_1.MyGlobal.logger) === null || _c === void 0 ? void 0 : _c.info({ npm: 'fc-landmark', className: 'Landmark', methodName: 'createShipmet', propertyName: 'response', propertyValue: response });
62
+ return response;
63
+ }
64
+ catch (e) {
65
+ (_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: 'WIZMO_ERROR', cause: e, message: 'Exception while creating shipment in Landmark' }));
66
+ throw e;
67
+ }
68
+ });
69
+ }
70
+ }
71
+ exports.LandMark = LandMark;
72
+ //# sourceMappingURL=landmark.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"landmark.js","sourceRoot":"","sources":["../src/landmark.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0DAAkC;AAClC,0DAAkC;AAClC,iCAA2C;AAC3C,uCAA4C;AAG5C,MAAa,QAAQ;IAGjB,YAAY,QAAe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C,CAAC;gBAC3E,IAAG,gBAAgB,CAAC,cAAc,CAAC,eAAe,CAAC,IAAI,gBAAgB,CAAC,eAAe,CAAC,CAAC,QAAQ,CAAC,EAAC;oBAC/F,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC,CAAG;iBACpG;gBACD,IAAI,QAAQ,GAAiC,QAAQ,CAAC,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;gBAC5F,MAAA,kBAAG,CAAC,MAAM,0CAAE,IAAI,CAAC,EAAC,GAAG,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAC,EAAE;gBAC9I,OAAO,QAAQ,CAAC;aACnB;YAAC,OAAM,CAAC,EAAE;gBACP,MAAA,kBAAG,CAAC,MAAM,0CAAE,KAAK,CAAC,kBAAG,CAAC,SAAU,CAAC,MAAM,CAAC,EAAC,GAAG,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,+CAA+C,EAAC,CAAC,EAAE;gBACpN,MAAM,CAAC,CAAC;aACX;;KACJ;CACJ;AAhDD,4BAgDC"}
@@ -0,0 +1,147 @@
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(dataIn) {
18
+ const combinedAddress = dataIn.shipto_address.address_line_1 + dataIn.shipto_address.address_line_2 + dataIn.shipto_address.address_line_3;
19
+ let consignee = {
20
+ "Name": dataIn.shipto_address.name.slice(0, 50),
21
+ "Attention": dataIn.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": dataIn.shipto_address.city,
26
+ "State": dataIn.shipto_address.state,
27
+ "PostalCode": dataIn.shipto_address.zip,
28
+ "Country": dataIn.targetToCountry ? dataIn.targetToCountry : dataIn.shipto_address.country,
29
+ "Phone": dataIn.shipto_address.phone.toString(),
30
+ "Email": dataIn.shipto_address.email,
31
+ "ConsigneeTaxID": dataIn.shipto_address.federal_tax_id ? dataIn.shipto_address.federal_tax_id : ""
32
+ };
33
+ return consignee;
34
+ }
35
+ getShipperInfo(dataIn) {
36
+ const combinedAddress = dataIn.shipfrom_address.address_line_1 + dataIn.shipfrom_address.address_line_2 + dataIn.shipfrom_address.address_line_3;
37
+ let shipper = {
38
+ "Name": dataIn.shipfrom_address.name.slice(0, 50),
39
+ "Attention": dataIn.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": dataIn.shipfrom_address.city,
44
+ "State": dataIn.shipfrom_address.state,
45
+ "PostalCode": dataIn.shipfrom_address.zip,
46
+ "Country": dataIn.targetToCountry ? dataIn.targetToCountry : dataIn.shipfrom_address.country,
47
+ "Phone": dataIn.shipfrom_address.phone.toString(),
48
+ "Email": dataIn.shipfrom_address.email
49
+ };
50
+ return shipper;
51
+ }
52
+ buildShipmentRequest(args, username, password) {
53
+ try {
54
+ let importRequest = {
55
+ "Login": {
56
+ "Username": username,
57
+ "Password": password
58
+ },
59
+ "Test": true,
60
+ "ClientID": 2056,
61
+ "Reference": args.reference,
62
+ "ShipTo": this.getConsignee(args),
63
+ "ShippingLane": {
64
+ "Region": "Landmark BUF"
65
+ },
66
+ "ShipMethod": args._carrierRateObj.termsoftrade.toLowerCase() == "ddp" ? "LGINTSTD" : "LGINTSTDU",
67
+ "OrderTotal": args.shipment_total_usd,
68
+ "ItemsCurrency": args.currency,
69
+ "ProduceLabel": true,
70
+ "LabelFormat": args.label_format,
71
+ "LabelEncoding": args.label_format.toLowerCase() == "zpl" ? "ZPL" : "LINKS",
72
+ "Packages": {
73
+ "Package": {
74
+ "WeightUnit": args.weight_unit,
75
+ "Weight": args.package.weight,
76
+ "DimensionsUnit": args.dimension_unit,
77
+ "Length": args.package.length,
78
+ "Width": args.package.width,
79
+ "Height": args.package.height,
80
+ "PackageReference": args.reference
81
+ }
82
+ },
83
+ "SendReturnToAddress": this.getShipperInfo(args),
84
+ "IsCommercialShipment": args.b2b ? 1 : 0,
85
+ };
86
+ let items = args.pieces.map((item) => {
87
+ return { "Item": {
88
+ "Sku": item.sku,
89
+ "Description": item.description.substr(0, 100),
90
+ "Quantity": item.quantity,
91
+ "UnitPrice": (item.sale_price == 0) ? 0.01 : item.sale_price,
92
+ "HSCode": item.hs_code,
93
+ "CountryOfOrigin": item.origin_country_code
94
+ }
95
+ };
96
+ });
97
+ importRequest["Items"] = items;
98
+ let request = {
99
+ "ImportRequest": importRequest
100
+ };
101
+ const xmlData = xml_js_1.js2xml(request, { compact: true, ignoreComment: true, spaces: 4 });
102
+ return xmlData;
103
+ }
104
+ catch (e) {
105
+ throw globals_1.MyGlobal.FlclError.create({ className: 'Shipment', methodName: '_buildRequest', message: 'Exception while building the LandMark shipment request', cause: e, appendChildMsg: true });
106
+ }
107
+ }
108
+ createShipment(ShipmentRequest) {
109
+ var _a, _b, _c;
110
+ return __awaiter(this, void 0, void 0, function* () {
111
+ try {
112
+ let configs = {
113
+ headers: {
114
+ 'Content-Type': 'application/xml'
115
+ }
116
+ };
117
+ let resp = yield globals_1.MyGlobal.axios.post(globals_1.MyGlobal.ship_url, ShipmentRequest, configs);
118
+ console.log(resp.data);
119
+ (_a = globals_1.MyGlobal.logger) === null || _a === void 0 ? void 0 : _a.info({ npm: 'fc-landmark', className: 'WIZMO', methodName: 'createShipmet', propertyName: 'WIZMO-RAW-RESPOSNE', propertyValue: resp.data });
120
+ let responsejson = xml_js_1.xml2json(resp.data, { compact: true, spaces: 4 });
121
+ return JSON.parse(responsejson);
122
+ }
123
+ catch (e) {
124
+ (_b = globals_1.MyGlobal.logger) === null || _b === void 0 ? void 0 : _b.info({ npm: 'fc-landmark', className: 'WIZMO', methodName: 'createShipmet', propertyName: 'WIZMO-RAW-RESPOSNE', data: { error: e } });
125
+ (_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 }));
126
+ throw e;
127
+ }
128
+ });
129
+ }
130
+ buildResponse(resp, args) {
131
+ let response = {
132
+ provider_name: 'Landmark',
133
+ shipping_provider: 'Landmark',
134
+ carrier: 'Landmark',
135
+ tracking_number: resp['ImportResponse']['Result']['Packages']['Package']['TrackingNumber']['_text'],
136
+ provider_tracking_number: resp['ImportResponse']['Result']['Packages']['Package']['TrackingNumber']['_text'],
137
+ shipping_label: resp['ImportResponse']['Result']['ShipmentLabelLink']['_text'],
138
+ label_type: args.label_format,
139
+ gross_weight: args.total_weight,
140
+ gross_weight_unit: args.weight_unit,
141
+ submitted_electronically: false
142
+ };
143
+ return response;
144
+ }
145
+ }
146
+ exports.default = Shipment;
147
+ //# sourceMappingURL=shipment.js.map
@@ -0,0 +1 @@
1
+ {"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CAAC,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC;YAC5G,cAAc,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,CAAC,mBAAmB,CAAC,CAAC,OAAO,CAAC;YAC9E,UAAU,EAAE,IAAI,CAAC,YAAY;YAC7B,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,iBAAiB,EAAE,IAAI,CAAC,WAAW;YACnC,wBAAwB,EAAE,KAAK;SAClC,CAAC;QACF,OAAO,QAAQ,CAAC;IACpB,CAAC;CAEJ;AApID,2BAoIC"}
@@ -0,0 +1,90 @@
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) {
18
+ try {
19
+ let trackRequest = {
20
+ "Login": {
21
+ "Username": username,
22
+ "Password": password
23
+ },
24
+ "Test": true,
25
+ "ClientID": 2056,
26
+ "TrackingNumber": args.tracking_number,
27
+ "RetrievalType": "Historical"
28
+ };
29
+ let request = {
30
+ "TrackRequest": trackRequest
31
+ };
32
+ const xmlData = 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 = 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
+ for (let i = 0; i < resp['TrackResponse']['Result']['Packages']['Package']['Events']['Event'].length; i++) {
67
+ let history = {};
68
+ let code = resp['TrackResponse']['Result']['Packages']['Package']['Events']['Event'][i]['EventCode']['_text'];
69
+ if (code == '50' || code == '60') {
70
+ history.status = "In Progress";
71
+ }
72
+ else if (code == '500') {
73
+ history.status = "Delivered";
74
+ }
75
+ else {
76
+ history.status = "In Transit";
77
+ }
78
+ history.status_date = resp['TrackResponse']['Result']['Packages']['Package']['Events']['Event'][i]['DateTime']['_text'];
79
+ let dateofevent = new Date(history.status_date);
80
+ history.event_date = dateofevent.getTime();
81
+ history.status_detail = resp['TrackResponse']['Result']['Packages']['Package']['Events']['Event'][i]['Status']['_text'] || "";
82
+ history.location = resp['TrackResponse']['Result']['Packages']['Package']['Events']['Event'][i]['Location']['_text'] || '';
83
+ history.country = '';
84
+ response.tracking_history.push(history);
85
+ }
86
+ return response;
87
+ }
88
+ }
89
+ exports.default = Tracking;
90
+ //# sourceMappingURL=tracking.js.map
@@ -0,0 +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;QAC5D,IAAI;YACA,IAAI,YAAY,GAAQ;gBACpB,OAAO,EAAE;oBACL,UAAU,EAAE,QAAQ;oBACpB,UAAU,EAAE,QAAQ;iBACvB;gBACD,MAAM,EAAE,IAAI;gBACZ,UAAU,EAAE,IAAI;gBAChB,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,eAAM,CAAC,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,KAAK,EAAE,CAAC,EAAE,cAAc,EAAE,IAAI,EAAC,CAAC,CAAC;SACxL;IACL,CAAC;IAGK,SAAS,CAAC,eAAuB;;;YACn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C,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;SAC3C;QACL,OAAO,QAAQ,CAAC;IAChB,CAAC;CACJ;AA3ED,2BA2EC"}
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "fc-landmark",
3
+ "version": "1.0.0",
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": "^1.0.3",
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": "^3.9.10"
30
+ }
31
+ }
package/src/axios.ts ADDED
@@ -0,0 +1,29 @@
1
+ import axios from 'axios';
2
+ import { FlclAxiosMiddleware, ValidObject } from './types';
3
+ import { MyGlobal as app } from './globals';
4
+
5
+
6
+ const injectRequestId = (data?: ValidObject) => {
7
+ if(data) {
8
+ data.requestId = app.requestId;
9
+ data.rootRequestId = app.rootRequestId;
10
+ }
11
+ return data;
12
+ }
13
+
14
+ let axiosMiddleware: FlclAxiosMiddleware = {
15
+ get: (urlPath: string, configs?: ValidObject) => {
16
+ return axios.get(urlPath, configs);
17
+ },
18
+ put: (urlPath: string, data?: ValidObject, configs?: ValidObject) => {
19
+ return axios.put(urlPath, data, configs);
20
+ },
21
+ post: (urlPath: string, data?: ValidObject, configs?: ValidObject) => {
22
+ return axios.post(urlPath, data, configs);
23
+ },
24
+ delete: (urlPath: string, configs?: ValidObject) => {
25
+ return axios.delete(urlPath, configs);
26
+ },
27
+ }
28
+
29
+ export default axiosMiddleware;
package/src/core.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { MyGlobal as app } from './globals';
2
+ import { FlclLogger, FlclError } from "fc-logger";
3
+ import axiosMiddleware from './axios';
4
+ export const setRequredGlobals = (logger?: FlclLogger, flclerror?: FlclError, rootRequestId?: string, requestId?: string) => {
5
+ app.logger = logger || undefined;
6
+ app.flclError = flclerror || undefined;
7
+ app.rootRequestId = rootRequestId || '';
8
+ app.requestId = requestId || '';
9
+ app.axios = axiosMiddleware;
10
+ app.ship_url = "https://api.landmarkglobal.com/v2/Import.php",
11
+ app.track_url = "https://api.landmarkglobal.com/v2/Track.php"
12
+ }
package/src/globals.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { AppObj } from './types';
2
+
3
+ export var MyGlobal: Partial<AppObj> = {
4
+
5
+ };
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { LandMark } from './landmark';
2
+
3
+ //export default ECMS;
@@ -0,0 +1,56 @@
1
+ import Shipment from './shipment';
2
+ import Tracking from './tracking';
3
+ import { setRequredGlobals } from './core';
4
+ import { MyGlobal as app } from './globals';
5
+ import {FlavorcloudShipmentResponse, FlavorcloudTrackingResponse} from './types';
6
+ import { FlclLogger, FlclError } from "fc-logger";
7
+ export class LandMark {
8
+ private username : string;
9
+ private password : string;
10
+ constructor(username:string,password:string, logger?: FlclLogger, flclerror?: FlclError, rootRequestId?: string, requestId?: string) {
11
+ this.username = username;
12
+ this.password = password;
13
+ setRequredGlobals(logger, flclerror, rootRequestId, requestId);
14
+ }
15
+
16
+ async createShipmet(args: any) {
17
+ try {
18
+
19
+ let shipObj = new Shipment();
20
+ app.logger?.info({npm: 'fc-landmark', className: 'Landmark', methodName: 'createShipmet', propertyName: 'WIZMOShipmentInput', propertyValue: args});
21
+ let landmarkShipmentRequest: string = shipObj.buildShipmentRequest(args,this.username,this.password);
22
+ app.logger?.info({npm: 'fc-landmark', className: 'Landmark', methodName: 'createShipmet', propertyName: 'WIZMOShipmentRequest', propertyValue: landmarkShipmentRequest});
23
+ let landmarkShipmentRes: any = await shipObj.createShipment(landmarkShipmentRequest);
24
+ if(landmarkShipmentRes.hasOwnProperty("ImportResponse") && landmarkShipmentRes['ImportResponse']['Errors']){
25
+ throw new Error(landmarkShipmentRes['ImportResponse']['Errors']['Error']['ErrorMessage']['_text']) ;
26
+ }
27
+ let response: FlavorcloudShipmentResponse = shipObj.buildResponse(landmarkShipmentRes, args);
28
+ app.logger?.info({npm: 'fc-landmark', className: 'Landmark', methodName: 'createShipmet', propertyName: 'response', propertyValue: response});
29
+ return response;
30
+ } catch(e) {
31
+ app.logger?.error(app.flclError!.create({npm: 'fc-landmark', className: 'Landmark', methodName: 'createShipmet', propertyName: 'WIZMO_ERROR', cause: e, message: 'Exception while creating shipment in Landmark'}));
32
+ throw e;
33
+ }
34
+ }
35
+
36
+ async getTrackingInfo(args: any) {
37
+ try {
38
+
39
+ let trackObj = new Tracking();
40
+ app.logger?.info({npm: 'fc-landmark', className: 'Landmark', methodName: 'getTrackingInfo', propertyName: 'LandmarkInput', propertyValue: args});
41
+ let landmarkTrackRequest: string = trackObj.buildTrackingRequest(args,this.username,this.password);
42
+ app.logger?.info({npm: 'fc-landmark', className: 'Landmark', methodName: 'createShipmet', propertyName: 'LandmarkTrackRequest', propertyValue: landmarkTrackRequest});
43
+ let wizmoTrackingRes: any = await trackObj.trackInfo(landmarkTrackRequest);
44
+ if(wizmoTrackingRes.hasOwnProperty("TrackResponse") && wizmoTrackingRes['TrackResponse']['Errors']){
45
+ throw new Error(wizmoTrackingRes['TrackResponse']['Errors']['Error']['ErrorMessage']['_text']) ;
46
+ }
47
+ let response: FlavorcloudTrackingResponse = trackObj.buildResponse(wizmoTrackingRes, args);
48
+ app.logger?.info({npm: 'fc-landmark', className: 'Landmark', methodName: 'createShipmet', propertyName: 'response', propertyValue: response});
49
+ return response;
50
+ } catch(e) {
51
+ app.logger?.error(app.flclError!.create({npm: 'fc-landmark', className: 'Landmark', methodName: 'createShipmet', propertyName: 'WIZMO_ERROR', cause: e, message: 'Exception while creating shipment in Landmark'}));
52
+ throw e;
53
+ }
54
+ }
55
+ }
56
+
@@ -0,0 +1,137 @@
1
+ import { FlavorcloudShipmentResponse } from "./types";
2
+ import { MyGlobal as app } from './globals';
3
+ import { js2xml , xml2json} from 'xml-js';
4
+
5
+ export default class Shipment {
6
+ constructor() {
7
+
8
+ }
9
+ getConsignee(dataIn: any): any {
10
+
11
+ const combinedAddress = dataIn.shipto_address.address_line_1 + dataIn.shipto_address.address_line_2 + dataIn.shipto_address.address_line_3;
12
+ let consignee: any = {
13
+ "Name": dataIn.shipto_address.name.slice(0, 50) ,
14
+ "Attention": dataIn.shipto_address.attention_name.slice(0, 50) ,
15
+ "Address1": combinedAddress.substring(0,60),
16
+ "Address2": combinedAddress.substring(61,120),
17
+ "Address3": combinedAddress.substring(121,180),
18
+ "City": dataIn.shipto_address.city,
19
+ "State": dataIn.shipto_address.state,
20
+ "PostalCode": dataIn.shipto_address.zip,
21
+ "Country": dataIn.targetToCountry ? dataIn.targetToCountry : dataIn.shipto_address.country,
22
+ "Phone": dataIn.shipto_address.phone.toString(),
23
+ "Email": dataIn.shipto_address.email,
24
+ "ConsigneeTaxID": dataIn.shipto_address.federal_tax_id ? dataIn.shipto_address.federal_tax_id : ""
25
+ };
26
+ return consignee;
27
+ }
28
+
29
+ getShipperInfo(dataIn: any) {
30
+ const combinedAddress = dataIn.shipfrom_address.address_line_1 + dataIn.shipfrom_address.address_line_2 + dataIn.shipfrom_address.address_line_3;
31
+ let shipper: any = {
32
+ "Name": dataIn.shipfrom_address.name.slice(0, 50) ,
33
+ "Attention": dataIn.shipfrom_address.attention_name.slice(0, 50) ,
34
+ "Address1": combinedAddress.substring(0,60),
35
+ "Address2": combinedAddress.substring(61,120),
36
+ "Address3": combinedAddress.substring(121,180),
37
+ "City": dataIn.shipfrom_address.city,
38
+ "State": dataIn.shipfrom_address.state,
39
+ "PostalCode": dataIn.shipfrom_address.zip,
40
+ "Country": dataIn.targetToCountry ? dataIn.targetToCountry : dataIn.shipfrom_address.country,
41
+ "Phone": dataIn.shipfrom_address.phone.toString(),
42
+ "Email": dataIn.shipfrom_address.email
43
+ };
44
+ return shipper;
45
+ }
46
+ buildShipmentRequest(args: any,username:string,password:string): string{
47
+ try {
48
+ let importRequest :any = {
49
+ "Login": {
50
+ "Username": username,
51
+ "Password": password
52
+ },
53
+ "Test": true,
54
+ "ClientID": 2056 ,
55
+ "Reference": args.reference,
56
+ "ShipTo": this.getConsignee( args),
57
+ "ShippingLane": {
58
+ "Region" : "Landmark BUF"
59
+ },
60
+ "ShipMethod": args._carrierRateObj.termsoftrade.toLowerCase() == "ddp" ? "LGINTSTD" : "LGINTSTDU",
61
+ "OrderTotal": args.shipment_total_usd,
62
+ "ItemsCurrency": args.currency,
63
+ "ProduceLabel": true,
64
+ "LabelFormat": args.label_format,
65
+ "LabelEncoding": args.label_format.toLowerCase() == "zpl" ? "ZPL" : "LINKS" ,
66
+ "Packages":{
67
+ "Package": {
68
+ "WeightUnit":args.weight_unit,
69
+ "Weight":args.package.weight,
70
+ "DimensionsUnit":args.dimension_unit,
71
+ "Length":args.package.length,
72
+ "Width":args.package.width,
73
+ "Height":args.package.height,
74
+ "PackageReference":args.reference
75
+ }
76
+ },
77
+ "SendReturnToAddress": this.getShipperInfo(args),
78
+ "IsCommercialShipment": args.b2b ? 1 : 0,
79
+ }
80
+ let items = args.pieces.map((item:any)=>{
81
+ return {"Item":{
82
+ "Sku": item.sku,
83
+ "Description": item.description.substr(0,100),
84
+ "Quantity": item.quantity,
85
+ "UnitPrice": (item.sale_price == 0) ? 0.01 : item.sale_price,
86
+ "HSCode": item.hs_code,
87
+ "CountryOfOrigin": item.origin_country_code
88
+ }
89
+ }
90
+ })
91
+ importRequest["Items"] = items
92
+ let request :any = {
93
+ "ImportRequest": importRequest
94
+ }
95
+ const xmlData = js2xml(request, { compact: true, ignoreComment: true, spaces: 4 });
96
+ return xmlData;
97
+ } catch(e) {
98
+ throw app.FlclError!.create({className: 'Shipment', methodName: '_buildRequest', message: 'Exception while building the LandMark shipment request', cause: e, appendChildMsg: true});
99
+ }
100
+ }
101
+
102
+ async createShipment(ShipmentRequest: string): Promise<any> {
103
+ try {
104
+ let configs = {
105
+ headers: {
106
+ 'Content-Type' : 'application/xml'
107
+ }
108
+ };
109
+ let resp = await app.axios!.post(app.ship_url, ShipmentRequest, configs);
110
+ console.log(resp.data)
111
+ app.logger?.info({npm: 'fc-landmark', className: 'WIZMO', methodName: 'createShipmet', propertyName: 'WIZMO-RAW-RESPOSNE', propertyValue: resp.data});
112
+ let responsejson= xml2json(resp.data,{compact: true, spaces: 4}) ;
113
+ return JSON.parse(responsejson) ;
114
+ } catch(e) {
115
+ app.logger?.info({npm: 'fc-landmark', className: 'WIZMO', methodName: 'createShipmet', propertyName: 'WIZMO-RAW-RESPOSNE', data: {error: e}});
116
+ app.logger?.error(app.flclError!.create({npm: 'fc-landmark', className: 'Shipment', methodName: 'createShipment', propertyName: 'CREDITS_ERROR', cause: e}));
117
+ throw e;
118
+ }
119
+ }
120
+
121
+ buildResponse(resp: any, args: any): FlavorcloudShipmentResponse{
122
+ let response: FlavorcloudShipmentResponse = {
123
+ provider_name: 'Landmark',
124
+ shipping_provider: 'Landmark',
125
+ carrier : 'Landmark',
126
+ tracking_number: resp['ImportResponse']['Result']['Packages']['Package']['TrackingNumber']['_text'],
127
+ provider_tracking_number: resp['ImportResponse']['Result']['Packages']['Package']['TrackingNumber']['_text'],
128
+ shipping_label: resp['ImportResponse']['Result']['ShipmentLabelLink']['_text'],
129
+ label_type: args.label_format,
130
+ gross_weight: args.total_weight,
131
+ gross_weight_unit: args.weight_unit,
132
+ submitted_electronically: false
133
+ };
134
+ return response;
135
+ }
136
+
137
+ }
@@ -0,0 +1,80 @@
1
+ import { FlavorcloudTrackingResponse} from "./types";
2
+ import { MyGlobal as app } from './globals';
3
+ import { js2xml , xml2json} from 'xml-js';
4
+
5
+ export default class Tracking {
6
+ constructor() {
7
+
8
+ }
9
+
10
+ buildTrackingRequest(args: any,username: string,password: string): string{
11
+ try {
12
+ let trackRequest :any = {
13
+ "Login": {
14
+ "Username": username,
15
+ "Password": password
16
+ },
17
+ "Test": true,
18
+ "ClientID": 2056 ,
19
+ "TrackingNumber": args.tracking_number,
20
+ "RetrievalType":"Historical"
21
+
22
+ };
23
+ let request :any = {
24
+ "TrackRequest": trackRequest
25
+ }
26
+ const xmlData = js2xml(request, { compact: true, ignoreComment: true, spaces: 4 });
27
+ return xmlData;
28
+ } catch(e) {
29
+ throw app.FlclError!.create({className: 'Tracking', methodName: '_buildRequest', message: 'Exception while building the LandMark Tracking request', cause: e, appendChildMsg: true});
30
+ }
31
+ }
32
+
33
+
34
+ async trackInfo(ShipmentRequest: string): Promise<any> {
35
+ try {
36
+ let configs = {
37
+ headers: {
38
+ 'Content-Type' : 'application/xml'
39
+ }
40
+ };
41
+ let resp = await app.axios!.post(app.track_url, ShipmentRequest, configs);
42
+ app.logger?.info({npm: 'fc-landmark', className: 'Tracking', methodName: 'trackInfo', propertyName: 'landmark-RAW-RESPOSNE', propertyValue: resp.data});
43
+ let responsejson= xml2json(resp.data,{compact: true, spaces: 4}) ;
44
+ return JSON.parse(responsejson) ;
45
+ } catch(e) {
46
+ app.logger?.info({npm: 'fc-landmark', className: 'Tracking', methodName: 'trackInfo', propertyName: 'landmar-RAW-RESPOSNE', data: {error: e}});
47
+ app.logger?.error(app.flclError!.create({npm: 'fc-landmark', className: 'Tracking', methodName: 'trackInfo', propertyName: 'CREDITS_ERROR', cause: e}));
48
+ throw e;
49
+ }
50
+ }
51
+
52
+ buildResponse(resp: any, args: any): FlavorcloudTrackingResponse{
53
+ let response: FlavorcloudTrackingResponse = {
54
+ reference: args.reference,
55
+ tracking_number: args.tracking_number,
56
+ tracking_history : []
57
+ };
58
+ for(let i = 0; i < resp['TrackResponse']['Result']['Packages']['Package']['Events']['Event'].length; i++){
59
+ let history: any = {};
60
+ let code :any = resp['TrackResponse']['Result']['Packages']['Package']['Events']['Event'][i]['EventCode']['_text'] ;
61
+ if(code == '50' || code == '60' ){
62
+ history.status = "In Progress";
63
+ }
64
+ else if(code == '500'){
65
+ history.status = "Delivered";
66
+ }
67
+ else{
68
+ history.status = "In Transit";
69
+ }
70
+ history.status_date = resp['TrackResponse']['Result']['Packages']['Package']['Events']['Event'][i]['DateTime']['_text'];
71
+ let dateofevent = new Date(history.status_date);
72
+ history.event_date = dateofevent.getTime();
73
+ history.status_detail = resp['TrackResponse']['Result']['Packages']['Package']['Events']['Event'][i]['Status']['_text']|| "";
74
+ history.location = resp['TrackResponse']['Result']['Packages']['Package']['Events']['Event'][i]['Location']['_text'] || '';
75
+ history.country = '';
76
+ response.tracking_history.push(history);
77
+ }
78
+ return response;
79
+ }
80
+ }
package/src/types.ts ADDED
@@ -0,0 +1,102 @@
1
+ import { FlclLogger, FlclError } from "fc-logger";
2
+
3
+
4
+
5
+ export interface AppObj {
6
+ logger?: FlclLogger,
7
+ FlclError?: typeof FlclError,
8
+ [x: string]: any
9
+ }
10
+ export interface credentials {
11
+ token?: string
12
+ }
13
+
14
+ export interface FlclAxiosMiddleware {
15
+ get: Function,
16
+ put: Function,
17
+ post: Function,
18
+ delete: Function,
19
+ }
20
+ export interface ValidObject {
21
+ [x: string]: string | number | boolean | object | [] | any
22
+ }
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+ export interface WIZMOShipmentRespone {
33
+ shipmentresponse : ShipmentRespone
34
+ }
35
+
36
+ export interface ShipmentRespone{
37
+ tracknbr : string,
38
+ label : string,
39
+ labelformat : string
40
+ }
41
+
42
+
43
+
44
+
45
+ export interface FlavorcloudShipmentResponse {
46
+
47
+ master_tracking_id?: any;
48
+
49
+ provider_name?: string,
50
+
51
+ shipping_provider: string,
52
+
53
+ carrier? : string,
54
+
55
+ tracking_number: number | string,
56
+
57
+ tracking_number_multi?: Array<string>,
58
+
59
+ provider_tracking_number?: number | string,
60
+
61
+ tracking_url?: string,
62
+
63
+ shipping_label: string,
64
+
65
+ shipping_label_multi?: Array<string>,
66
+
67
+ label_type: string,
68
+
69
+ gross_weight: number,
70
+
71
+ gross_weight_unit: string,
72
+
73
+ easyPostReferenceId?: string,
74
+
75
+ ecourierzReferenceId?: string,
76
+
77
+ submitted_electronically?: boolean,
78
+
79
+ formUrl?: string | null,
80
+
81
+ fims_parcel_id?: number | string,
82
+
83
+ customsInvoiceData?: any,
84
+
85
+ form_id?: any
86
+
87
+ }
88
+
89
+ export interface WIZMOTrackingRequest {
90
+ tracking: TrackingRequest
91
+ }
92
+ export interface TrackingRequest {
93
+ tracknbr: string
94
+ }
95
+
96
+ export interface WIZMOTrackingResponse {
97
+ [x: string]: any;
98
+ }
99
+
100
+ export interface FlavorcloudTrackingResponse{
101
+ [x: string]: any;
102
+ }
@@ -0,0 +1,166 @@
1
+ let LandMark = require("../dist/index").LandMark;
2
+ let request = {
3
+ "reference": "257038-SEVEN",
4
+ "service_code": "Wizmo DHL Parcel Plus Grd",
5
+ "carrier_service_code": "Wizmo DHL Parcel Plus Grd",
6
+ "label_format": "PDF",
7
+ "weight_unit": "KG",
8
+ "currency": "USD",
9
+ "dimension_unit": "CM",
10
+ "insurance": "N",
11
+ "terms_of_trade": "ddu",
12
+ "_carrierRateObj": {
13
+ "carrier": "landmark",
14
+ "flclservicecode": "express",
15
+ "servicecode": "P",
16
+ "termsoftrade": "ddu",
17
+ "landedCostId": "",
18
+ "carrierrateid": 21513625
19
+ },
20
+ "shipfrom_address": {
21
+ "name": "ABC Company",
22
+ "attention_name": "Robert Dobolina",
23
+ "address_line_1": "123 Main Street",
24
+ "address_line_2": "Apartment 123",
25
+ "address_line_3": "",
26
+ "city": "San Francisco",
27
+ "state": "CA",
28
+ "country": "US",
29
+ "zip": "94107",
30
+ "phone": "212 234 1400",
31
+ "email": "support@landmark.com",
32
+ "federal_tax_id": "",
33
+ "state_tax_id": ""
34
+
35
+ },
36
+ "shipto_address": {
37
+ "name": "Eiffel Tower",
38
+ "attention_name": "Robert Dobolina",
39
+ "address_line_1": "Champ de Mars",
40
+ "address_line_2": "11 Derby Road",
41
+ "address_line_3": "",
42
+ "city": "Richmond",
43
+ "state": "BC",
44
+ "country": "CA",
45
+ "zip": "V7A 2Z5",
46
+ "phone": "212 234 1400",
47
+ "email": "support@landmark.com",
48
+ "federal_tax_id": "",
49
+ "state_tax_id": ""
50
+ },
51
+ "pieces": [{
52
+ "quantity": 1,
53
+ "weight": 0.5,
54
+ "length": 0,
55
+ "width": 0,
56
+ "height": 0,
57
+ "sale_price": 26.99,
58
+ "hs_code": "6211429000",
59
+ "origin_country_code": "US",
60
+ "material": "To The Person Reading This TShirt L",
61
+ "description": "To The Person Reading This TShirt L",
62
+ "sku": "761062883269",
63
+ "category": ["To The Person Reading This T-Shirt L"],
64
+ "line_item_id": "",
65
+ "product_id": "",
66
+ "variant_id": "",
67
+ "sale_price_usd": "26.99",
68
+ "hs_code_real": "621142",
69
+ "update": true,
70
+ "hs_code_10": "6211429000",
71
+ "origin_country_name": "United States"
72
+ }, {
73
+ "quantity": 1,
74
+ "weight": 0.4,
75
+ "length": 0,
76
+ "width": 5,
77
+ "height": 7.75,
78
+ "sale_price": 15,
79
+ "hs_code": "4901990000",
80
+ "origin_country_code": "US",
81
+ "material": "Beyond Worhty",
82
+ "description": "Beyond Worhty",
83
+ "sku": "9781949759174",
84
+ "category": ["Beyond Worhty"],
85
+ "line_item_id": "",
86
+ "product_id": "",
87
+ "variant_id": "",
88
+ "sale_price_usd": "15.00",
89
+ "hs_code_real": "490199",
90
+ "update": true,
91
+ "hs_code_10": "4901990000",
92
+ "origin_country_name": "United States"
93
+ }, {
94
+ "quantity": 1,
95
+ "weight": 1.15,
96
+ "length": 0,
97
+ "width": 0,
98
+ "height": 0,
99
+ "sale_price": 22,
100
+ "hs_code": "6211429000",
101
+ "origin_country_code": "US",
102
+ "material": "Feel Your Feelings Hoodie L",
103
+ "description": "Feel Your Feelings Hoodie L",
104
+ "sku": "745557711596",
105
+ "category": ["Feel Your Feelings Hoodie L"],
106
+ "line_item_id": "",
107
+ "product_id": "",
108
+ "variant_id": "",
109
+ "sale_price_usd": "22.00",
110
+ "hs_code_real": "621142",
111
+ "update": true,
112
+ "hs_code_10": "6211429000",
113
+ "origin_country_name": "United States"
114
+ }],
115
+ "package": {
116
+ "length": 8,
117
+ "width": 6,
118
+ "height": 1,
119
+ "weight": 2.7199999999999998,
120
+ "customer_surcharge": "",
121
+ "customer_surcharge_type": "",
122
+ "weight_correction_value": 0,
123
+ "defaultName": "International Shipments",
124
+ "defaultCompanyName": "Thought Catalog",
125
+ "defaultPhoneNumber": "405-919-0068",
126
+ "defaultEmail": "noelle@thoughtcatalog.com",
127
+ "defaultTermsOfTrade": "DDP",
128
+ "defaultServiceCode": "EXPRESS",
129
+ "labelFormat": "PDF",
130
+ "total_weight": null
131
+ },
132
+ "shipment_total": 63.989999999999995,
133
+ "invoice_date": "2018-01-01 01:01:01",
134
+ "total_weight": 1.8,
135
+ "rate_api_shiping_usd": 63.99,
136
+ "rate_api_shiping": 63.99,
137
+ "rate_api_duty_usd": "15.00",
138
+ "rate_api_duty": 15,
139
+ "service_code_flcl": "standard",
140
+ "reason_for_export": 'commercial'
141
+ };
142
+ async function create(){
143
+ try{
144
+ console.log('sampel gift');
145
+
146
+ let landmark = new LandMark('demoapi','demo123','','','','');
147
+ let res = await landmark.createShipmet(request);
148
+ console.log(res);
149
+ return res;
150
+
151
+ }catch(err){
152
+ console.log('ERR-1', err)
153
+ throw err;
154
+ }
155
+ }
156
+
157
+
158
+ try{
159
+ create().then(function(res){
160
+ console.log(res)
161
+ }).catch(function(err){
162
+ console.log('ERR-2',err)
163
+ })
164
+ }catch(err){
165
+ console.log('ERR-3',err)
166
+ }
@@ -0,0 +1,32 @@
1
+
2
+ let LandMark = require("../dist/index").LandMark;
3
+
4
+ let request = {
5
+ "reference" : "LTN123121",
6
+ "tracking_number": "LTN123121"
7
+ };
8
+ async function create(){
9
+ try{
10
+ console.log('sampel gift');
11
+
12
+ let landmark = new LandMark('demoapi','demo123','','','','');
13
+ let res = await landmark.getTrackingInfo(request);
14
+ console.log(res);
15
+ return res;
16
+
17
+ }catch(err){
18
+ console.log('ERR-1', err)
19
+ throw err;
20
+ }
21
+ }
22
+
23
+
24
+ try{
25
+ create().then(function(res){
26
+ //console.log(res)
27
+ }).catch(function(err){
28
+ console.log('ERR-2',err)
29
+ })
30
+ }catch(err){
31
+ console.log('ERR-3',err)
32
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es6",
4
+ "module": "commonjs",
5
+ "sourceMap": true,
6
+ "outDir": "./dist",
7
+ "rootDir": "./src",
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "forceConsistentCasingInFileNames": true
11
+ }
12
+ }