mts-booking-library 1.3.24 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,7 @@
1
1
  import { MTSConfig, MTSEnvs } from "../config";
2
2
  import { ErrorResponse } from "../types/ErrorResponse";
3
- import { processedStepsToStatus } from "../types/common/Cart";
3
+ import { Cart, processedStepsToStatus } from "../types/common/Cart";
4
+ import { GetExtrasForBookingResponse, GetExtrasResponse } from "../types/common/Extra";
4
5
  import { GetPaymentInformationFromGatewayResponse, GetSellerGatewaysResponse, PaymentMethods, IssueTicketsResponse } from "../types/common/Payment";
5
6
  import { Buyer, GetBuyerPassengersDetailsResponse, GetBuyerRequest } from "../types/common/Person";
6
7
  import { AddReductionRequest } from "../types/common/Reduction";
@@ -20,7 +21,7 @@ export declare abstract class Booking {
20
21
  * - The third tells whether the section is required. <br/>
21
22
  */
22
23
  bookingStepsToStatus: processedStepsToStatus;
23
- /** @deprecated Please use {@link Booking.cartGuid} instead */
24
+ /** @deprecated Please use {@link cartGuid} instead */
24
25
  cartId: number | undefined;
25
26
  cartGuid: string | undefined;
26
27
  bookingDueDate: Date | undefined;
@@ -42,6 +43,7 @@ export declare abstract class Booking {
42
43
  renewAccessToken(access_token: string): void;
43
44
  callGetApi(url: string): Promise<ErrorResponse | any>;
44
45
  callPostApi(url: string, body: any): Promise<any>;
46
+ callPutApi(url: string, body: any): Promise<any>;
45
47
  callDeleteApi(url: string): Promise<ErrorResponse | any>;
46
48
  getBookingStepsToStatus(): processedStepsToStatus;
47
49
  changeCurrency(currency: Booking.Currencies): void;
@@ -69,8 +71,8 @@ export declare abstract class Booking {
69
71
  getSellerGateways(): Promise<ErrorResponse | GetSellerGatewaysResponse>;
70
72
  /**
71
73
  * @description This method shall be used to get all necessary informations to initialize a payment with a certain gateway.
72
- * @param {number} gatewayId The id of the gateway to use. Its value shall be taken from the response of the {@link Booking.getSellerGateways} API
73
- * @param {string} [returnUrl=undefined] The url to which the user will be redirected after the payment. This value shall be set only if the
74
+ * @param gatewayId The id of the gateway to use. Its value shall be taken from the response of the {@link Booking.getSellerGateways} API
75
+ * @param returnUrl The url to which the user will be redirected after the payment. This value shall be set only if the
74
76
  * chosen gateway is {@link GatewayTypes.PAYPAL} or {@link GatewayTypes.WORLDLINE}
75
77
  * @returns An {@link ErrorResponse} object in case of error, a {@link GetPaymentInformationFromGatewayResponse} object otherwise.
76
78
  */
@@ -82,6 +84,28 @@ export declare abstract class Booking {
82
84
  * @returns An {@link IssueTicketsResponse} object.
83
85
  */
84
86
  issueTickets(paymentMethod: PaymentMethods): Promise<ErrorResponse | IssueTicketsResponse>;
87
+ getExtras({ extraId, tariffPlanId }?: {
88
+ /** The extra object identifier. By default, all the extras of the seller are returned. */
89
+ extraId?: number;
90
+ /** If present, the extras that are part of that tariff plan are returned. */
91
+ tariffPlanId?: number;
92
+ }): Promise<ErrorResponse | GetExtrasResponse>;
93
+ /**
94
+ * Fetches extras tariffs for the given cart
95
+ * @param cartGuid The guid of the cart
96
+ * @param tripId The ID of the trip for which the extras are requested. Please note that this
97
+ * parameter is required when adding extras to a MLP or services cart.
98
+ */
99
+ getExtrasForBooking(cartGuid: string, tripId?: number): Promise<ErrorResponse | GetExtrasForBookingResponse>;
100
+ /**
101
+ * Updates the extras associated with a cart, removing all previous ones.
102
+ * @param cartGuid The guid of the cart
103
+ * @param tariffIdToQuantity A map of tariff ids to the quantity of tickets to add for that tariff
104
+ */
105
+ updateExtrasForCart(cartGuid: string, tariffIdToQuantity: Record<number, number>): Promise<ErrorResponse | {}>;
106
+ abstract getCart(): Cart | undefined;
107
+ abstract fetchAndSetCart(cartGuid: string): Promise<void>;
108
+ abstract fetchCart(cartGuid: string): Promise<Cart>;
85
109
  }
86
110
  export declare namespace Booking {
87
111
  enum Currencies {
@@ -53,6 +53,7 @@ var ErrorResponse_1 = require("../types/ErrorResponse");
53
53
  var Payment_1 = require("../types/common/Payment");
54
54
  var apiCall_1 = require("../utils/apiCall");
55
55
  var processBookingSteps_1 = require("../utils/processBookingSteps");
56
+ var utils_1 = require("../utils/utils");
56
57
  var Booking = /** @class */ (function () {
57
58
  /**
58
59
  * This is the constructor of the Booking class. See {@link Booking.BookingConfig} for more information.
@@ -124,6 +125,13 @@ var Booking = /** @class */ (function () {
124
125
  (0, config_1.getConfig)().DB_TYPE && { databaseType: (0, config_1.getConfig)().DB_TYPE }));
125
126
  return (0, apiCall_1.makePost)(url, completeBody);
126
127
  };
128
+ Booking.prototype.callPutApi = function (url, body) {
129
+ var _a, _b, _c, _d;
130
+ // Add sellerId, resellerId and language to the query string
131
+ var completeBody = __assign(__assign(__assign({}, body), { sellerId: (_b = (_a = this.sellerId) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : 0, resellerId: (_d = (_c = this.resellerId) === null || _c === void 0 ? void 0 : _c.toString()) !== null && _d !== void 0 ? _d : 0, language: this.language }), ((0, config_1.getConfig)().ENV === config_1.MTSEnvs.DEV &&
132
+ (0, config_1.getConfig)().DB_TYPE && { databaseType: (0, config_1.getConfig)().DB_TYPE }));
133
+ return (0, apiCall_1.makePut)(url, completeBody);
134
+ };
127
135
  Booking.prototype.callDeleteApi = function (url) {
128
136
  var _a, _b, _c, _d;
129
137
  // Add sellerId, resellerId and language to the query string.
@@ -160,7 +168,7 @@ var Booking = /** @class */ (function () {
160
168
  var _this = this;
161
169
  return __generator(this, function (_a) {
162
170
  // First check that it is possible to call this API
163
- if (!this.cartId || this.cartId === 0) {
171
+ if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
164
172
  throw Error("Cart is not initialized yet");
165
173
  }
166
174
  currentStepStatus = this.bookingStepsToStatus.get(bookingStep);
@@ -174,7 +182,7 @@ var Booking = /** @class */ (function () {
174
182
  // Booking step is already completed, no need to call the API
175
183
  if (currentStepStatus[0])
176
184
  return [2 /*return*/, true];
177
- url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/").concat(this.cartId, "/bookingSteps");
185
+ url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/bookingSteps");
178
186
  return [2 /*return*/, this.callPostApi(url, { bookingStep: bookingStep }).then(function (response) {
179
187
  if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
180
188
  return response;
@@ -200,7 +208,7 @@ var Booking = /** @class */ (function () {
200
208
  switch (_c.label) {
201
209
  case 0:
202
210
  // First check that it is possible to call this API
203
- if (!this.cartId || this.cartId === 0) {
211
+ if (!this.cartGuid || (0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
204
212
  throw Error("Cart is not initialized yet");
205
213
  }
206
214
  issueStep = this.bookingStepsToStatus.get(Booking.BookingSteps.ISSUE);
@@ -245,8 +253,8 @@ var Booking = /** @class */ (function () {
245
253
  };
246
254
  /**
247
255
  * @description This method shall be used to get all necessary informations to initialize a payment with a certain gateway.
248
- * @param {number} gatewayId The id of the gateway to use. Its value shall be taken from the response of the {@link Booking.getSellerGateways} API
249
- * @param {string} [returnUrl=undefined] The url to which the user will be redirected after the payment. This value shall be set only if the
256
+ * @param gatewayId The id of the gateway to use. Its value shall be taken from the response of the {@link Booking.getSellerGateways} API
257
+ * @param returnUrl The url to which the user will be redirected after the payment. This value shall be set only if the
250
258
  * chosen gateway is {@link GatewayTypes.PAYPAL} or {@link GatewayTypes.WORLDLINE}
251
259
  * @returns An {@link ErrorResponse} object in case of error, a {@link GetPaymentInformationFromGatewayResponse} object otherwise.
252
260
  */
@@ -255,15 +263,15 @@ var Booking = /** @class */ (function () {
255
263
  var issueStep, searchParams, url;
256
264
  return __generator(this, function (_a) {
257
265
  // First check that it is possible to call this API
258
- if (!this.cartId || this.cartId === 0) {
266
+ if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
259
267
  throw Error("Cart is not initialized yet");
260
268
  }
261
269
  issueStep = this.bookingStepsToStatus.get(Booking.BookingSteps.ISSUE);
262
270
  if (!issueStep || !issueStep[0]) {
263
271
  throw Error("The status of the cart does not allow to call this API");
264
272
  }
265
- searchParams = new URLSearchParams(__assign({ gatewayId: gatewayId.toString() }, (returnUrl && { returnUrl: returnUrl })));
266
- url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/").concat(this.cartId, "/payment?").concat(searchParams);
273
+ searchParams = new URLSearchParams(__assign({ gatewayId: gatewayId.toString(), cartGuid: this.cartGuid }, (returnUrl && { returnUrl: returnUrl })));
274
+ url = "".concat(this.config.API_ENDPOINT, "/v3_payment/paymentInformation?").concat(searchParams);
267
275
  return [2 /*return*/, this.callGetApi(url).then(function (response) {
268
276
  return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response)
269
277
  ? response
@@ -272,6 +280,7 @@ var Booking = /** @class */ (function () {
272
280
  });
273
281
  });
274
282
  };
283
+ // TODO: Rename this as issueCart
275
284
  /**
276
285
  * @description This method shall be used to issue the tickets. It must be called after the payment was successful.
277
286
  * @param {PaymentMethods} paymentMethod The payment method used to pay the cart. If the chosen method is {@link PaymentMethods.ZERO_COST},
@@ -348,6 +357,65 @@ var Booking = /** @class */ (function () {
348
357
  });
349
358
  });
350
359
  };
360
+ //#endregion
361
+ // #region Extras
362
+ Booking.prototype.getExtras = function () {
363
+ return __awaiter(this, arguments, void 0, function (_a) {
364
+ var searchParams, url;
365
+ var _b = _a === void 0 ? {} : _a, extraId = _b.extraId, tariffPlanId = _b.tariffPlanId;
366
+ return __generator(this, function (_c) {
367
+ searchParams = new URLSearchParams(__assign(__assign({}, (extraId && { extraId: extraId.toString() })), (tariffPlanId && { tariffPlanId: tariffPlanId.toString() })));
368
+ url = "".concat(this.config.API_ENDPOINT, "/v3_resources/extras?").concat(searchParams);
369
+ return [2 /*return*/, this.callGetApi(url)];
370
+ });
371
+ });
372
+ };
373
+ /**
374
+ * Fetches extras tariffs for the given cart
375
+ * @param cartGuid The guid of the cart
376
+ * @param tripId The ID of the trip for which the extras are requested. Please note that this
377
+ * parameter is required when adding extras to a MLP or services cart.
378
+ */
379
+ Booking.prototype.getExtrasForBooking = function (cartGuid, tripId) {
380
+ return __awaiter(this, void 0, void 0, function () {
381
+ var searchParams, url;
382
+ return __generator(this, function (_a) {
383
+ searchParams = new URLSearchParams(__assign({ cartGuid: cartGuid }, (tripId && { tripId: tripId.toString() })));
384
+ url = "".concat(this.config.API_ENDPOINT, "/v3_booking/extras?").concat(searchParams);
385
+ return [2 /*return*/, this.callGetApi(url)];
386
+ });
387
+ });
388
+ };
389
+ /**
390
+ * Updates the extras associated with a cart, removing all previous ones.
391
+ * @param cartGuid The guid of the cart
392
+ * @param tariffIdToQuantity A map of tariff ids to the quantity of tickets to add for that tariff
393
+ */
394
+ Booking.prototype.updateExtrasForCart = function (cartGuid, tariffIdToQuantity) {
395
+ return __awaiter(this, void 0, void 0, function () {
396
+ var body, url, res;
397
+ return __generator(this, function (_a) {
398
+ switch (_a.label) {
399
+ case 0:
400
+ body = {
401
+ cartGuid: cartGuid,
402
+ tariffIdToQuantity: tariffIdToQuantity
403
+ };
404
+ url = "".concat(this.config.API_ENDPOINT, "/v3_booking/extras");
405
+ return [4 /*yield*/, this.callPutApi(url, body)];
406
+ case 1:
407
+ res = _a.sent();
408
+ if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(res)) {
409
+ return [2 /*return*/, res];
410
+ }
411
+ return [4 /*yield*/, this.fetchAndSetCart(cartGuid)];
412
+ case 2:
413
+ _a.sent();
414
+ return [2 /*return*/, res];
415
+ }
416
+ });
417
+ });
418
+ };
351
419
  return Booking;
352
420
  }());
353
421
  exports.Booking = Booking;
@@ -77,6 +77,7 @@ var mtsStorage_1 = require("../mtsStorage");
77
77
  var ErrorResponse_1 = require("../types/ErrorResponse");
78
78
  var Reduction_1 = require("../types/common/Reduction");
79
79
  var processBookingSteps_1 = require("../utils/processBookingSteps");
80
+ var utils_1 = require("../utils/utils");
80
81
  var booking_1 = require("./booking");
81
82
  var JourneyBooking = /** @class */ (function (_super) {
82
83
  __extends(JourneyBooking, _super);
@@ -354,6 +355,7 @@ var JourneyBooking = /** @class */ (function (_super) {
354
355
  });
355
356
  });
356
357
  };
358
+ // TODO: rename this as getPerson and use personDetails as return type
357
359
  /**
358
360
  * @description This method shall be called when the user wants to retrieve information about an esisting buyer.
359
361
  * @param {GetBuyerRequest} request The object containing the parameters to search the buyer.
@@ -562,7 +564,7 @@ var JourneyBooking = /** @class */ (function (_super) {
562
564
  switch (_c.label) {
563
565
  case 0:
564
566
  // First check that it is possible to call this API
565
- if (!this.cartId || this.cartId === 0) {
567
+ if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
566
568
  throw Error("Cart is not initialized yet");
567
569
  }
568
570
  discountsStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.DISCOUNTS);
@@ -590,8 +592,8 @@ var JourneyBooking = /** @class */ (function (_super) {
590
592
  }
591
593
  _c.label = 5;
592
594
  case 5:
593
- url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/").concat(this.cartId, "/payment/reduction");
594
- return [2 /*return*/, this.callPostApi(url, request).then(function (response) {
595
+ url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/reduction");
596
+ return [2 /*return*/, this.callPostApi(url, __assign(__assign({}, request), { cartId: this.cartId, cartGuid: this.cartGuid })).then(function (response) {
595
597
  var _a, _b;
596
598
  if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
597
599
  return response;
@@ -619,15 +621,15 @@ var JourneyBooking = /** @class */ (function (_super) {
619
621
  var _this = this;
620
622
  return __generator(this, function (_a) {
621
623
  // First check that it is possible to call this API
622
- if (!this.cartId || this.cartId === 0) {
624
+ if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
623
625
  throw Error("Cart is not initialized yet");
624
626
  }
625
627
  discountsStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.DISCOUNTS);
626
628
  if (!discountsStep || !discountsStep[0]) {
627
629
  throw Error("The status of the cart does not allow to call this API");
628
630
  }
629
- queryParams = new URLSearchParams({ tripId: tripId.toString() });
630
- url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/").concat(this.cartId, "/payment/reduction?").concat(queryParams);
631
+ queryParams = new URLSearchParams({ tripId: tripId.toString(), cartId: this.cartId.toString(), cartGuid: this.cartGuid });
632
+ url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/reduction?").concat(queryParams);
631
633
  return [2 /*return*/, this.callDeleteApi(url).then(function (response) {
632
634
  var _a, _b, _c;
633
635
  if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
@@ -662,7 +664,7 @@ var JourneyBooking = /** @class */ (function (_super) {
662
664
  switch (_c.label) {
663
665
  case 0:
664
666
  // First check that it is possible to call this API
665
- if (!this.cartId || this.cartId === 0) {
667
+ if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
666
668
  throw Error("Cart is not initialized yet");
667
669
  }
668
670
  issueStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.ISSUE);
@@ -690,12 +692,12 @@ var JourneyBooking = /** @class */ (function (_super) {
690
692
  // Check again if the discounts step is accessible
691
693
  issueStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.ISSUE);
692
694
  if (!issueStep || !issueStep[0]) {
693
- throw Error("The status of the cart does not allow to call the API: booking/carts/".concat(this.cartId, "/payment/wallet"));
695
+ throw Error("The status of the cart does not allow to call the API: booking/carts/payment/wallet");
694
696
  }
695
697
  _c.label = 5;
696
698
  case 5:
697
- url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/").concat(this.cartId, "/payment/wallet");
698
- return [2 /*return*/, this.callPostApi(url, {}).then(function (response) {
699
+ url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/wallet");
700
+ return [2 /*return*/, this.callPostApi(url, { cartId: this.cartId, cartGuid: this.cartGuid }).then(function (response) {
699
701
  var _a, _b;
700
702
  if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
701
703
  return response;
@@ -718,14 +720,15 @@ var JourneyBooking = /** @class */ (function (_super) {
718
720
  */
719
721
  JourneyBooking.prototype.removeWalletReduction = function () {
720
722
  return __awaiter(this, void 0, void 0, function () {
721
- var url;
723
+ var queryParams, url;
722
724
  var _this = this;
723
725
  return __generator(this, function (_a) {
724
726
  // First check that it is possible to call this API
725
- if (!this.cartId || this.cartId === 0) {
727
+ if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
726
728
  throw Error("Cart is not initialized yet");
727
729
  }
728
- url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/").concat(this.cartId, "/payment/wallet");
730
+ queryParams = new URLSearchParams({ cartId: this.cartId.toString(), cartGuid: this.cartGuid });
731
+ url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/wallet?").concat(queryParams);
729
732
  return [2 /*return*/, this.callDeleteApi(url).then(function (response) {
730
733
  var _a, _b, _c;
731
734
  if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
@@ -77,6 +77,7 @@ var mtsStorage_1 = require("../mtsStorage");
77
77
  var ErrorResponse_1 = require("../types/ErrorResponse");
78
78
  var Reduction_1 = require("../types/common/Reduction");
79
79
  var processBookingSteps_1 = require("../utils/processBookingSteps");
80
+ var utils_1 = require("../utils/utils");
80
81
  var booking_1 = require("./booking");
81
82
  var ServiceBooking = /** @class */ (function (_super) {
82
83
  __extends(ServiceBooking, _super);
@@ -419,7 +420,7 @@ var ServiceBooking = /** @class */ (function (_super) {
419
420
  switch (_c.label) {
420
421
  case 0:
421
422
  // First check that it is possible to call this API
422
- if (!this.cartId || this.cartId === 0) {
423
+ if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
423
424
  throw Error("Cart is not initialized yet");
424
425
  }
425
426
  discountsStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.DISCOUNTS);
@@ -447,8 +448,8 @@ var ServiceBooking = /** @class */ (function (_super) {
447
448
  }
448
449
  _c.label = 5;
449
450
  case 5:
450
- url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/").concat(this.cartId, "/payment/reduction");
451
- return [2 /*return*/, this.callPostApi(url, request).then(function (response) {
451
+ url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/reduction");
452
+ return [2 /*return*/, this.callPostApi(url, __assign(__assign({}, request), { cartId: this.cartId, cartGuid: this.cartGuid })).then(function (response) {
452
453
  var _a, _b;
453
454
  if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
454
455
  return response;
@@ -476,15 +477,15 @@ var ServiceBooking = /** @class */ (function (_super) {
476
477
  var _this = this;
477
478
  return __generator(this, function (_a) {
478
479
  // First check that it is possible to call this API
479
- if (!this.cartId || this.cartId === 0) {
480
+ if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
480
481
  throw Error("Cart is not initialized yet");
481
482
  }
482
483
  discountsStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.DISCOUNTS);
483
484
  if (!discountsStep || !discountsStep[0]) {
484
485
  throw Error("The status of the cart does not allow to call this API");
485
486
  }
486
- queryParams = new URLSearchParams({ tripId: tripId.toString() });
487
- url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/").concat(this.cartId, "/payment/reduction?").concat(queryParams);
487
+ queryParams = new URLSearchParams({ tripId: tripId.toString(), cartId: this.cartId.toString(), cartGuid: this.cartGuid });
488
+ url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/reduction?").concat(queryParams);
488
489
  return [2 /*return*/, this.callDeleteApi(url).then(function (response) {
489
490
  var _a, _b, _c;
490
491
  if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
@@ -519,7 +520,7 @@ var ServiceBooking = /** @class */ (function (_super) {
519
520
  switch (_c.label) {
520
521
  case 0:
521
522
  // First check that it is possible to call this API
522
- if (!this.cartId || this.cartId === 0) {
523
+ if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
523
524
  throw Error("Cart is not initialized yet");
524
525
  }
525
526
  issueStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.ISSUE);
@@ -547,12 +548,12 @@ var ServiceBooking = /** @class */ (function (_super) {
547
548
  // Check again if the discounts step is accessible
548
549
  issueStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.ISSUE);
549
550
  if (!issueStep || !issueStep[0]) {
550
- throw Error("The status of the cart does not allow to call the API: booking/carts/".concat(this.cartId, "/payment/wallet"));
551
+ throw Error("The status of the cart does not allow to call the API: booking/carts/payment/wallet");
551
552
  }
552
553
  _c.label = 5;
553
554
  case 5:
554
- url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/").concat(this.cartId, "/payment/wallet");
555
- return [2 /*return*/, this.callPostApi(url, {}).then(function (response) {
555
+ url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/wallet");
556
+ return [2 /*return*/, this.callPostApi(url, { cartId: this.cartId, cartGuid: this.cartGuid }).then(function (response) {
556
557
  var _a, _b;
557
558
  if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
558
559
  return response;
@@ -575,14 +576,15 @@ var ServiceBooking = /** @class */ (function (_super) {
575
576
  */
576
577
  ServiceBooking.prototype.removeWalletReduction = function () {
577
578
  return __awaiter(this, void 0, void 0, function () {
578
- var url;
579
+ var queryParams, url;
579
580
  var _this = this;
580
581
  return __generator(this, function (_a) {
581
582
  // First check that it is possible to call this API
582
- if (!this.cartId || this.cartId === 0) {
583
+ if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
583
584
  throw Error("Cart is not initialized yet");
584
585
  }
585
- url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/").concat(this.cartId, "/payment/wallet");
586
+ queryParams = new URLSearchParams({ cartId: this.cartId.toString(), cartGuid: this.cartGuid });
587
+ url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/wallet?").concat(queryParams);
586
588
  return [2 /*return*/, this.callDeleteApi(url).then(function (response) {
587
589
  var _a, _b, _c;
588
590
  if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
@@ -77,6 +77,7 @@ var mtsStorage_1 = require("../mtsStorage");
77
77
  var ErrorResponse_1 = require("../types/ErrorResponse");
78
78
  var Reduction_1 = require("../types/common/Reduction");
79
79
  var processBookingSteps_1 = require("../utils/processBookingSteps");
80
+ var utils_1 = require("../utils/utils");
80
81
  var booking_1 = require("./booking");
81
82
  var SubscriptionBooking = /** @class */ (function (_super) {
82
83
  __extends(SubscriptionBooking, _super);
@@ -499,7 +500,7 @@ var SubscriptionBooking = /** @class */ (function (_super) {
499
500
  switch (_c.label) {
500
501
  case 0:
501
502
  // First check that it is possible to call this API
502
- if (!this.cartId || this.cartId === 0) {
503
+ if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
503
504
  throw Error("Cart is not initialized yet");
504
505
  }
505
506
  discountsStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.DISCOUNTS);
@@ -527,8 +528,8 @@ var SubscriptionBooking = /** @class */ (function (_super) {
527
528
  }
528
529
  _c.label = 5;
529
530
  case 5:
530
- url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/").concat(this.cartId, "/payment/reduction");
531
- return [2 /*return*/, this.callPostApi(url, request).then(function (response) {
531
+ url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/reduction");
532
+ return [2 /*return*/, this.callPostApi(url, __assign(__assign({}, request), { cartId: this.cartId, cartGuid: this.cartGuid })).then(function (response) {
532
533
  var _a, _b;
533
534
  if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
534
535
  return response;
@@ -556,15 +557,15 @@ var SubscriptionBooking = /** @class */ (function (_super) {
556
557
  var _this = this;
557
558
  return __generator(this, function (_a) {
558
559
  // First check that it is possible to call this API
559
- if (!this.cartId || this.cartId === 0) {
560
+ if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
560
561
  throw Error("Cart is not initialized yet");
561
562
  }
562
563
  discountsStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.DISCOUNTS);
563
564
  if (!discountsStep || !discountsStep[0]) {
564
565
  throw Error("The status of the cart does not allow to call this API");
565
566
  }
566
- queryParams = new URLSearchParams({ tripId: tripId.toString() });
567
- url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/").concat(this.cartId, "/payment/reduction?").concat(queryParams);
567
+ queryParams = new URLSearchParams({ tripId: tripId.toString(), cartId: this.cartId.toString(), cartGuid: this.cartGuid });
568
+ url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/reduction?").concat(queryParams);
568
569
  return [2 /*return*/, this.callDeleteApi(url).then(function (response) {
569
570
  var _a, _b, _c;
570
571
  if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
@@ -599,7 +600,7 @@ var SubscriptionBooking = /** @class */ (function (_super) {
599
600
  switch (_c.label) {
600
601
  case 0:
601
602
  // First check that it is possible to call this API
602
- if (!this.cartId || this.cartId === 0) {
603
+ if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
603
604
  throw Error("Cart is not initialized yet");
604
605
  }
605
606
  issueStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.ISSUE);
@@ -627,12 +628,12 @@ var SubscriptionBooking = /** @class */ (function (_super) {
627
628
  // Check again if the discounts step is accessible
628
629
  issueStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.ISSUE);
629
630
  if (!issueStep || !issueStep[0]) {
630
- throw Error("The status of the cart does not allow to call the API: booking/carts/".concat(this.cartId, "/payment/wallet"));
631
+ throw Error("The status of the cart does not allow to call the API: booking/carts/payment/wallet");
631
632
  }
632
633
  _c.label = 5;
633
634
  case 5:
634
- url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/").concat(this.cartId, "/payment/wallet");
635
- return [2 /*return*/, this.callPostApi(url, {}).then(function (response) {
635
+ url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/wallet");
636
+ return [2 /*return*/, this.callPostApi(url, { cartId: this.cartId, cartGuid: this.cartGuid }).then(function (response) {
636
637
  var _a, _b;
637
638
  if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
638
639
  return response;
@@ -655,14 +656,15 @@ var SubscriptionBooking = /** @class */ (function (_super) {
655
656
  */
656
657
  SubscriptionBooking.prototype.removeWalletReduction = function () {
657
658
  return __awaiter(this, void 0, void 0, function () {
658
- var url;
659
+ var queryParams, url;
659
660
  var _this = this;
660
661
  return __generator(this, function (_a) {
661
662
  // First check that it is possible to call this API
662
- if (!this.cartId || this.cartId === 0) {
663
+ if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
663
664
  throw Error("Cart is not initialized yet");
664
665
  }
665
- url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/").concat(this.cartId, "/payment/wallet");
666
+ queryParams = new URLSearchParams({ cartId: this.cartId.toString(), cartGuid: this.cartGuid });
667
+ url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/wallet?").concat(queryParams);
666
668
  return [2 /*return*/, this.callDeleteApi(url).then(function (response) {
667
669
  var _a, _b, _c;
668
670
  if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
@@ -77,6 +77,7 @@ var mtsStorage_1 = require("../mtsStorage");
77
77
  var ErrorResponse_1 = require("../types/ErrorResponse");
78
78
  var Reduction_1 = require("../types/common/Reduction");
79
79
  var processBookingSteps_1 = require("../utils/processBookingSteps");
80
+ var utils_1 = require("../utils/utils");
80
81
  var booking_1 = require("./booking");
81
82
  var TplBooking = /** @class */ (function (_super) {
82
83
  __extends(TplBooking, _super);
@@ -226,6 +227,7 @@ var TplBooking = /** @class */ (function (_super) {
226
227
  });
227
228
  });
228
229
  };
230
+ // TODO: use v3_resources/superAreas
229
231
  /**
230
232
  * This method fetches the list of super areas for a given city. A super area is a region of the city in which
231
233
  * the TPL service is available at a certain price.
@@ -491,7 +493,7 @@ var TplBooking = /** @class */ (function (_super) {
491
493
  switch (_c.label) {
492
494
  case 0:
493
495
  // First check that it is possible to call this API
494
- if (!this.cartId || this.cartId === 0) {
496
+ if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
495
497
  throw Error("Cart is not initialized yet");
496
498
  }
497
499
  discountsStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.DISCOUNTS);
@@ -519,8 +521,8 @@ var TplBooking = /** @class */ (function (_super) {
519
521
  }
520
522
  _c.label = 5;
521
523
  case 5:
522
- url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/").concat(this.cartId, "/payment/reduction");
523
- return [2 /*return*/, this.callPostApi(url, request).then(function (response) {
524
+ url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/reduction");
525
+ return [2 /*return*/, this.callPostApi(url, __assign(__assign({}, request), { cartId: this.cartId, cartGuid: this.cartGuid })).then(function (response) {
524
526
  var _a, _b;
525
527
  if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
526
528
  return response;
@@ -548,15 +550,15 @@ var TplBooking = /** @class */ (function (_super) {
548
550
  var _this = this;
549
551
  return __generator(this, function (_a) {
550
552
  // First check that it is possible to call this API
551
- if (!this.cartId || this.cartId === 0) {
553
+ if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
552
554
  throw Error("Cart is not initialized yet");
553
555
  }
554
556
  discountsStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.DISCOUNTS);
555
557
  if (!discountsStep || !discountsStep[0]) {
556
558
  throw Error("The status of the cart does not allow to call this API");
557
559
  }
558
- queryParams = new URLSearchParams({ tripId: tripId.toString() });
559
- url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/").concat(this.cartId, "/payment/reduction?").concat(queryParams);
560
+ queryParams = new URLSearchParams({ tripId: tripId.toString(), cartId: this.cartId.toString(), cartGuid: this.cartGuid });
561
+ url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/reduction?").concat(queryParams);
560
562
  return [2 /*return*/, this.callDeleteApi(url).then(function (response) {
561
563
  var _a, _b, _c;
562
564
  if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
@@ -591,7 +593,7 @@ var TplBooking = /** @class */ (function (_super) {
591
593
  switch (_c.label) {
592
594
  case 0:
593
595
  // First check that it is possible to call this API
594
- if (!this.cartId || this.cartId === 0) {
596
+ if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
595
597
  throw Error("Cart is not initialized yet");
596
598
  }
597
599
  issueStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.ISSUE);
@@ -619,12 +621,12 @@ var TplBooking = /** @class */ (function (_super) {
619
621
  // Check again if the discounts step is accessible
620
622
  issueStep = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.ISSUE);
621
623
  if (!issueStep || !issueStep[0]) {
622
- throw Error("The status of the cart does not allow to call the API: booking/carts/".concat(this.cartId, "/payment/wallet"));
624
+ throw Error("The status of the cart does not allow to call the API: booking/carts/payment/wallet");
623
625
  }
624
626
  _c.label = 5;
625
627
  case 5:
626
- url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/").concat(this.cartId, "/payment/wallet");
627
- return [2 /*return*/, this.callPostApi(url, {}).then(function (response) {
628
+ url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/wallet");
629
+ return [2 /*return*/, this.callPostApi(url, { cartId: this.cartId, cartGuid: this.cartGuid }).then(function (response) {
628
630
  var _a, _b;
629
631
  if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
630
632
  return response;
@@ -647,14 +649,15 @@ var TplBooking = /** @class */ (function (_super) {
647
649
  */
648
650
  TplBooking.prototype.removeWalletReduction = function () {
649
651
  return __awaiter(this, void 0, void 0, function () {
650
- var url;
652
+ var queryParams, url;
651
653
  var _this = this;
652
654
  return __generator(this, function (_a) {
653
655
  // First check that it is possible to call this API
654
- if (!this.cartId || this.cartId === 0) {
656
+ if ((0, utils_1.isNullOrWhiteSpace)(this.cartGuid)) {
655
657
  throw Error("Cart is not initialized yet");
656
658
  }
657
- url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/").concat(this.cartId, "/payment/wallet");
659
+ queryParams = new URLSearchParams({ cartId: this.cartId.toString(), cartGuid: this.cartGuid });
660
+ url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/payment/wallet?").concat(queryParams);
658
661
  return [2 /*return*/, this.callDeleteApi(url).then(function (response) {
659
662
  var _a, _b, _c;
660
663
  if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
package/lib/mtsStorage.js CHANGED
@@ -19,7 +19,9 @@ var INITIAL_STATE = {
19
19
  cartId: 0,
20
20
  cartGuid: undefined
21
21
  };
22
- var useMtsBookingAsyncState = (0, zustand_1.create)((0, middleware_1.persist)(function (set) { return (__assign(__assign({}, INITIAL_STATE), { updateCartId: function (cartId) { return set(function () { return ({ cartId: cartId }); }); }, resetState: function () { return set(function () { return INITIAL_STATE; }); } })); }, {
22
+ var useMtsBookingAsyncState = (0, zustand_1.create)((0, middleware_1.persist)(function (set) { return (__assign(__assign({}, INITIAL_STATE), { updateCartId: function (cartId, cartGuid) {
23
+ return set(function () { return ({ cartId: cartId, cartGuid: cartGuid }); });
24
+ }, resetState: function () { return set(function () { return INITIAL_STATE; }); } })); }, {
23
25
  name: "mts-booking-storage",
24
26
  storage: (0, middleware_1.createJSONStorage)(function () { return async_storage_1.default; })
25
27
  }));
@@ -1,4 +1,4 @@
1
- import { ExtraTariff } from "./Tariffs";
1
+ import { ExtraTariff, TariffsMatrix } from "./Tariffs";
2
2
  /**
3
3
  * @description this type represents an extra, which is an additional service that can be added to a cart. Extras are selected in the booking step `EXTRAS`.
4
4
  *
@@ -18,3 +18,15 @@ export type Extra = {
18
18
  notes: string;
19
19
  tariff: ExtraTariff;
20
20
  };
21
+ export type GetExtrasResponse = {
22
+ extras: {
23
+ id: number;
24
+ name: string;
25
+ description: string;
26
+ requiresNotes: boolean;
27
+ notes: string | null;
28
+ }[];
29
+ };
30
+ export type GetExtrasForBookingResponse = {
31
+ extraIdToTariffsMatrix: Record<number, TariffsMatrix>;
32
+ };
@@ -54,23 +54,26 @@ export declare enum GatewayTypes {
54
54
  PAYPAL = "PAYPAL"
55
55
  }
56
56
  /**
57
- * @enum {string} This enum contains the possible values for the `paymentMethod` parameter of the {@link Booking.issueTickets} function.
58
- *
59
- * @property {string} ZERO_COST: Only for Sellers: 100% discount
60
- * @property {string} PAY_LATER: Only for Sellers: Ticket will be paid at the counter/bus
61
- * @property {string} WALLET: Only for Resellers: the ticket will be paid with the wallet balance
62
- * @property {string} CARD: Pay with card at the Seller/Reseller counter
63
- * @property {string} CASH: Pay with cash at the Seller/Reseller counter
64
- * @property {string} ONLINE_CARD: Pay online using payment gateways
57
+ * This enum contains the possible values for the `paymentMethod` parameter of the
58
+ * {@link Booking.issueTickets} function.
65
59
  */
66
60
  export declare enum PaymentMethods {
61
+ /** Pay with card at the Seller/Reseller counter */
67
62
  CARD = "CARD",
63
+ /** Pay with cash at the Seller/Reseller counter */
68
64
  CASH = "CASH",
65
+ /** Pay with credit from change*/
69
66
  CREDIT_FROM_CHANGE = "CREDIT_FROM_CHANGE",
67
+ /** Only for Sellers: Ticket will be paid at the counter/bus */
70
68
  PAY_LATER = "PAY_LATER",
69
+ /** Pay online using payment gateways */
71
70
  ONLINE_CARD = "ONLINE_CARD",
71
+ /** Only for Resellers: the ticket will be paid with the wallet balance */
72
72
  WALLET = "WALLET",
73
- ZERO_COST = "ZERO_COST"
73
+ /** Only for Sellers: 100% discount */
74
+ ZERO_COST = "ZERO_COST",
75
+ /** Pay with a bank transfer */
76
+ TRANSFER = "TRANSFER"
74
77
  }
75
78
  export type Wallet = {
76
79
  id: number;
@@ -12,22 +12,25 @@ var GatewayTypes;
12
12
  GatewayTypes["PAYPAL"] = "PAYPAL";
13
13
  })(GatewayTypes || (exports.GatewayTypes = GatewayTypes = {}));
14
14
  /**
15
- * @enum {string} This enum contains the possible values for the `paymentMethod` parameter of the {@link Booking.issueTickets} function.
16
- *
17
- * @property {string} ZERO_COST: Only for Sellers: 100% discount
18
- * @property {string} PAY_LATER: Only for Sellers: Ticket will be paid at the counter/bus
19
- * @property {string} WALLET: Only for Resellers: the ticket will be paid with the wallet balance
20
- * @property {string} CARD: Pay with card at the Seller/Reseller counter
21
- * @property {string} CASH: Pay with cash at the Seller/Reseller counter
22
- * @property {string} ONLINE_CARD: Pay online using payment gateways
15
+ * This enum contains the possible values for the `paymentMethod` parameter of the
16
+ * {@link Booking.issueTickets} function.
23
17
  */
24
18
  var PaymentMethods;
25
19
  (function (PaymentMethods) {
20
+ /** Pay with card at the Seller/Reseller counter */
26
21
  PaymentMethods["CARD"] = "CARD";
22
+ /** Pay with cash at the Seller/Reseller counter */
27
23
  PaymentMethods["CASH"] = "CASH";
24
+ /** Pay with credit from change*/
28
25
  PaymentMethods["CREDIT_FROM_CHANGE"] = "CREDIT_FROM_CHANGE";
26
+ /** Only for Sellers: Ticket will be paid at the counter/bus */
29
27
  PaymentMethods["PAY_LATER"] = "PAY_LATER";
28
+ /** Pay online using payment gateways */
30
29
  PaymentMethods["ONLINE_CARD"] = "ONLINE_CARD";
30
+ /** Only for Resellers: the ticket will be paid with the wallet balance */
31
31
  PaymentMethods["WALLET"] = "WALLET";
32
+ /** Only for Sellers: 100% discount */
32
33
  PaymentMethods["ZERO_COST"] = "ZERO_COST";
34
+ /** Pay with a bank transfer */
35
+ PaymentMethods["TRANSFER"] = "TRANSFER";
33
36
  })(PaymentMethods || (exports.PaymentMethods = PaymentMethods = {}));
@@ -30,6 +30,8 @@ export type Tariff = {
30
30
  chf: number | null;
31
31
  id: number;
32
32
  };
33
+ /** The user-friendly label of the tariff */
34
+ label: string;
33
35
  /** The number of passengers to which this tariff applies */
34
36
  quantity: number;
35
37
  /** The custom code for one-way tickets */
@@ -1,22 +1,22 @@
1
1
  import { Booking } from "../../booking/booking";
2
2
  import { Cart } from "../common/Cart";
3
- import { TariffsMatrix, TariffSummary } from "../common/Tariffs";
3
+ import { TariffSummary } from "../common/Tariffs";
4
4
  import { Stop } from "./Stop";
5
5
  import { CartTrip } from "./Trip";
6
6
  /**
7
- * @description Object containing information about a trip of a selected journey. This object is part of the {@link CreateJourneyCartRequest} object
7
+ * Object containing information about a trip of a selected journey.
8
+ * This object is part of the {@link CreateJourneyCartRequest} object
8
9
  * and describes a single trip of the journey (either outbound or return).
9
- *
10
- * @property {number} tripId - The unique identifier for the trip.
11
- * @property {number} departureStopId - The unique identifier for the departure stop.
12
- * @property {number} destinationStopId - The unique identifier for the destination stop.
13
- * @property {TariffsMatrix} tariffsMatrix - The tariff matrix for pricing the outbound journey.
14
10
  */
15
11
  export type TripBookingInfo = {
12
+ /** The unique identifier for the trip. */
16
13
  tripId: number;
14
+ /** The unique identifier for the departure stop. */
17
15
  departureStopId: number;
16
+ /** The unique identifier for the destination stop. */
18
17
  destinationStopId: number;
19
- tariffsMatrix: TariffsMatrix;
18
+ /** A record containing tariff ids as keys and their respective quantities as values. */
19
+ tariffIdToQuantity: Record<number, number>;
20
20
  };
21
21
  /**
22
22
  * @description This is the object to be passed to `JourneyBooking.createJourneyCart`, containing information about the selected service.
@@ -1,23 +1,23 @@
1
1
  import { Booking } from "../../booking/booking";
2
2
  import { Cart } from "../common/Cart";
3
- import { TariffsMatrix, TariffSummary } from "../common/Tariffs";
3
+ import { TariffSummary } from "../common/Tariffs";
4
4
  import { ServiceTrip } from "./Service";
5
5
  /**
6
- * @description This is the object to be passed to `ServiceBooking.createServiceCart`, containing information about the selected service.
7
- *
8
- * @property {Booking.Currencies} currency - The currency in which the service is priced.
9
- * @property {Object} service - Information about the selected service.
10
- * @property {number} service.serviceId - The unique identifier for the service.
11
- * @property {TariffsMatrix} service.tariffsMatrix - The tariff matrix for pricing the service.
12
- * @property {string|undefined} [service.date] - The date for the service in ISO string format (optional).
13
- * @property {number|undefined} [service.tripId] - The unique identifier for the trip (optional).
6
+ * This is the object to be passed to `ServiceBooking.createServiceCart`, containing
7
+ * information about the selected service.
14
8
  */
15
9
  export type CreateServiceCartRequest = {
10
+ /** The currency in which the service is priced. */
16
11
  currency: Booking.Currencies;
12
+ /** Information about the selected service. */
17
13
  service: {
14
+ /** The unique identifier for the service. */
18
15
  serviceId: number;
19
- tariffsMatrix: TariffsMatrix;
16
+ /** A record containing tariff ids as keys and their respective quantities as values. */
17
+ tariffIdToQuantity: Record<number, number>;
18
+ /** The date for the service in ISO string format (optional). */
20
19
  date?: string;
20
+ /** The unique identifier for the trip (optional). */
21
21
  tripId?: number;
22
22
  };
23
23
  };
@@ -8,4 +8,5 @@
8
8
  import { ErrorResponse } from "../types/ErrorResponse";
9
9
  export declare const makeGet: (url: string) => Promise<ErrorResponse | any>;
10
10
  export declare const makePost: (url: string, data: any) => Promise<ErrorResponse | any>;
11
+ export declare const makePut: (url: string, data: any) => Promise<ErrorResponse | any>;
11
12
  export declare const makeDelete: (url: string) => Promise<ErrorResponse | any>;
@@ -54,7 +54,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
54
54
  }
55
55
  };
56
56
  Object.defineProperty(exports, "__esModule", { value: true });
57
- exports.makeDelete = exports.makePost = exports.makeGet = void 0;
57
+ exports.makeDelete = exports.makePut = exports.makePost = exports.makeGet = void 0;
58
58
  var axios_1 = require("axios");
59
59
  var config_1 = require("../config");
60
60
  var utils_1 = require("./utils");
@@ -81,7 +81,7 @@ var makeGet = function (url) { return __awaiter(void 0, void 0, void 0, function
81
81
  throw new Error("MTS Library Error! makeGet: missing OCP SUBSCRIPTION KEY! ".concat(errorReport));
82
82
  }
83
83
  return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
84
- var response, filteredResponse, error_1, resError, resError;
84
+ var response, filteredResponse, error_1, message, resError, resError;
85
85
  var _a, _b, _c, _d, _e, _f, _g;
86
86
  return __generator(this, function (_h) {
87
87
  switch (_h.label) {
@@ -101,10 +101,13 @@ var makeGet = function (url) { return __awaiter(void 0, void 0, void 0, function
101
101
  case 2:
102
102
  error_1 = _h.sent();
103
103
  if (axios_1.default.isAxiosError(error_1)) {
104
+ message = "error" in ((_a = error_1.response) === null || _a === void 0 ? void 0 : _a.data)
105
+ ? (_b = error_1.response) === null || _b === void 0 ? void 0 : _b.data.error.message
106
+ : (_c = error_1.response) === null || _c === void 0 ? void 0 : _c.data.message;
104
107
  resError = {
105
- httpStatus: ((_a = error_1.response) === null || _a === void 0 ? void 0 : _a.status) || 0,
106
- mtsCode: ((_d = (_c = (_b = error_1.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.error) === null || _d === void 0 ? void 0 : _d.code) || 0,
107
- message: ((_g = (_f = (_e = error_1.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.error) === null || _g === void 0 ? void 0 : _g.message) || "Unknown error"
108
+ httpStatus: ((_d = error_1.response) === null || _d === void 0 ? void 0 : _d.status) || 0,
109
+ mtsCode: ((_g = (_f = (_e = error_1.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.error) === null || _g === void 0 ? void 0 : _g.code) || 0,
110
+ message: message || "Unknown error"
108
111
  };
109
112
  if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
110
113
  console.log("GET_ResponseAxiosError", url, resError);
@@ -139,7 +142,7 @@ var makePost = function (url, data) { return __awaiter(void 0, void 0, void 0, f
139
142
  throw new Error("MTS Library Error! makePost: missing OCP SUBSCRIPTION KEY! ".concat(errorReport));
140
143
  }
141
144
  return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
142
- var response, filteredResponse, error_2, resError, resError;
145
+ var response, filteredResponse, error_2, message, resError, resError;
143
146
  var _a, _b, _c, _d, _e, _f, _g;
144
147
  return __generator(this, function (_h) {
145
148
  switch (_h.label) {
@@ -159,10 +162,13 @@ var makePost = function (url, data) { return __awaiter(void 0, void 0, void 0, f
159
162
  case 2:
160
163
  error_2 = _h.sent();
161
164
  if (axios_1.default.isAxiosError(error_2)) {
165
+ message = "error" in ((_a = error_2.response) === null || _a === void 0 ? void 0 : _a.data)
166
+ ? (_b = error_2.response) === null || _b === void 0 ? void 0 : _b.data.error.message
167
+ : (_c = error_2.response) === null || _c === void 0 ? void 0 : _c.data.message;
162
168
  resError = {
163
- httpStatus: ((_a = error_2.response) === null || _a === void 0 ? void 0 : _a.status) || 0,
164
- mtsCode: ((_d = (_c = (_b = error_2.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.error) === null || _d === void 0 ? void 0 : _d.code) || 0,
165
- message: ((_g = (_f = (_e = error_2.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.error) === null || _g === void 0 ? void 0 : _g.message) || "Unknown error"
169
+ httpStatus: ((_d = error_2.response) === null || _d === void 0 ? void 0 : _d.status) || 0,
170
+ mtsCode: ((_g = (_f = (_e = error_2.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.error) === null || _g === void 0 ? void 0 : _g.code) || 0,
171
+ message: message || "Unknown error"
166
172
  };
167
173
  if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
168
174
  console.log("POST_ResponseAxiosError", url, resError);
@@ -184,6 +190,67 @@ var makePost = function (url, data) { return __awaiter(void 0, void 0, void 0, f
184
190
  });
185
191
  }); };
186
192
  exports.makePost = makePost;
193
+ var makePut = function (url, data) { return __awaiter(void 0, void 0, void 0, function () {
194
+ var debug, subKey, errorReport;
195
+ return __generator(this, function (_a) {
196
+ debug = (0, config_1.getConfig)().DEBUG;
197
+ if (debug) {
198
+ console.log("PUT_RequestData", url, data);
199
+ }
200
+ subKey = (0, config_1.getConfig)().OCP_SUBSCRIPTION_KEY;
201
+ if ((0, utils_1.isNullOrWhiteSpace)(subKey)) {
202
+ errorReport = "Sub Key: ".concat(subKey, ", url: ").concat(url, ", access token: ").concat((0, config_1.getConfig)().ACCESS_TOKEN);
203
+ throw new Error("MTS Library Error! makePut: missing OCP SUBSCRIPTION KEY! ".concat(errorReport));
204
+ }
205
+ return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
206
+ var response, filteredResponse, error_3, message, resError, resError;
207
+ var _a, _b, _c, _d, _e, _f, _g;
208
+ return __generator(this, function (_h) {
209
+ switch (_h.label) {
210
+ case 0:
211
+ _h.trys.push([0, 2, , 3]);
212
+ return [4 /*yield*/, axios_1.default.put(url, data, {
213
+ headers: __assign(__assign({ "Content-Type": "application/json", "Ocp-Apim-Subscription-Key": subKey }, ((0, config_1.getConfig)().ACCESS_TOKEN && { Authorization: "Bearer ".concat((0, config_1.getConfig)().ACCESS_TOKEN) })), ((0, config_1.getConfig)().SESSION_ID && { SessionId: (0, config_1.getConfig)().SESSION_ID }))
214
+ })];
215
+ case 1:
216
+ response = _h.sent();
217
+ filteredResponse = removeNullError(response.data);
218
+ if (debug) {
219
+ console.log("PUT_ResponseData", url, filteredResponse);
220
+ }
221
+ resolve(filteredResponse);
222
+ return [3 /*break*/, 3];
223
+ case 2:
224
+ error_3 = _h.sent();
225
+ if (axios_1.default.isAxiosError(error_3)) {
226
+ message = "error" in ((_a = error_3.response) === null || _a === void 0 ? void 0 : _a.data)
227
+ ? (_b = error_3.response) === null || _b === void 0 ? void 0 : _b.data.error.message
228
+ : (_c = error_3.response) === null || _c === void 0 ? void 0 : _c.data.message;
229
+ resError = {
230
+ httpStatus: ((_d = error_3.response) === null || _d === void 0 ? void 0 : _d.status) || 0,
231
+ mtsCode: ((_g = (_f = (_e = error_3.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.error) === null || _g === void 0 ? void 0 : _g.code) || 0,
232
+ message: message || "Unknown error"
233
+ };
234
+ if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
235
+ console.log("PUT_ResponseAxiosError", url, resError);
236
+ }
237
+ reject(resError);
238
+ }
239
+ else {
240
+ resError = __assign(__assign({}, error_3), { httpStatus: 0, mtsCode: 0, message: "Unknown error" });
241
+ if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
242
+ console.log("PUT_ResponseError", url, resError);
243
+ }
244
+ reject(resError);
245
+ }
246
+ return [3 /*break*/, 3];
247
+ case 3: return [2 /*return*/];
248
+ }
249
+ });
250
+ }); })];
251
+ });
252
+ }); };
253
+ exports.makePut = makePut;
187
254
  var makeDelete = function (url) { return __awaiter(void 0, void 0, void 0, function () {
188
255
  var debug, subKey, errorReport;
189
256
  return __generator(this, function (_a) {
@@ -197,7 +264,7 @@ var makeDelete = function (url) { return __awaiter(void 0, void 0, void 0, funct
197
264
  throw new Error("MTS Library Error! makeDelete: missing OCP SUBSCRIPTION KEY! ".concat(errorReport));
198
265
  }
199
266
  return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
200
- var response, filteredResponse, error_3, resError, resError;
267
+ var response, filteredResponse, error_4, message, resError, resError;
201
268
  var _a, _b, _c, _d, _e, _f, _g;
202
269
  return __generator(this, function (_h) {
203
270
  switch (_h.label) {
@@ -215,12 +282,15 @@ var makeDelete = function (url) { return __awaiter(void 0, void 0, void 0, funct
215
282
  resolve(filteredResponse);
216
283
  return [3 /*break*/, 3];
217
284
  case 2:
218
- error_3 = _h.sent();
219
- if (axios_1.default.isAxiosError(error_3)) {
285
+ error_4 = _h.sent();
286
+ if (axios_1.default.isAxiosError(error_4)) {
287
+ message = "error" in ((_a = error_4.response) === null || _a === void 0 ? void 0 : _a.data)
288
+ ? (_b = error_4.response) === null || _b === void 0 ? void 0 : _b.data.error.message
289
+ : (_c = error_4.response) === null || _c === void 0 ? void 0 : _c.data.message;
220
290
  resError = {
221
- httpStatus: ((_a = error_3.response) === null || _a === void 0 ? void 0 : _a.status) || 0,
222
- mtsCode: ((_d = (_c = (_b = error_3.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.error) === null || _d === void 0 ? void 0 : _d.code) || 0,
223
- message: ((_g = (_f = (_e = error_3.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.error) === null || _g === void 0 ? void 0 : _g.message) || "Unknown error"
291
+ httpStatus: ((_d = error_4.response) === null || _d === void 0 ? void 0 : _d.status) || 0,
292
+ mtsCode: ((_g = (_f = (_e = error_4.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.error) === null || _g === void 0 ? void 0 : _g.code) || 0,
293
+ message: message || "Unknown error"
224
294
  };
225
295
  if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
226
296
  console.log("DELETE_ResponseAxiosError", url, resError);
@@ -228,7 +298,7 @@ var makeDelete = function (url) { return __awaiter(void 0, void 0, void 0, funct
228
298
  reject(resError);
229
299
  }
230
300
  else {
231
- resError = __assign(__assign({}, error_3), { httpStatus: 0, mtsCode: 0, message: "Unknown error" });
301
+ resError = __assign(__assign({}, error_4), { httpStatus: 0, mtsCode: 0, message: "Unknown error" });
232
302
  if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
233
303
  console.log("DELETE_ResponseError", url, resError);
234
304
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mts-booking-library",
3
- "version": "1.3.24",
3
+ "version": "1.4.0",
4
4
  "description": "Library for using MyTicketSolution Booking API",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
File without changes
@@ -1,148 +0,0 @@
1
- "use strict";
2
- // import { MTSEnvs } from "../config";
3
- // import { ServiceBooking } from "../booking/serviceBooking";
4
- // import { CreateServiceCartRequest, ServiceCart } from "../types/services/ServiceCart";
5
- // import { Service, ServiceTripsResponse } from "../types/services/Service";
6
- // import { GetBuyerPassengersDetailsResponse } from "../types/common/Person";
7
- // import { GetPaymentInformationFromGatewayResponse, GetSellerGatewaysResponse, PaymentMethods } from "../types/common/Payment";
8
- // import { useTestState } from "../mtsStorage";
9
- // import { SubscriptionBooking } from "../booking/subscriptionBooking";
10
- // // Load .env file
11
- // require('dotenv').config();
12
- // // How to run the test: npm run test -- SubscriptionBooking.test.ts
13
- // describe("SubscriptionBooking", () => {
14
- // const timeOut = 120000;
15
- // const sub_key = process.env.OCP_SUB_KEY_MTS;
16
- // const access_token = process.env.ACCESS_TOKEN;
17
- // const sellerId = 8; // ATV
18
- // // Define localStorage for local testing
19
- // if (typeof localStorage === "undefined" || localStorage === null) {
20
- // var LocalStorage = require("node-localstorage").LocalStorage;
21
- // global.localStorage = new LocalStorage("./scratch");
22
- // }
23
- // test("search_tpl", async () => {
24
- // const booking = new SubscriptionBooking(MTSEnvs.TEST, sub_key!, true, SubscriptionBooking.Languages.EN, access_token, sellerId);
25
- // // First, get the departures and destinations
26
- // const departures = await booking.getSubscriptionsDepartures() as string[];
27
- // expect(departures.length).toBeGreaterThan(0);
28
- // expect(departures).toContain("BARDOLINO AUTOSTAZIONE");
29
- // const selectedDeparture = "BARDOLINO AUTOSTAZIONE";
30
- // const destinations = await booking.getSubscriptionsDestinations(selectedDeparture) as string[];
31
- // expect(destinations.length).toBeGreaterThan(0);
32
- // expect(destinations).toContain("GARDA AUTOSTAZIONE");
33
- // const selectedDestination = "GARDA AUTOSTAZIONE";
34
- // // Then get the validity types
35
- // const validityTypes = await booking.getSubscriptionsValidityTypes(selectedDeparture, selectedDestination) as SubscriptionBooking.ValidityTypes[];
36
- // expect(validityTypes.length).toBeGreaterThan(0);
37
- // for (const validityType of validityTypes) {
38
- // // Check that all returned validity types are valid
39
- // expect(Object.values(SubscriptionBooking.ValidityTypes).includes(validityType)).toBe(true);
40
- // }
41
- // }, timeOut);
42
- // const createCart = async (booking: ServiceBooking): Promise<ServiceCart> => {
43
- // const servicesResponse = await booking.getServices(ServiceBooking.Currencies.EUR);
44
- // const services = servicesResponse as Service[];
45
- // // Build create cart request
46
- // let tariffsMatrix = services[0].tariffsMatrix;
47
- // tariffsMatrix[0][0].quantity = 1;
48
- // const createServiceCartRequest: CreateServiceCartRequest = {
49
- // currency: ServiceBooking.Currencies.EUR,
50
- // service: {
51
- // serviceId: services[0].id,
52
- // tariffsMatrix: tariffsMatrix
53
- // }
54
- // };
55
- // // Create cart
56
- // const cart = await booking.createServiceCart(createServiceCartRequest) as ServiceCart;
57
- // return cart;
58
- // }
59
- // test("create_service_cart", async () => {
60
- // const booking = new ServiceBooking(MTSEnvs.TEST, sub_key!, true, ServiceBooking.Languages.EN);
61
- // const cart = await createCart(booking);
62
- // // Check that the cartId was saved to the local storage
63
- // expect(useTestState().getState().cartId).toBe(cart.id);
64
- // expect(booking.cartId).toBe(cart.id);
65
- // // Test the booking status (we test only the Buyer and passenger data, as it will always be required)
66
- // expect(booking.bookingStepsToStatus.get(ServiceBooking.BookingSteps.BUYER_PASSENGERS)).toStrictEqual([ true, false, true ]);
67
- // expect(booking.bookingStepsToStatus.get(ServiceBooking.BookingSteps.ISSUE)).toStrictEqual([ false, false, true ]);
68
- // // Test booking due date
69
- // expect(booking.bookingDueDate?.toISOString()).toBe(new Date(cart.bookingDueDate).toISOString());
70
- // // Test expired tickets
71
- // expect(cart.hasIssuedTickets).toBe(false);
72
- // // Test seller data
73
- // expect(booking.getSellerId()).toBe(cart.sellerId);
74
- // expect(cart.sellerPrivacyUrl.length).toBeGreaterThan(0);
75
- // expect(cart.sellerTermsUrl.length).toBeGreaterThan(0);
76
- // // Now try to get the cart
77
- // const newBooking = await ServiceBooking.createBooking(MTSEnvs.TEST, sub_key!, true, ServiceBooking.Languages.EN);
78
- // expect(newBooking.cartId).toBe(cart.id);
79
- // expect(newBooking.getCart()?.id).toBe(cart.id)
80
- // expect(newBooking.getSellerId()).toBe(cart.sellerId);
81
- // // Finally try to delete the cart
82
- // await booking.deleteCart();
83
- // expect(booking.getCart()).toBe(undefined);
84
- // expect(useTestState().getState().cartId).toBe(undefined);
85
- // }, timeOut);
86
- // test("get_edit_buyer_data", async () => {
87
- // const booking = new ServiceBooking(MTSEnvs.TEST, sub_key!, true, ServiceBooking.Languages.EN);
88
- // const cart = await createCart(booking);
89
- // // First, try to get the buyer data
90
- // let buyerDataResponse = await booking.getBuyerPassengersDetails();
91
- // expect((buyerDataResponse as GetBuyerPassengersDetailsResponse).passengers.length).toBe(0);
92
- // let buyer = (buyerDataResponse as GetBuyerPassengersDetailsResponse).buyer;
93
- // expect(buyer).toBe(null);
94
- // // Now try to edit the buyer data
95
- // buyer = {
96
- // id: 0,
97
- // name: "TestName",
98
- // lastName: "TestSurname",
99
- // email: "testBookingLib@infos.it",
100
- // phoneNumber: "+391234567890"
101
- // }
102
- // await booking.updateBuyerPassengersDetails(buyer);
103
- // // Finally, get the buyer data again and check that the data was updated
104
- // buyerDataResponse = await booking.getBuyerPassengersDetails();
105
- // const updatedBuyer = (buyerDataResponse as GetBuyerPassengersDetailsResponse).buyer;
106
- // expect(updatedBuyer.id).toBeGreaterThan(0);
107
- // expect(updatedBuyer.name).toBe(buyer.name);
108
- // expect(updatedBuyer.lastName).toBe(buyer.lastName);
109
- // expect(updatedBuyer.email).toBe(buyer.email);
110
- // expect(updatedBuyer.phoneNumber).toBe(buyer.phoneNumber);
111
- // // Finally try to delete the cart
112
- // await booking.deleteCart();
113
- // expect(booking.getCart()).toBe(undefined);
114
- // expect(useTestState().getState().cartId).toBe(undefined);
115
- // }, timeOut);
116
- // test("get_gateway_info", async () => {
117
- // const booking = new ServiceBooking(MTSEnvs.TEST, sub_key!, true, ServiceBooking.Languages.EN);
118
- // const cart = await createCart(booking);
119
- // booking.updateSellerId(cart.sellerId);
120
- // // First, try to get the buyer data
121
- // let buyerDataResponse = await booking.getBuyerPassengersDetails();
122
- // expect((buyerDataResponse as GetBuyerPassengersDetailsResponse).passengers.length).toBe(0);
123
- // let buyer = (buyerDataResponse as GetBuyerPassengersDetailsResponse).buyer;
124
- // expect(buyer).toBe(null);
125
- // // Now try to edit the buyer data
126
- // buyer = {
127
- // id: 0,
128
- // name: "TestName",
129
- // lastName: "TestSurname",
130
- // email: "testBookingLib@infos.it",
131
- // phoneNumber: "+391234567890"
132
- // }
133
- // await booking.updateBuyerPassengersDetails(buyer);
134
- // // Try to get the gateways
135
- // const gateways = await booking.getSellerGateways() as GetSellerGatewaysResponse;
136
- // if (!gateways.payPalGatewayDTO && !gateways.cardGatewayDTO) {
137
- // throw new Error("No gateways found");
138
- // }
139
- // const gateway = gateways.payPalGatewayDTO ? gateways.payPalGatewayDTO : gateways.cardGatewayDTO;
140
- // expect(gateway?.id).toBeGreaterThan(0);
141
- // // Now try to get the info
142
- // const gatewayInfo = await booking.getPaymentInformationFromGateway(gateway?.id ?? 0) as GetPaymentInformationFromGatewayResponse;
143
- // // Finally try to delete the cart
144
- // await booking.deleteCart();
145
- // expect(booking.getCart()).toBe(undefined);
146
- // expect(useTestState().getState().cartId).toBe(undefined);
147
- // }, timeOut);
148
- // });
@@ -1,8 +0,0 @@
1
- /**
2
- * This method return the ISO string of the date without GMT. An ISO string looks like this: YYYY-MM-DDThh:mm:ss.mmmZ
3
- * @param {Date | string} date the date to convert
4
- * @param {boolean} [removeTimezone=true] if true, the timezone will be removed from the ISO string, meaning
5
- * that the string will look like this: YYYY-MM-DDThh:mm:ss.mmm
6
- * @returns {string} the ISO string
7
- */
8
- export declare const getISOStringWithoutGMT: (date: Date | string | null | undefined, removeTimezone?: boolean) => string | null;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getISOStringWithoutGMT = void 0;
4
- /**
5
- * This method return the ISO string of the date without GMT. An ISO string looks like this: YYYY-MM-DDThh:mm:ss.mmmZ
6
- * @param {Date | string} date the date to convert
7
- * @param {boolean} [removeTimezone=true] if true, the timezone will be removed from the ISO string, meaning
8
- * that the string will look like this: YYYY-MM-DDThh:mm:ss.mmm
9
- * @returns {string} the ISO string
10
- */
11
- var getISOStringWithoutGMT = function (date, removeTimezone) {
12
- if (removeTimezone === void 0) { removeTimezone = true; }
13
- if (!date)
14
- return null;
15
- var newDate = new Date(date);
16
- var isoString = new Date(newDate.valueOf() - newDate.getTimezoneOffset() * 60000).toISOString();
17
- return removeTimezone ? isoString.slice(0, -1) : isoString;
18
- };
19
- exports.getISOStringWithoutGMT = getISOStringWithoutGMT;