@artaio/arta-browser 2.19.0 → 2.19.1
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/ModalStatus.js +3 -4
- package/dist/arta.js +26 -39
- package/dist/bundle.js +1 -1
- package/dist/components/Date/SimpleDate.js +11 -11
- package/dist/components/Date/index.js +13 -13
- package/dist/components/Destination/countriesWithoutPostalCode.js +5 -4
- package/dist/components/Destination/index.js +20 -25
- package/dist/components/Disqualified/index.js +15 -14
- package/dist/components/DrawerFooter/index.js +7 -6
- package/dist/components/DrawerHeader/index.js +8 -8
- package/dist/components/DrawerInsurance/index.js +7 -6
- package/dist/components/Footer/index.js +7 -7
- package/dist/components/Header/index.js +7 -7
- package/dist/components/Invalidated/index.js +7 -7
- package/dist/components/Loading/index.js +7 -6
- package/dist/components/Modal/index.css.js +7 -0
- package/dist/components/Modal/index.d.ts +0 -1
- package/dist/components/Modal/index.js +67 -132
- package/dist/components/Package/index.js +24 -25
- package/dist/components/PackageEvents/index.js +43 -88
- package/dist/components/Pill/index.js +8 -8
- package/dist/components/Quotes/index.js +26 -25
- package/dist/components/SelectTrackingShipment/index.js +31 -35
- package/dist/components/ShipToFrom/index.js +13 -13
- package/dist/components/ShipmentException/icons/ExceptionIcon.js +12 -12
- package/dist/components/ShipmentException/icons/HexagonAlertBase.js +7 -7
- package/dist/components/ShipmentException/icons/HexagonPauseBase.js +7 -7
- package/dist/components/ShipmentException/icons/HexagonStopBase.js +7 -7
- package/dist/components/ShipmentException/index.js +25 -27
- package/dist/components/Summary/index.js +7 -7
- package/dist/components/Timeline/CheckedStep.js +12 -12
- package/dist/components/Timeline/CheckedSteps.js +7 -7
- package/dist/components/Timeline/EmptyStep.js +7 -7
- package/dist/components/Timeline/SecondaryStep.js +7 -7
- package/dist/components/Timeline/SecondarySteps.js +7 -7
- package/dist/components/Timeline/TimelineDefault.js +22 -22
- package/dist/components/Timeline/TimlineMinimal.js +24 -25
- package/dist/components/Timeline/defaultIcons/CancelledIcon.js +8 -8
- package/dist/components/Timeline/defaultIcons/CollectedIcon.js +9 -9
- package/dist/components/Timeline/defaultIcons/CompletedIcon.js +9 -9
- package/dist/components/Timeline/defaultIcons/ConfirmedIcon.js +9 -9
- package/dist/components/Timeline/defaultIcons/InTransitIcon.js +9 -9
- package/dist/components/Timeline/defaultIcons/PendingIcon.js +8 -8
- package/dist/components/Timeline/icons/CancelledIconBase.js +7 -7
- package/dist/components/Timeline/icons/CollectedIconBase.js +7 -7
- package/dist/components/Timeline/icons/CompletedIconBase.js +7 -7
- package/dist/components/Timeline/icons/ConfirmedIconBase.js +7 -7
- package/dist/components/Timeline/icons/InTransitIconBase.js +7 -7
- package/dist/components/Timeline/icons/PendingIconBase.js +7 -7
- package/dist/components/Timeline/index.js +9 -9
- package/dist/components/TrackingDrawer/index.css.js +7 -0
- package/dist/components/TrackingDrawer/index.d.ts +0 -1
- package/dist/components/TrackingDrawer/index.js +33 -81
- package/dist/components/TrackingShipment/index.js +27 -66
- package/dist/components/TrackingTop/index.js +14 -14
- package/dist/estimate.js +41 -83
- package/dist/estimateConfig.js +16 -14
- package/dist/fixtures/countries.js +5 -4
- package/dist/helper.js +61 -64
- package/dist/index.js +15 -34
- package/dist/requests.js +71 -191
- package/dist/tracking.js +77 -128
- package/dist/trackingConfig.js +11 -9
- package/package.json +8 -5
- package/dist/MetadataTypes.js +0 -2
- package/dist/typing.js +0 -1
package/dist/helper.js
CHANGED
|
@@ -1,41 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.getTrackingStyle = exports.getEstimateStyle = exports.getDestinationConfig = exports.getDisqualifiedConfig = exports.getQuoteConfig = exports.parseErrors = exports.parseEstimatedLocation = void 0;
|
|
15
|
-
exports.isSmallMobile = isSmallMobile;
|
|
16
|
-
exports.applySmallMobileStyling = applySmallMobileStyling;
|
|
17
|
-
exports.deepClean = deepClean;
|
|
18
|
-
exports.nestedObjectAssign = nestedObjectAssign;
|
|
19
|
-
exports.deepClone = deepClone;
|
|
20
|
-
var parseEstimatedLocation = function (loc) {
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const parseEstimatedLocation = (loc) => {
|
|
21
4
|
if (!loc) {
|
|
22
5
|
return '';
|
|
23
6
|
}
|
|
24
7
|
if (!loc.estimated_country || !loc.estimated_city) {
|
|
25
|
-
return
|
|
8
|
+
return `${loc.postal_code}, ${loc.country}`;
|
|
26
9
|
}
|
|
27
|
-
|
|
10
|
+
const region = loc.estimated_country === 'US' && loc.estimated_region
|
|
28
11
|
? loc.estimated_region
|
|
29
12
|
: '';
|
|
30
|
-
|
|
13
|
+
const city = loc.estimated_city.toLowerCase();
|
|
31
14
|
return region === ''
|
|
32
|
-
?
|
|
33
|
-
:
|
|
15
|
+
? `${city}, ${loc.estimated_country}`
|
|
16
|
+
: `${city}, ${region}, ${loc.estimated_country}`;
|
|
34
17
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
var keys = Object.keys(errors);
|
|
18
|
+
const parseErrors = (errors) => {
|
|
19
|
+
const errorMessages = [];
|
|
20
|
+
const keys = Object.keys(errors);
|
|
39
21
|
if (keys.includes('destination')) {
|
|
40
22
|
errorMessages.push('Invalid location details. Please check your destination address info and try again.');
|
|
41
23
|
}
|
|
@@ -47,20 +29,30 @@ var parseErrors = function (errors) {
|
|
|
47
29
|
}
|
|
48
30
|
return errorMessages;
|
|
49
31
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
32
|
+
const getQuoteConfig = (config) => {
|
|
33
|
+
return {
|
|
34
|
+
...config.text.quoted,
|
|
35
|
+
detailOriginLabel: config.text.detailOriginLabel,
|
|
36
|
+
detailDestinationLabel: config.text.detailDestinationLabel,
|
|
37
|
+
returnLinkLabel: config.text.returnLinkLabel,
|
|
38
|
+
};
|
|
53
39
|
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
40
|
+
const getDisqualifiedConfig = (config) => {
|
|
41
|
+
return {
|
|
42
|
+
...config.text.disqualified,
|
|
43
|
+
detailOriginLabel: config.text.detailOriginLabel,
|
|
44
|
+
detailDestinationLabel: config.text.detailDestinationLabel,
|
|
45
|
+
returnLinkLabel: config.text.returnLinkLabel,
|
|
46
|
+
};
|
|
57
47
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
48
|
+
const getDestinationConfig = (config) => {
|
|
49
|
+
return {
|
|
50
|
+
...config.text.destination,
|
|
51
|
+
detailOriginLabel: config.text.detailOriginLabel,
|
|
52
|
+
background: config.style.color.background,
|
|
53
|
+
};
|
|
61
54
|
};
|
|
62
|
-
|
|
63
|
-
var getEstimateStyle = function (config) {
|
|
55
|
+
const getEstimateStyle = (config) => {
|
|
64
56
|
return {
|
|
65
57
|
'--background': config.style.color.background,
|
|
66
58
|
'--text-primary': config.style.color.textPrimary,
|
|
@@ -78,20 +70,19 @@ var getEstimateStyle = function (config) {
|
|
|
78
70
|
'--error-text': config.style.color.errorText,
|
|
79
71
|
'--error-background': config.style.color.errorBackground,
|
|
80
72
|
'--font-family': config.style.fontFamily,
|
|
81
|
-
'--font-size':
|
|
82
|
-
'--width':
|
|
83
|
-
'--height':
|
|
73
|
+
'--font-size': `${config.style.fontSize}px`,
|
|
74
|
+
'--width': `${config.style.width}px`,
|
|
75
|
+
'--height': `${config.style.height}px`,
|
|
84
76
|
};
|
|
85
77
|
};
|
|
86
|
-
|
|
87
|
-
var getTrackingStyle = function (config) {
|
|
78
|
+
const getTrackingStyle = (config) => {
|
|
88
79
|
return {
|
|
89
80
|
'--background': config.style.color.background,
|
|
90
81
|
'--text-primary': config.style.color.textPrimary,
|
|
91
82
|
'--text-secondary': config.style.color.textSecondary,
|
|
92
83
|
'--border': config.style.color.border,
|
|
93
84
|
'--font-family': config.style.fontFamily,
|
|
94
|
-
'--font-size':
|
|
85
|
+
'--font-size': `${config.style.fontSize}px`,
|
|
95
86
|
'--width': config.style.variant === 'default' ? '540px' : '320px',
|
|
96
87
|
'--default-styling': config.style.variant === 'default' ? 'flex' : 'none',
|
|
97
88
|
'--minimal-styling': config.style.variant === 'default' ? 'none' : 'flex',
|
|
@@ -109,20 +100,18 @@ var getTrackingStyle = function (config) {
|
|
|
109
100
|
'--button-border-hover': config.style.color.buttonBorderHover,
|
|
110
101
|
};
|
|
111
102
|
};
|
|
112
|
-
|
|
113
|
-
var getAnimationStyleIn = function (animation, config) {
|
|
114
|
-
var _a;
|
|
103
|
+
const getAnimationStyleIn = (animation, config) => {
|
|
115
104
|
if (animation.type === null) {
|
|
116
105
|
return 'none';
|
|
117
106
|
}
|
|
118
|
-
|
|
107
|
+
const type = animation.type === 'fade'
|
|
119
108
|
? 'fadeInAnimation'
|
|
120
109
|
: config.style.position === 'left'
|
|
121
110
|
? 'slideInFromLeft'
|
|
122
111
|
: 'slideInFromRight';
|
|
123
|
-
return
|
|
112
|
+
return `${type} ${animation.easing ?? 'ease'} ${animation.duration}ms`;
|
|
124
113
|
};
|
|
125
|
-
|
|
114
|
+
const MINIMUM_RENDERING_HEIGHT = 467;
|
|
126
115
|
function isSmallMobile() {
|
|
127
116
|
return window.innerWidth <= 800 && window.innerHeight <= 600;
|
|
128
117
|
}
|
|
@@ -137,13 +126,12 @@ function deepClean(obj) {
|
|
|
137
126
|
if (typeof obj !== 'object' || obj === null) {
|
|
138
127
|
return obj;
|
|
139
128
|
}
|
|
140
|
-
|
|
141
|
-
var key = _a[0], value = _a[1];
|
|
129
|
+
const cleanedObj = Object.entries(obj).reduce((acc, [key, value]) => {
|
|
142
130
|
if (value === null || value === undefined) {
|
|
143
131
|
return acc;
|
|
144
132
|
}
|
|
145
133
|
if (typeof value === 'object' && !Array.isArray(value)) {
|
|
146
|
-
|
|
134
|
+
const cleanedValue = deepClean(value);
|
|
147
135
|
if (Object.keys(cleanedValue).length > 0) {
|
|
148
136
|
acc[key] = cleanedValue;
|
|
149
137
|
}
|
|
@@ -155,16 +143,12 @@ function deepClean(obj) {
|
|
|
155
143
|
}, {});
|
|
156
144
|
return cleanedObj;
|
|
157
145
|
}
|
|
158
|
-
function nestedObjectAssign(target) {
|
|
159
|
-
|
|
160
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
161
|
-
sources[_i - 1] = arguments[_i];
|
|
162
|
-
}
|
|
163
|
-
sources.forEach(function (source) {
|
|
146
|
+
function nestedObjectAssign(target, ...sources) {
|
|
147
|
+
sources.forEach((source) => {
|
|
164
148
|
if (source) {
|
|
165
|
-
Object.keys(source).forEach(
|
|
166
|
-
|
|
167
|
-
|
|
149
|
+
Object.keys(source).forEach((key) => {
|
|
150
|
+
const s_val = source[key];
|
|
151
|
+
const t_val = target[key];
|
|
168
152
|
target[key] =
|
|
169
153
|
t_val &&
|
|
170
154
|
s_val &&
|
|
@@ -180,3 +164,16 @@ function nestedObjectAssign(target) {
|
|
|
180
164
|
function deepClone(obj) {
|
|
181
165
|
return JSON.parse(JSON.stringify(obj));
|
|
182
166
|
}
|
|
167
|
+
|
|
168
|
+
exports.applySmallMobileStyling = applySmallMobileStyling;
|
|
169
|
+
exports.deepClean = deepClean;
|
|
170
|
+
exports.deepClone = deepClone;
|
|
171
|
+
exports.getDestinationConfig = getDestinationConfig;
|
|
172
|
+
exports.getDisqualifiedConfig = getDisqualifiedConfig;
|
|
173
|
+
exports.getEstimateStyle = getEstimateStyle;
|
|
174
|
+
exports.getQuoteConfig = getQuoteConfig;
|
|
175
|
+
exports.getTrackingStyle = getTrackingStyle;
|
|
176
|
+
exports.isSmallMobile = isSmallMobile;
|
|
177
|
+
exports.nestedObjectAssign = nestedObjectAssign;
|
|
178
|
+
exports.parseErrors = parseErrors;
|
|
179
|
+
exports.parseEstimatedLocation = parseEstimatedLocation;
|
package/dist/index.js
CHANGED
|
@@ -1,36 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.Tracking = exports.Estimate = void 0;
|
|
21
|
-
var arta_1 = __importDefault(require("./arta"));
|
|
22
|
-
require("./components/Modal/index.css");
|
|
23
|
-
require("./components/TrackingDrawer/index.css");
|
|
24
|
-
var estimate_1 = __importDefault(require("./estimate"));
|
|
25
|
-
exports.Estimate = estimate_1.default;
|
|
26
|
-
var tracking_1 = __importDefault(require("./tracking"));
|
|
27
|
-
exports.Tracking = tracking_1.default;
|
|
28
|
-
var init = function () {
|
|
29
|
-
window.Arta = new arta_1.default();
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var arta = require('./arta.js');
|
|
6
|
+
var estimate = require('./estimate.js');
|
|
7
|
+
var tracking = require('./tracking.js');
|
|
8
|
+
|
|
9
|
+
const init = () => {
|
|
10
|
+
window.Arta = new arta.default();
|
|
30
11
|
};
|
|
31
12
|
init();
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
exports.default =
|
|
13
|
+
var index = window.Arta;
|
|
14
|
+
|
|
15
|
+
exports.Estimate = estimate.default;
|
|
16
|
+
exports.Tracking = tracking.default;
|
|
17
|
+
exports.default = index;
|
package/dist/requests.js
CHANGED
|
@@ -1,66 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
-
if (ar || !(i in from)) {
|
|
52
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
-
ar[i] = from[i];
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
-
};
|
|
58
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
59
|
-
exports.loadPackageEvents = exports.validateShipment = exports.loadShipment = exports.validateEstimateBody = exports.loadQuoteRequests = exports.loadHostedSessions = void 0;
|
|
60
|
-
var AUTH_KEY = 'ARTA_APIKey';
|
|
61
|
-
var logError = function (_a) {
|
|
62
|
-
var status = _a.status, errors = _a.errors;
|
|
63
|
-
var keys = Object.keys(errors);
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const AUTH_KEY = 'ARTA_APIKey';
|
|
4
|
+
const logError = ({ status, errors }) => {
|
|
5
|
+
const keys = Object.keys(errors);
|
|
64
6
|
if (status === 403) {
|
|
65
7
|
console.error('Invalid API Key');
|
|
66
8
|
}
|
|
@@ -68,146 +10,84 @@ var logError = function (_a) {
|
|
|
68
10
|
console.error('Private API Key');
|
|
69
11
|
}
|
|
70
12
|
else if (status === 422) {
|
|
71
|
-
keys.map(
|
|
72
|
-
console.error(
|
|
13
|
+
keys.map((key) => {
|
|
14
|
+
console.error(`${key} ${errors[key]}`);
|
|
73
15
|
});
|
|
74
16
|
}
|
|
75
17
|
else if (status === 400) {
|
|
76
|
-
keys.map(
|
|
77
|
-
console.error(
|
|
18
|
+
keys.map((key) => {
|
|
19
|
+
console.error(`${key} ${errors[key]}`);
|
|
78
20
|
});
|
|
79
21
|
}
|
|
80
22
|
else {
|
|
81
23
|
console.error('Unkonwn error', status, errors);
|
|
82
24
|
}
|
|
83
25
|
};
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
case 0:
|
|
95
|
-
schema = config.httpSchema ? config.httpSchema : 'https';
|
|
96
|
-
return [4 /*yield*/, fetch("".concat(schema, "://").concat(config.host).concat(path), {
|
|
97
|
-
method: method,
|
|
98
|
-
body: body,
|
|
99
|
-
headers: __assign(__assign({}, headers), { Authorization: "".concat(AUTH_KEY, " ").concat(config.apiKey), 'Content-Type': 'application/json' }),
|
|
100
|
-
})];
|
|
101
|
-
case 1:
|
|
102
|
-
res = _a.sent();
|
|
103
|
-
return [4 /*yield*/, res.json()];
|
|
104
|
-
case 2:
|
|
105
|
-
resBody = _a.sent();
|
|
106
|
-
if (!res.ok) {
|
|
107
|
-
err = Object.assign({}, {
|
|
108
|
-
errors: resBody['errors'],
|
|
109
|
-
status: res.status,
|
|
110
|
-
statusText: res.statusText,
|
|
111
|
-
});
|
|
112
|
-
logError(err);
|
|
113
|
-
return [2 /*return*/, { err: err }];
|
|
114
|
-
}
|
|
115
|
-
return [2 /*return*/, resBody];
|
|
116
|
-
}
|
|
117
|
-
});
|
|
26
|
+
const artaRequest = async (path, config, body, headers, method = 'POST') => {
|
|
27
|
+
const schema = config.httpSchema ? config.httpSchema : 'https';
|
|
28
|
+
const res = await fetch(`${schema}://${config.host}${path}`, {
|
|
29
|
+
method,
|
|
30
|
+
body,
|
|
31
|
+
headers: {
|
|
32
|
+
...headers,
|
|
33
|
+
Authorization: `${AUTH_KEY} ${config.apiKey}`,
|
|
34
|
+
'Content-Type': 'application/json',
|
|
35
|
+
},
|
|
118
36
|
});
|
|
37
|
+
const resBody = await res.json();
|
|
38
|
+
if (!res.ok) {
|
|
39
|
+
const err = Object.assign({}, {
|
|
40
|
+
errors: resBody['errors'],
|
|
41
|
+
status: res.status,
|
|
42
|
+
statusText: res.statusText,
|
|
43
|
+
});
|
|
44
|
+
logError(err);
|
|
45
|
+
return { err: err };
|
|
46
|
+
}
|
|
47
|
+
return resBody;
|
|
119
48
|
};
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
|
|
49
|
+
const loadHostedSessions = async (config, estimateBody) => {
|
|
50
|
+
const path = '/estimate/hosted_sessions';
|
|
51
|
+
const body = JSON.stringify({ hosted_session: estimateBody });
|
|
52
|
+
const res = await artaRequest(path, config, body);
|
|
53
|
+
return res;
|
|
54
|
+
};
|
|
55
|
+
const loadQuoteRequests = async (config, hostedSession, estimateBody) => {
|
|
56
|
+
const path = '/estimate/requests';
|
|
57
|
+
const body = JSON.stringify({ request: estimateBody });
|
|
58
|
+
const headers = {
|
|
59
|
+
'hosted-session-id': hostedSession.id,
|
|
60
|
+
'hosted-session-private-token': hostedSession.private_token,
|
|
61
|
+
};
|
|
62
|
+
const res = await artaRequest(path, config, body, headers);
|
|
63
|
+
res.quotes && res.quotes.forEach((q) => (q.total = parseFloat(q.total)));
|
|
64
|
+
return res;
|
|
65
|
+
};
|
|
66
|
+
const validateEstimateBody = async (config, estimateBody) => {
|
|
67
|
+
const path = '/estimate/validate';
|
|
68
|
+
const body = JSON.stringify({ estimate: estimateBody });
|
|
69
|
+
const res = await artaRequest(path, config, body);
|
|
70
|
+
return res.err?.errors;
|
|
71
|
+
};
|
|
72
|
+
const loadShipment = async (config, shipmentId) => {
|
|
73
|
+
const path = `/embedded_tracking/shipments/${shipmentId}`;
|
|
74
|
+
const res = await artaRequest(path, config, undefined, undefined, 'GET');
|
|
75
|
+
return res;
|
|
76
|
+
};
|
|
77
|
+
const validateShipment = async (config, shipmentId) => {
|
|
78
|
+
const path = `/embedded_tracking/shipments/${shipmentId}/validate`;
|
|
79
|
+
const res = await artaRequest(path, config, undefined, undefined, 'GET');
|
|
80
|
+
return res.err?.errors;
|
|
81
|
+
};
|
|
82
|
+
const loadPackageEvents = async (config, shipmentId, packageId) => {
|
|
83
|
+
const path = `/embedded_tracking/package_events/${shipmentId}/${packageId}`;
|
|
84
|
+
const res = await artaRequest(path, config, undefined, undefined, 'GET');
|
|
85
|
+
return res;
|
|
86
|
+
};
|
|
87
|
+
|
|
134
88
|
exports.loadHostedSessions = loadHostedSessions;
|
|
135
|
-
|
|
136
|
-
var path, body, headers, res;
|
|
137
|
-
return __generator(this, function (_a) {
|
|
138
|
-
switch (_a.label) {
|
|
139
|
-
case 0:
|
|
140
|
-
path = '/estimate/requests';
|
|
141
|
-
body = JSON.stringify({ request: estimateBody });
|
|
142
|
-
headers = {
|
|
143
|
-
'hosted-session-id': hostedSession.id,
|
|
144
|
-
'hosted-session-private-token': hostedSession.private_token,
|
|
145
|
-
};
|
|
146
|
-
return [4 /*yield*/, artaRequest(path, config, body, headers)];
|
|
147
|
-
case 1:
|
|
148
|
-
res = _a.sent();
|
|
149
|
-
res.quotes && res.quotes.forEach(function (q) { return (q.total = parseFloat(q.total)); });
|
|
150
|
-
return [2 /*return*/, res];
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}); };
|
|
89
|
+
exports.loadPackageEvents = loadPackageEvents;
|
|
154
90
|
exports.loadQuoteRequests = loadQuoteRequests;
|
|
155
|
-
var validateEstimateBody = function (config, estimateBody) { return __awaiter(void 0, void 0, void 0, function () {
|
|
156
|
-
var path, body, res;
|
|
157
|
-
var _a;
|
|
158
|
-
return __generator(this, function (_b) {
|
|
159
|
-
switch (_b.label) {
|
|
160
|
-
case 0:
|
|
161
|
-
path = '/estimate/validate';
|
|
162
|
-
body = JSON.stringify({ estimate: estimateBody });
|
|
163
|
-
return [4 /*yield*/, artaRequest(path, config, body)];
|
|
164
|
-
case 1:
|
|
165
|
-
res = _b.sent();
|
|
166
|
-
return [2 /*return*/, (_a = res.err) === null || _a === void 0 ? void 0 : _a.errors];
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
}); };
|
|
170
|
-
exports.validateEstimateBody = validateEstimateBody;
|
|
171
|
-
var loadShipment = function (config, shipmentId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
172
|
-
var path, res;
|
|
173
|
-
return __generator(this, function (_a) {
|
|
174
|
-
switch (_a.label) {
|
|
175
|
-
case 0:
|
|
176
|
-
path = "/embedded_tracking/shipments/".concat(shipmentId);
|
|
177
|
-
return [4 /*yield*/, artaRequest(path, config, undefined, undefined, 'GET')];
|
|
178
|
-
case 1:
|
|
179
|
-
res = _a.sent();
|
|
180
|
-
return [2 /*return*/, res];
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
}); };
|
|
184
91
|
exports.loadShipment = loadShipment;
|
|
185
|
-
|
|
186
|
-
var path, res;
|
|
187
|
-
var _a;
|
|
188
|
-
return __generator(this, function (_b) {
|
|
189
|
-
switch (_b.label) {
|
|
190
|
-
case 0:
|
|
191
|
-
path = "/embedded_tracking/shipments/".concat(shipmentId, "/validate");
|
|
192
|
-
return [4 /*yield*/, artaRequest(path, config, undefined, undefined, 'GET')];
|
|
193
|
-
case 1:
|
|
194
|
-
res = _b.sent();
|
|
195
|
-
return [2 /*return*/, (_a = res.err) === null || _a === void 0 ? void 0 : _a.errors];
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
}); };
|
|
92
|
+
exports.validateEstimateBody = validateEstimateBody;
|
|
199
93
|
exports.validateShipment = validateShipment;
|
|
200
|
-
var loadPackageEvents = function (config, shipmentId, packageId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
201
|
-
var path, res;
|
|
202
|
-
return __generator(this, function (_a) {
|
|
203
|
-
switch (_a.label) {
|
|
204
|
-
case 0:
|
|
205
|
-
path = "/embedded_tracking/package_events/".concat(shipmentId, "/").concat(packageId);
|
|
206
|
-
return [4 /*yield*/, artaRequest(path, config, undefined, undefined, 'GET')];
|
|
207
|
-
case 1:
|
|
208
|
-
res = _a.sent();
|
|
209
|
-
return [2 /*return*/, res];
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
}); };
|
|
213
|
-
exports.loadPackageEvents = loadPackageEvents;
|