mts-booking-library 2.1.2 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -134,30 +134,25 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
134
134
|
return __awaiter(this, void 0, void 0, function () {
|
135
135
|
var _this = this;
|
136
136
|
return __generator(this, function (_a) {
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
_this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(cart.stepsToStatus);
|
150
|
-
}
|
151
|
-
else {
|
152
|
-
// This should never happen, but just in case
|
153
|
-
_this.resetBooking();
|
154
|
-
}
|
137
|
+
return [2 /*return*/, this.fetchCart(cartGuid, options).then(function (cart) {
|
138
|
+
if (cart) {
|
139
|
+
var cartDueDate = new Date();
|
140
|
+
cartDueDate.setSeconds(cartDueDate.getSeconds() + cart.bookingDueDateRemainingSeconds);
|
141
|
+
if (cartDueDate > new Date() && !cart.hasIssuedTickets) {
|
142
|
+
_this.cart = cart;
|
143
|
+
_this.cartGuid = cart.guid;
|
144
|
+
_this.bookingDueDate = cartDueDate; // See Booking class
|
145
|
+
// Update the sellerId. This is particularly important in Linkavel
|
146
|
+
_this.updateSellerId(cart.sellerId);
|
147
|
+
// Fill the booking process status
|
148
|
+
_this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(cart.stepsToStatus);
|
155
149
|
}
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
150
|
+
else {
|
151
|
+
// This should never happen, but just in case
|
152
|
+
_this.resetBooking();
|
153
|
+
}
|
154
|
+
}
|
155
|
+
})];
|
161
156
|
});
|
162
157
|
});
|
163
158
|
};
|
@@ -271,26 +266,46 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
271
266
|
return __generator(this, function (_a) {
|
272
267
|
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/journeys/carts");
|
273
268
|
request = __assign(__assign({}, journeyCart), (this.cartGuid && { cartGuid: this.cartGuid }));
|
274
|
-
return [2 /*return*/, this.callPostApi(url, request, options).then(function (response) {
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
269
|
+
return [2 /*return*/, this.callPostApi(url, request, options).then(function (response) { return __awaiter(_this, void 0, void 0, function () {
|
270
|
+
var cartDueDate;
|
271
|
+
return __generator(this, function (_a) {
|
272
|
+
switch (_a.label) {
|
273
|
+
case 0:
|
274
|
+
// Check for errors
|
275
|
+
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
276
|
+
// If there was an error, reset cartGuid and remove it from the mts-storage
|
277
|
+
this.resetBooking();
|
278
|
+
return [2 /*return*/, response];
|
279
|
+
}
|
280
|
+
if (!response.cart) return [3 /*break*/, 1];
|
281
|
+
this.cart = response.cart;
|
282
|
+
this.cartGuid = response.cart.guid;
|
283
|
+
// Save the cartGuid in the storage
|
284
|
+
this.getStorage().getState().updateCartGuid(response.cart.guid);
|
285
|
+
// Fill the booking process status
|
286
|
+
this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(response.cart.stepsToStatus);
|
287
|
+
cartDueDate = new Date();
|
288
|
+
cartDueDate.setSeconds(cartDueDate.getSeconds() + response.cart.bookingDueDateRemainingSeconds);
|
289
|
+
this.bookingDueDate = cartDueDate;
|
290
|
+
// Update the sellerId. This is particularly important in Linkavel
|
291
|
+
this.updateSellerId(response.cart.sellerId);
|
292
|
+
return [2 /*return*/, response.cart];
|
293
|
+
case 1:
|
294
|
+
// Fetch & update local properties
|
295
|
+
return [4 /*yield*/, this.fetchAndSetCart(response.cartGuid)];
|
296
|
+
case 2:
|
297
|
+
// Fetch & update local properties
|
298
|
+
_a.sent();
|
299
|
+
if (!this.cart) {
|
300
|
+
// Should already be handled, but just in case
|
301
|
+
throw new Error("Could not fetch cart");
|
302
|
+
}
|
303
|
+
// Update storage
|
304
|
+
this.getStorage().getState().updateCartGuid(response.cart.guid);
|
305
|
+
return [2 /*return*/, this.cart];
|
306
|
+
}
|
307
|
+
});
|
308
|
+
}); })];
|
294
309
|
});
|
295
310
|
});
|
296
311
|
};
|
@@ -134,30 +134,25 @@ var ServiceBooking = /** @class */ (function (_super) {
|
|
134
134
|
return __awaiter(this, void 0, void 0, function () {
|
135
135
|
var _this = this;
|
136
136
|
return __generator(this, function (_a) {
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
_this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(cart.stepsToStatus);
|
150
|
-
}
|
151
|
-
else {
|
152
|
-
// This should never happen, but just in case
|
153
|
-
_this.resetBooking();
|
154
|
-
}
|
137
|
+
return [2 /*return*/, this.fetchCart(cartGuid, options).then(function (cart) {
|
138
|
+
if (cart) {
|
139
|
+
var cartDueDate = new Date();
|
140
|
+
cartDueDate.setSeconds(cartDueDate.getSeconds() + cart.bookingDueDateRemainingSeconds);
|
141
|
+
if (cartDueDate > new Date() && !cart.hasIssuedTickets) {
|
142
|
+
_this.cart = cart;
|
143
|
+
_this.cartGuid = cart.guid;
|
144
|
+
_this.bookingDueDate = cartDueDate; // See Booking class
|
145
|
+
// Update the sellerId. This is particularly important in Linkavel
|
146
|
+
_this.updateSellerId(cart.sellerId);
|
147
|
+
// Fill the booking process status
|
148
|
+
_this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(cart.stepsToStatus);
|
155
149
|
}
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
150
|
+
else {
|
151
|
+
// This should never happen, but just in case
|
152
|
+
_this.resetBooking();
|
153
|
+
}
|
154
|
+
}
|
155
|
+
})];
|
161
156
|
});
|
162
157
|
});
|
163
158
|
};
|
@@ -271,27 +266,47 @@ var ServiceBooking = /** @class */ (function (_super) {
|
|
271
266
|
var _this = this;
|
272
267
|
return __generator(this, function (_a) {
|
273
268
|
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/services/carts");
|
274
|
-
return [2 /*return*/, this.callPostApi(url, serviceCart, options).then(function (response) {
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
269
|
+
return [2 /*return*/, this.callPostApi(url, serviceCart, options).then(function (response) { return __awaiter(_this, void 0, void 0, function () {
|
270
|
+
var cartDueDate;
|
271
|
+
return __generator(this, function (_a) {
|
272
|
+
switch (_a.label) {
|
273
|
+
case 0:
|
274
|
+
// Check for errors
|
275
|
+
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
276
|
+
// If there was an error, reset cartGuid and remove it from the mts-storage
|
277
|
+
this.resetBooking();
|
278
|
+
return [2 /*return*/, response];
|
279
|
+
}
|
280
|
+
if (!response.cart) return [3 /*break*/, 1];
|
281
|
+
// Save the local data
|
282
|
+
this.cart = response.cart;
|
283
|
+
this.cartGuid = response.cart.guid;
|
284
|
+
// Save the cartGuid in the mts-storage
|
285
|
+
this.getStorage().getState().updateCartGuid(response.cart.guid);
|
286
|
+
// Fill the booking process status
|
287
|
+
this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(response.cart.stepsToStatus);
|
288
|
+
cartDueDate = new Date();
|
289
|
+
cartDueDate.setSeconds(cartDueDate.getSeconds() + response.cart.bookingDueDateRemainingSeconds);
|
290
|
+
this.bookingDueDate = cartDueDate;
|
291
|
+
// Update the sellerId. This is particularly important in Linkavel
|
292
|
+
this.updateSellerId(response.cart.sellerId);
|
293
|
+
return [2 /*return*/, response.cart];
|
294
|
+
case 1:
|
295
|
+
// Fetch & update local properties
|
296
|
+
return [4 /*yield*/, this.fetchAndSetCart(response.cartGuid)];
|
297
|
+
case 2:
|
298
|
+
// Fetch & update local properties
|
299
|
+
_a.sent();
|
300
|
+
if (!this.cart) {
|
301
|
+
// Should already be handled, but just in case
|
302
|
+
throw new Error("Could not fetch cart");
|
303
|
+
}
|
304
|
+
// Update storage
|
305
|
+
this.getStorage().getState().updateCartGuid(response.cart.guid);
|
306
|
+
return [2 /*return*/, this.cart];
|
307
|
+
}
|
308
|
+
});
|
309
|
+
}); })];
|
295
310
|
});
|
296
311
|
});
|
297
312
|
};
|
@@ -134,30 +134,25 @@ var SubscriptionBooking = /** @class */ (function (_super) {
|
|
134
134
|
return __awaiter(this, void 0, void 0, function () {
|
135
135
|
var _this = this;
|
136
136
|
return __generator(this, function (_a) {
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
_this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(cart.stepsToStatus);
|
150
|
-
}
|
151
|
-
else {
|
152
|
-
// This should never happen, but just in case
|
153
|
-
_this.resetBooking();
|
154
|
-
}
|
137
|
+
return [2 /*return*/, this.fetchCart(cartGuid, options).then(function (cart) {
|
138
|
+
if (cart) {
|
139
|
+
var cartDueDate = new Date();
|
140
|
+
cartDueDate.setSeconds(cartDueDate.getSeconds() + cart.bookingDueDateRemainingSeconds);
|
141
|
+
if (cartDueDate > new Date() && !cart.hasIssuedTickets) {
|
142
|
+
_this.cart = cart;
|
143
|
+
_this.cartGuid = cart.guid;
|
144
|
+
_this.bookingDueDate = cartDueDate; // See Booking class
|
145
|
+
// Update the sellerId. This is particularly important in Linkavel
|
146
|
+
_this.updateSellerId(cart.sellerId);
|
147
|
+
// Fill the booking process status
|
148
|
+
_this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(cart.stepsToStatus);
|
155
149
|
}
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
150
|
+
else {
|
151
|
+
// This should never happen, but just in case
|
152
|
+
_this.resetBooking();
|
153
|
+
}
|
154
|
+
}
|
155
|
+
})];
|
161
156
|
});
|
162
157
|
});
|
163
158
|
};
|
@@ -330,26 +325,46 @@ var SubscriptionBooking = /** @class */ (function (_super) {
|
|
330
325
|
var _this = this;
|
331
326
|
return __generator(this, function (_a) {
|
332
327
|
url = "".concat(this.config.API_ENDPOINT, "/v3_booking/subscriptions/carts");
|
333
|
-
return [2 /*return*/, this.callPostApi(url, request, options).then(function (response) {
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
328
|
+
return [2 /*return*/, this.callPostApi(url, request, options).then(function (response) { return __awaiter(_this, void 0, void 0, function () {
|
329
|
+
var cartDueDate;
|
330
|
+
return __generator(this, function (_a) {
|
331
|
+
switch (_a.label) {
|
332
|
+
case 0:
|
333
|
+
// Check for errors
|
334
|
+
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
335
|
+
// If there was an error, reset cartGuid and remove it from the mts-storage
|
336
|
+
this.resetBooking();
|
337
|
+
return [2 /*return*/, response];
|
338
|
+
}
|
339
|
+
if (!response.cart) return [3 /*break*/, 1];
|
340
|
+
this.cart = response.cart;
|
341
|
+
this.cartGuid = response.cart.guid;
|
342
|
+
// Save the cartGuid in the mts-storage
|
343
|
+
this.getStorage().getState().updateCartGuid(response.cart.guid);
|
344
|
+
// Fill the booking process status
|
345
|
+
this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(response.cart.stepsToStatus);
|
346
|
+
cartDueDate = new Date();
|
347
|
+
cartDueDate.setSeconds(cartDueDate.getSeconds() + response.cart.bookingDueDateRemainingSeconds);
|
348
|
+
this.bookingDueDate = cartDueDate;
|
349
|
+
// Update the sellerId. This is particularly important in Linkavel
|
350
|
+
this.updateSellerId(response.cart.sellerId);
|
351
|
+
return [2 /*return*/, response.cart];
|
352
|
+
case 1:
|
353
|
+
// Fetch & update local properties
|
354
|
+
return [4 /*yield*/, this.fetchAndSetCart(response.cartGuid)];
|
355
|
+
case 2:
|
356
|
+
// Fetch & update local properties
|
357
|
+
_a.sent();
|
358
|
+
if (!this.cart) {
|
359
|
+
// Should already be handled, but just in case
|
360
|
+
throw new Error("Could not fetch cart");
|
361
|
+
}
|
362
|
+
// Update storage
|
363
|
+
this.getStorage().getState().updateCartGuid(response.cart.guid);
|
364
|
+
return [2 /*return*/, this.cart];
|
365
|
+
}
|
366
|
+
});
|
367
|
+
}); })];
|
353
368
|
});
|
354
369
|
});
|
355
370
|
};
|
@@ -134,30 +134,25 @@ var TplBooking = /** @class */ (function (_super) {
|
|
134
134
|
return __awaiter(this, void 0, void 0, function () {
|
135
135
|
var _this = this;
|
136
136
|
return __generator(this, function (_a) {
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
_this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(cart.stepsToStatus);
|
150
|
-
}
|
151
|
-
else {
|
152
|
-
// This should never happen, but just in case
|
153
|
-
_this.resetBooking();
|
154
|
-
}
|
137
|
+
return [2 /*return*/, this.fetchCart(cartGuid, options).then(function (cart) {
|
138
|
+
if (cart) {
|
139
|
+
var cartDueDate = new Date();
|
140
|
+
cartDueDate.setSeconds(cartDueDate.getSeconds() + cart.bookingDueDateRemainingSeconds);
|
141
|
+
if (cartDueDate > new Date() && !cart.hasIssuedTickets) {
|
142
|
+
_this.cart = cart;
|
143
|
+
_this.cartGuid = cart.guid;
|
144
|
+
_this.bookingDueDate = cartDueDate; // See Booking class
|
145
|
+
// Update the sellerId. This is particularly important in Linkavel
|
146
|
+
_this.updateSellerId(cart.sellerId);
|
147
|
+
// Fill the booking process status
|
148
|
+
_this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(cart.stepsToStatus);
|
155
149
|
}
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
150
|
+
else {
|
151
|
+
// This should never happen, but just in case
|
152
|
+
_this.resetBooking();
|
153
|
+
}
|
154
|
+
}
|
155
|
+
})];
|
161
156
|
});
|
162
157
|
});
|
163
158
|
};
|
@@ -329,26 +324,46 @@ var TplBooking = /** @class */ (function (_super) {
|
|
329
324
|
renewSubscriptionTicketPNR: tplCart.renewSubscriptionTicketPNR
|
330
325
|
})), (tplCart.otaResellerId !== undefined && { otaResellerId: tplCart.otaResellerId })), (tplCart.otaTicketPicture !== undefined && { otaTicketPicture: tplCart.otaTicketPicture }));
|
331
326
|
// Call the API
|
332
|
-
return [2 /*return*/, this.callPostApi(url, request, options).then(function (response) {
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
327
|
+
return [2 /*return*/, this.callPostApi(url, request, options).then(function (response) { return __awaiter(_this, void 0, void 0, function () {
|
328
|
+
var cartDueDate;
|
329
|
+
return __generator(this, function (_a) {
|
330
|
+
switch (_a.label) {
|
331
|
+
case 0:
|
332
|
+
// Check for errors
|
333
|
+
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
334
|
+
// If there was an error, reset cartGuid and remove it from the mts-storage
|
335
|
+
this.resetBooking();
|
336
|
+
return [2 /*return*/, response];
|
337
|
+
}
|
338
|
+
if (!response.cart) return [3 /*break*/, 1];
|
339
|
+
this.cart = response.cart;
|
340
|
+
this.cartGuid = response.cart.guid;
|
341
|
+
// Save the cartGuid in the mts-storage
|
342
|
+
this.getStorage().getState().updateCartGuid(response.cart.guid);
|
343
|
+
// Fill the booking process status
|
344
|
+
this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(response.cart.stepsToStatus);
|
345
|
+
cartDueDate = new Date();
|
346
|
+
cartDueDate.setSeconds(cartDueDate.getSeconds() + response.cart.bookingDueDateRemainingSeconds);
|
347
|
+
this.bookingDueDate = cartDueDate;
|
348
|
+
// Update the sellerId. This is particularly important in Linkavel
|
349
|
+
this.updateSellerId(response.cart.sellerId);
|
350
|
+
return [2 /*return*/, response.cart];
|
351
|
+
case 1:
|
352
|
+
// Fetch & update local properties
|
353
|
+
return [4 /*yield*/, this.fetchAndSetCart(response.cartGuid)];
|
354
|
+
case 2:
|
355
|
+
// Fetch & update local properties
|
356
|
+
_a.sent();
|
357
|
+
if (!this.cart) {
|
358
|
+
// Should already be handled, but just in case
|
359
|
+
throw new Error("Could not fetch cart");
|
360
|
+
}
|
361
|
+
// Update storage
|
362
|
+
this.getStorage().getState().updateCartGuid(response.cart.guid);
|
363
|
+
return [2 /*return*/, this.cart];
|
364
|
+
}
|
365
|
+
});
|
366
|
+
}); })];
|
352
367
|
});
|
353
368
|
});
|
354
369
|
};
|
package/lib/utils/apiCall.js
CHANGED
@@ -104,7 +104,7 @@ var makeGet = function (url, options) { return __awaiter(void 0, void 0, void 0,
|
|
104
104
|
if (axios_1.default.isCancel(error_1)) {
|
105
105
|
// Log cancellation
|
106
106
|
if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST)
|
107
|
-
console.log("
|
107
|
+
console.log("GET_RequestCanceled", url);
|
108
108
|
// Resolve with empty object
|
109
109
|
resolve({});
|
110
110
|
}
|
@@ -173,7 +173,7 @@ var makePost = function (url, data, options) { return __awaiter(void 0, void 0,
|
|
173
173
|
if (axios_1.default.isCancel(error_2)) {
|
174
174
|
// Log cancellation
|
175
175
|
if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST)
|
176
|
-
console.log("
|
176
|
+
console.log("POST_RequestCanceled", url);
|
177
177
|
// Resolve with empty object
|
178
178
|
resolve({});
|
179
179
|
}
|
@@ -242,7 +242,7 @@ var makePut = function (url, data, options) { return __awaiter(void 0, void 0, v
|
|
242
242
|
if (axios_1.default.isCancel(error_3)) {
|
243
243
|
// Log cancellation
|
244
244
|
if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST)
|
245
|
-
console.log("
|
245
|
+
console.log("PUT_RequestCanceled", url);
|
246
246
|
// Resolve with empty object
|
247
247
|
resolve({});
|
248
248
|
}
|
@@ -311,7 +311,7 @@ var makeDelete = function (url, options) { return __awaiter(void 0, void 0, void
|
|
311
311
|
if (axios_1.default.isCancel(error_4)) {
|
312
312
|
// Log cancellation
|
313
313
|
if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST)
|
314
|
-
console.log("
|
314
|
+
console.log("DELETE_RequestCanceled", url);
|
315
315
|
// Resolve with empty object
|
316
316
|
resolve({});
|
317
317
|
}
|