mts-booking-library 1.2.28 → 1.2.29
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/booking/booking.d.ts +1 -0
- package/lib/booking/booking.js +3 -0
- package/lib/booking/journeyBooking.js +14 -1
- package/lib/booking/serviceBooking.js +14 -1
- package/lib/booking/subscriptionBooking.js +14 -1
- package/lib/config.d.ts +1 -0
- package/lib/config.js +2 -0
- package/package.json +1 -1
package/lib/booking/booking.d.ts
CHANGED
@@ -39,6 +39,7 @@ export declare abstract class Booking {
|
|
39
39
|
* @param sellerId The id of the seller.
|
40
40
|
*/
|
41
41
|
updateSellerId(sellerId: number): void;
|
42
|
+
getSellerId(): number | undefined;
|
42
43
|
/**
|
43
44
|
* This method allows to renew the access token for calling MTS APIs
|
44
45
|
* @param {string} access_token The new access token
|
package/lib/booking/booking.js
CHANGED
@@ -93,6 +93,9 @@ var Booking = /** @class */ (function () {
|
|
93
93
|
Booking.prototype.updateSellerId = function (sellerId) {
|
94
94
|
this.sellerId = sellerId;
|
95
95
|
};
|
96
|
+
Booking.prototype.getSellerId = function () {
|
97
|
+
return this.sellerId;
|
98
|
+
};
|
96
99
|
/**
|
97
100
|
* This method allows to renew the access token for calling MTS APIs
|
98
101
|
* @param {string} access_token The new access token
|
@@ -72,6 +72,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
72
72
|
};
|
73
73
|
Object.defineProperty(exports, "__esModule", { value: true });
|
74
74
|
exports.JourneyBooking = void 0;
|
75
|
+
var config_1 = require("../config");
|
75
76
|
var ErrorResponse_1 = require("../types/ErrorResponse");
|
76
77
|
var Reduction_1 = require("../types/common/Reduction");
|
77
78
|
var processBookingSteps_1 = require("../utils/processBookingSteps");
|
@@ -108,7 +109,15 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
108
109
|
this.cartId = undefined;
|
109
110
|
this.bookingStepsToStatus = new Map();
|
110
111
|
this.bookingDueDate = undefined;
|
111
|
-
|
112
|
+
try {
|
113
|
+
localStorage.removeItem("cartId");
|
114
|
+
}
|
115
|
+
catch (e) {
|
116
|
+
if (this.config.ENV !== config_1.MTSEnvs.TEST) {
|
117
|
+
throw new Error("Error while deleting cartId from localStorage");
|
118
|
+
}
|
119
|
+
console.log(e);
|
120
|
+
}
|
112
121
|
};
|
113
122
|
JourneyBooking.prototype.fetchAndSetCart = function (cartId) {
|
114
123
|
return __awaiter(this, void 0, void 0, function () {
|
@@ -122,6 +131,8 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
122
131
|
_this.cart = cart;
|
123
132
|
_this.cartId = cart.id;
|
124
133
|
_this.bookingDueDate = cartDate; // See Booking class
|
134
|
+
// Update the sellerId. This is particularly important in Linkavel
|
135
|
+
_this.updateSellerId(cart.sellerId);
|
125
136
|
// Fill the booking process status
|
126
137
|
_this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(cart.stepsToStatus);
|
127
138
|
}
|
@@ -256,6 +267,8 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
256
267
|
// Fill the booking process status
|
257
268
|
_this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(response.cart.stepsToStatus);
|
258
269
|
_this.bookingDueDate = new Date(response.cart.bookingDueDate);
|
270
|
+
// Update the sellerId. This is particularly important in Linkavel
|
271
|
+
_this.updateSellerId(response.cart.sellerId);
|
259
272
|
return response.cart;
|
260
273
|
})];
|
261
274
|
});
|
@@ -72,6 +72,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
72
72
|
};
|
73
73
|
Object.defineProperty(exports, "__esModule", { value: true });
|
74
74
|
exports.ServiceBooking = void 0;
|
75
|
+
var config_1 = require("../config");
|
75
76
|
var ErrorResponse_1 = require("../types/ErrorResponse");
|
76
77
|
var Reduction_1 = require("../types/common/Reduction");
|
77
78
|
var processBookingSteps_1 = require("../utils/processBookingSteps");
|
@@ -108,7 +109,15 @@ var ServiceBooking = /** @class */ (function (_super) {
|
|
108
109
|
this.cartId = undefined;
|
109
110
|
this.bookingStepsToStatus = new Map();
|
110
111
|
this.bookingDueDate = undefined;
|
111
|
-
|
112
|
+
try {
|
113
|
+
localStorage.removeItem("cartId");
|
114
|
+
}
|
115
|
+
catch (e) {
|
116
|
+
if (this.config.ENV !== config_1.MTSEnvs.TEST) {
|
117
|
+
throw new Error("Error while deleting cartId from localStorage");
|
118
|
+
}
|
119
|
+
console.log(e);
|
120
|
+
}
|
112
121
|
};
|
113
122
|
ServiceBooking.prototype.fetchAndSetCart = function (cartId) {
|
114
123
|
return __awaiter(this, void 0, void 0, function () {
|
@@ -122,6 +131,8 @@ var ServiceBooking = /** @class */ (function (_super) {
|
|
122
131
|
_this.cart = cart;
|
123
132
|
_this.cartId = cart.id;
|
124
133
|
_this.bookingDueDate = cartDate; // See Booking class
|
134
|
+
// Update the sellerId. This is particularly important in Linkavel
|
135
|
+
_this.updateSellerId(cart.sellerId);
|
125
136
|
// Fill the booking process status
|
126
137
|
_this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(cart.stepsToStatus);
|
127
138
|
}
|
@@ -257,6 +268,8 @@ var ServiceBooking = /** @class */ (function (_super) {
|
|
257
268
|
// Fill the booking process status
|
258
269
|
_this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(response.cart.stepsToStatus);
|
259
270
|
_this.bookingDueDate = new Date(response.cart.bookingDueDate);
|
271
|
+
// Update the sellerId. This is particularly important in Linkavel
|
272
|
+
_this.updateSellerId(response.cart.sellerId);
|
260
273
|
return response.cart;
|
261
274
|
})];
|
262
275
|
});
|
@@ -72,6 +72,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
72
72
|
};
|
73
73
|
Object.defineProperty(exports, "__esModule", { value: true });
|
74
74
|
exports.SubscriptionBooking = void 0;
|
75
|
+
var config_1 = require("../config");
|
75
76
|
var ErrorResponse_1 = require("../types/ErrorResponse");
|
76
77
|
var Reduction_1 = require("../types/common/Reduction");
|
77
78
|
var processBookingSteps_1 = require("../utils/processBookingSteps");
|
@@ -108,7 +109,15 @@ var SubscriptionBooking = /** @class */ (function (_super) {
|
|
108
109
|
this.cartId = undefined;
|
109
110
|
this.bookingStepsToStatus = new Map();
|
110
111
|
this.bookingDueDate = undefined;
|
111
|
-
|
112
|
+
try {
|
113
|
+
localStorage.removeItem("cartId");
|
114
|
+
}
|
115
|
+
catch (e) {
|
116
|
+
if (this.config.ENV !== config_1.MTSEnvs.TEST) {
|
117
|
+
throw new Error("Error while deleting cartId from localStorage");
|
118
|
+
}
|
119
|
+
console.log(e);
|
120
|
+
}
|
112
121
|
};
|
113
122
|
SubscriptionBooking.prototype.fetchAndSetCart = function (cartId) {
|
114
123
|
return __awaiter(this, void 0, void 0, function () {
|
@@ -122,6 +131,8 @@ var SubscriptionBooking = /** @class */ (function (_super) {
|
|
122
131
|
_this.cart = cart;
|
123
132
|
_this.cartId = cart.id;
|
124
133
|
_this.bookingDueDate = cartDate; // See Booking class
|
134
|
+
// Update the sellerId. This is particularly important in Linkavel
|
135
|
+
_this.updateSellerId(cart.sellerId);
|
125
136
|
// Fill the booking process status
|
126
137
|
_this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(cart.stepsToStatus);
|
127
138
|
}
|
@@ -311,6 +322,8 @@ var SubscriptionBooking = /** @class */ (function (_super) {
|
|
311
322
|
// Fill the booking process status
|
312
323
|
_this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(response.cart.stepsToStatus);
|
313
324
|
_this.bookingDueDate = new Date(response.cart.bookingDueDate);
|
325
|
+
// Update the sellerId. This is particularly important in Linkavel
|
326
|
+
_this.updateSellerId(response.cart.sellerId);
|
314
327
|
return response.cart;
|
315
328
|
})];
|
316
329
|
});
|
package/lib/config.d.ts
CHANGED
package/lib/config.js
CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getConfig = exports.setConfig = exports.MTSEnvs = void 0;
|
4
4
|
var MTSEnvs;
|
5
5
|
(function (MTSEnvs) {
|
6
|
+
MTSEnvs["TEST"] = "TEST";
|
6
7
|
MTSEnvs["DEV"] = "DEV";
|
7
8
|
MTSEnvs["STAGING"] = "STAGING";
|
8
9
|
MTSEnvs["PROD"] = "PROD";
|
@@ -18,6 +19,7 @@ var setConfig = function (env, sub_key, debug, access_token) {
|
|
18
19
|
// First, set the environment
|
19
20
|
config.ENV = env.toUpperCase();
|
20
21
|
switch (config.ENV) {
|
22
|
+
case MTSEnvs.TEST:
|
21
23
|
case MTSEnvs.DEV:
|
22
24
|
config.API_ENDPOINT = "https://myticketsolutionapim.azure-api.net/api/dev";
|
23
25
|
break;
|