mts-booking-library 2.4.1 → 2.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -84,11 +84,12 @@ export declare abstract class Booking {
84
84
  getPaymentInformationFromGateway(gatewayId: number, returnUrl?: string, options?: ApiCallOptions): Promise<ErrorResponse | GetPaymentInformationFromGatewayResponse>;
85
85
  /**
86
86
  * @description This method shall be used to issue the tickets. It must be called after the payment was successful.
87
- * @param {PaymentMethods} paymentMethod The payment method used to pay the cart. If the chosen method is {@link PaymentMethods.ZERO_COST},
87
+ * @param paymentMethod The payment method used to pay the cart. If the chosen method is {@link PaymentMethods.ZERO_COST},
88
88
  * first the {@link Booking.addReduction} API is called with a 100% discount, then tickets are issued with the {@link PaymentMethods.CASH} method.
89
+ * @param tripId The Id of the trip for which the tickets are issued. This parameter is required when the booking done on the MTSAPP
89
90
  * @returns An {@link IssueCartResponse} object.
90
91
  */
91
- issueCart(paymentMethod: PaymentMethods, options?: ApiCallOptions): Promise<ErrorResponse | IssueCartResponse>;
92
+ issueCart(paymentMethod: PaymentMethods, tripId?: number, options?: ApiCallOptions): Promise<ErrorResponse | IssueCartResponse>;
92
93
  getExtras({ extraId, tariffPlanId }?: {
93
94
  /** The extra object identifier. By default, all the extras of the seller are returned. */
94
95
  extraId?: number;
@@ -313,11 +313,12 @@ var Booking = /** @class */ (function () {
313
313
  };
314
314
  /**
315
315
  * @description This method shall be used to issue the tickets. It must be called after the payment was successful.
316
- * @param {PaymentMethods} paymentMethod The payment method used to pay the cart. If the chosen method is {@link PaymentMethods.ZERO_COST},
316
+ * @param paymentMethod The payment method used to pay the cart. If the chosen method is {@link PaymentMethods.ZERO_COST},
317
317
  * first the {@link Booking.addReduction} API is called with a 100% discount, then tickets are issued with the {@link PaymentMethods.CASH} method.
318
+ * @param tripId The Id of the trip for which the tickets are issued. This parameter is required when the booking done on the MTSAPP
318
319
  * @returns An {@link IssueCartResponse} object.
319
320
  */
320
- Booking.prototype.issueCart = function (paymentMethod, options) {
321
+ Booking.prototype.issueCart = function (paymentMethod, tripId, options) {
321
322
  return __awaiter(this, void 0, void 0, function () {
322
323
  var paymentMethodToSet, issueStep, _i, _a, step, url, body;
323
324
  var _b;
@@ -373,10 +374,7 @@ var Booking = /** @class */ (function () {
373
374
  _c.label = 7;
374
375
  case 7:
375
376
  url = "".concat(this.config.API_ENDPOINT, "/v3_booking/carts/issue");
376
- body = {
377
- cartGuid: this.cartGuid,
378
- paymentMethod: paymentMethodToSet === Payment_1.PaymentMethods.PAY_LATER ? null : paymentMethodToSet
379
- };
377
+ body = __assign(__assign({ cartGuid: this.cartGuid }, (tripId && { tripId: tripId })), { paymentMethod: paymentMethodToSet === Payment_1.PaymentMethods.PAY_LATER ? null : paymentMethodToSet });
380
378
  return [2 /*return*/, this.callPostApi(url, body, options).then(function (response) {
381
379
  return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response) ? response : response;
382
380
  })];
@@ -815,7 +815,7 @@ exports.JourneyBooking = JourneyBooking;
815
815
  (function (JourneyBooking) {
816
816
  var _this = this;
817
817
  JourneyBooking.createBooking = function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
818
- var booking, error_1;
818
+ var booking, error_1, errorString;
819
819
  var env = _b.env, subKey = _b.subKey, debug = _b.debug, language = _b.language, sessionId = _b.sessionId, restoreState = _b.restoreState, accessToken = _b.accessToken, sellerId = _b.sellerId, resellerId = _b.resellerId, appVersion = _b.appVersion, os = _b.os, dbType = _b.dbType;
820
820
  return __generator(this, function (_c) {
821
821
  switch (_c.label) {
@@ -852,7 +852,22 @@ exports.JourneyBooking = JourneyBooking;
852
852
  booking.cartGuid = undefined;
853
853
  return [2 /*return*/, booking];
854
854
  }
855
- throw new Error("Could not instantiate JourneyBooking");
855
+ errorString = void 0;
856
+ if (typeof error_1 === "string") {
857
+ errorString = error_1;
858
+ }
859
+ else if (typeof error_1 === "object") {
860
+ try {
861
+ errorString = JSON.stringify(error_1);
862
+ }
863
+ catch (_d) {
864
+ errorString = String(error_1);
865
+ }
866
+ }
867
+ else {
868
+ errorString = String(error_1);
869
+ }
870
+ throw new Error("Could not instantiate JourneyBooking. Error: ".concat(errorString));
856
871
  case 5: return [2 /*return*/];
857
872
  }
858
873
  });
@@ -677,7 +677,7 @@ exports.ServiceBooking = ServiceBooking;
677
677
  (function (ServiceBooking) {
678
678
  var _this = this;
679
679
  ServiceBooking.createBooking = function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
680
- var booking, error_1;
680
+ var booking, error_1, errorString;
681
681
  var env = _b.env, subKey = _b.subKey, debug = _b.debug, language = _b.language, sessionId = _b.sessionId, restoreState = _b.restoreState, accessToken = _b.accessToken, sellerId = _b.sellerId, resellerId = _b.resellerId, appVersion = _b.appVersion, os = _b.os, dbType = _b.dbType;
682
682
  return __generator(this, function (_c) {
683
683
  switch (_c.label) {
@@ -714,7 +714,22 @@ exports.ServiceBooking = ServiceBooking;
714
714
  booking.cartGuid = undefined;
715
715
  return [2 /*return*/, booking];
716
716
  }
717
- throw new Error("Could not instantiate JourneyBooking");
717
+ errorString = void 0;
718
+ if (typeof error_1 === "string") {
719
+ errorString = error_1;
720
+ }
721
+ else if (typeof error_1 === "object") {
722
+ try {
723
+ errorString = JSON.stringify(error_1);
724
+ }
725
+ catch (_d) {
726
+ errorString = String(error_1);
727
+ }
728
+ }
729
+ else {
730
+ errorString = String(error_1);
731
+ }
732
+ throw new Error("Could not instantiate ServiceBooking. Error: ".concat(errorString));
718
733
  case 5: return [2 /*return*/];
719
734
  }
720
735
  });
@@ -727,7 +727,7 @@ exports.SubscriptionBooking = SubscriptionBooking;
727
727
  (function (SubscriptionBooking) {
728
728
  var _this = this;
729
729
  SubscriptionBooking.createBooking = function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
730
- var booking, error_1;
730
+ var booking, error_1, errorString;
731
731
  var env = _b.env, subKey = _b.subKey, debug = _b.debug, language = _b.language, sessionId = _b.sessionId, restoreState = _b.restoreState, accessToken = _b.accessToken, sellerId = _b.sellerId, resellerId = _b.resellerId, appVersion = _b.appVersion, os = _b.os, dbType = _b.dbType;
732
732
  return __generator(this, function (_c) {
733
733
  switch (_c.label) {
@@ -764,7 +764,22 @@ exports.SubscriptionBooking = SubscriptionBooking;
764
764
  booking.cartGuid = undefined;
765
765
  return [2 /*return*/, booking];
766
766
  }
767
- throw new Error("Could not instantiate JourneyBooking");
767
+ errorString = void 0;
768
+ if (typeof error_1 === "string") {
769
+ errorString = error_1;
770
+ }
771
+ else if (typeof error_1 === "object") {
772
+ try {
773
+ errorString = JSON.stringify(error_1);
774
+ }
775
+ catch (_d) {
776
+ errorString = String(error_1);
777
+ }
778
+ }
779
+ else {
780
+ errorString = String(error_1);
781
+ }
782
+ throw new Error("Could not instantiate SubscriptionsBooking. Error: ".concat(errorString));
768
783
  case 5: return [2 /*return*/];
769
784
  }
770
785
  });
@@ -742,7 +742,7 @@ exports.TplBooking = TplBooking;
742
742
  (function (TplBooking) {
743
743
  var _this = this;
744
744
  TplBooking.createBooking = function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
745
- var booking, error_1;
745
+ var booking, error_1, errorString;
746
746
  var env = _b.env, subKey = _b.subKey, debug = _b.debug, language = _b.language, sessionId = _b.sessionId, restoreState = _b.restoreState, accessToken = _b.accessToken, sellerId = _b.sellerId, resellerId = _b.resellerId, appVersion = _b.appVersion, os = _b.os, dbType = _b.dbType;
747
747
  return __generator(this, function (_c) {
748
748
  switch (_c.label) {
@@ -779,7 +779,22 @@ exports.TplBooking = TplBooking;
779
779
  booking.cartGuid = undefined;
780
780
  return [2 /*return*/, booking];
781
781
  }
782
- throw new Error("Could not instantiate TplBooking");
782
+ errorString = void 0;
783
+ if (typeof error_1 === "string") {
784
+ errorString = error_1;
785
+ }
786
+ else if (typeof error_1 === "object") {
787
+ try {
788
+ errorString = JSON.stringify(error_1);
789
+ }
790
+ catch (_d) {
791
+ errorString = String(error_1);
792
+ }
793
+ }
794
+ else {
795
+ errorString = String(error_1);
796
+ }
797
+ throw new Error("Could not instantiate TplBooking. Error: ".concat(errorString));
783
798
  case 5: return [2 /*return*/];
784
799
  }
785
800
  });
@@ -26,6 +26,7 @@ export type GetSellerGatewaysResponse = {
26
26
  * @param {string | null} axervE_BANCASELLA_PaymentId The payment id of the Axerve Bancasella gateway
27
27
  * @param {string | null} axervE_BANCASELLA_PaymentToken The payment token of the Axerve Bancasella gateway
28
28
  * @param {string | null} axervE_BANCASELLA_ShopLogin The shop login of the Axerve Bancasella gateway
29
+ * @param {string | null} axervE_BANCASELLA_Link The link of the Axerve Bancasella gateway
29
30
  * @param {string | null} axeptA_BNL_PaymentId The payment id of the Axepta BNL gateway
30
31
  * @param {string | null} axeptA_BNL_EasyCheckoutLicenseKey The easy checkout license key of the Axepta BNL gateway
31
32
  * @param {string | null} paypaL_ClientId The client id of the PayPal gateway
@@ -37,6 +38,7 @@ export type GetPaymentInformationFromGatewayResponse = {
37
38
  axervE_BANCASELLA_PaymentId: string | null;
38
39
  axervE_BANCASELLA_PaymentToken: string | null;
39
40
  axervE_BANCASELLA_ShopLogin: string | null;
41
+ axervE_BANCASELLA_Link: string | null;
40
42
  axeptA_BNL_PaymentId: string | null;
41
43
  axeptA_BNL_EasyCheckoutLicenseKey: string | null;
42
44
  paypaL_ClientId: string | null;
@@ -75,7 +75,7 @@ var makeRequest = function (method, url, data, options) { return __awaiter(void
75
75
  throw new Error("MTS Library Error! makeRequest: data is not supported for ".concat(method, " calls. url: ").concat(url));
76
76
  debug = (0, config_1.getConfig)().DEBUG;
77
77
  if (debug) {
78
- console.log("".concat(method, "_RequestData"), url);
78
+ console.log("".concat(method, "_RequestData"), url, data);
79
79
  }
80
80
  subKey = (0, config_1.getConfig)().OCP_SUBSCRIPTION_KEY;
81
81
  if ((0, utils_1.isNullOrWhiteSpace)(subKey)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mts-booking-library",
3
- "version": "2.4.1",
3
+ "version": "2.4.3",
4
4
  "description": "Library for using MyTicketSolution Booking API",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -17,10 +17,10 @@
17
17
  "license": "ISC",
18
18
  "devDependencies": {
19
19
  "@types/jest": "^29.5.14",
20
- "dotenv": "^16.4.5",
20
+ "dotenv": "^16.4.7",
21
21
  "jest": "^29.7.0",
22
22
  "node-localstorage": "^3.0.5",
23
- "prettier": "^3.3.3",
23
+ "prettier": "^3.4.2",
24
24
  "ts-jest": "^29.2.5",
25
25
  "typescript": "^5.7.2"
26
26
  },
@@ -34,7 +34,7 @@
34
34
  "author": "Infoservice s.r.l.",
35
35
  "dependencies": {
36
36
  "@react-native-async-storage/async-storage": "^2.1.0",
37
- "axios": "^1.7.7",
37
+ "axios": "^1.7.9",
38
38
  "zustand": "^4.5.5"
39
39
  }
40
40
  }