mts-booking-library 1.3.4 → 1.3.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -177,8 +177,13 @@ export declare namespace SubscriptionBooking {
177
177
  const createBooking: (env: MTSEnvs, sub_key: string, debug: boolean, language: string, access_token?: string, sellerId?: number, resellerId?: number) => Promise<SubscriptionBooking>;
178
178
  enum ValidityTypes {
179
179
  WORKING_WEEK = "WORKING_WEEK",
180
- WEEKLY = "WEEKLY",
181
- MONTHLY = "MONTHLY",
182
- YEARLY = "YEARLY"
180
+ ONE_WEEK = "ONE_WEEK",
181
+ CALENDAR_WEEK = "CALENDAR_WEEK",
182
+ FIFTEEN_DAYS = "FIFTEEN_DAYS",
183
+ ONE_MONTH = "ONE_MONTH",
184
+ CALENDAR_MONTH = "CALENDAR_MONTH",
185
+ CALENDAR_SIX_MONTHS = "CALENDAR_SIX_MONTHS",
186
+ ONE_YEAR = "ONE_YEAR",
187
+ CALENDAR_YEAR = "CALENDAR_YEAR"
183
188
  }
184
189
  }
@@ -172,7 +172,7 @@ var SubscriptionBooking = /** @class */ (function (_super) {
172
172
  if (response.cart.hasIssuedTickets) {
173
173
  _this.resetBooking();
174
174
  }
175
- return response;
175
+ return response.cart;
176
176
  })];
177
177
  });
178
178
  });
@@ -750,8 +750,13 @@ exports.SubscriptionBooking = SubscriptionBooking;
750
750
  var ValidityTypes;
751
751
  (function (ValidityTypes) {
752
752
  ValidityTypes["WORKING_WEEK"] = "WORKING_WEEK";
753
- ValidityTypes["WEEKLY"] = "WEEKLY";
754
- ValidityTypes["MONTHLY"] = "MONTHLY";
755
- ValidityTypes["YEARLY"] = "YEARLY";
753
+ ValidityTypes["ONE_WEEK"] = "ONE_WEEK";
754
+ ValidityTypes["CALENDAR_WEEK"] = "CALENDAR_WEEK";
755
+ ValidityTypes["FIFTEEN_DAYS"] = "FIFTEEN_DAYS";
756
+ ValidityTypes["ONE_MONTH"] = "ONE_MONTH";
757
+ ValidityTypes["CALENDAR_MONTH"] = "CALENDAR_MONTH";
758
+ ValidityTypes["CALENDAR_SIX_MONTHS"] = "CALENDAR_SIX_MONTHS";
759
+ ValidityTypes["ONE_YEAR"] = "ONE_YEAR";
760
+ ValidityTypes["CALENDAR_YEAR"] = "CALENDAR_YEAR";
756
761
  })(ValidityTypes = SubscriptionBooking.ValidityTypes || (SubscriptionBooking.ValidityTypes = {}));
757
762
  })(SubscriptionBooking || (exports.SubscriptionBooking = SubscriptionBooking = {}));
@@ -96,9 +96,14 @@ export declare class TplBooking extends Booking {
96
96
  getTermsTypes(superAreaId: number): Promise<ErrorResponse | TermsType[]>;
97
97
  /**
98
98
  * This method fetches the list of available tariffs for the selected terms type in a given super area.
99
- * @returns An array of {@link GetTariffsResponse} if the call is successful, an {@link ErrorResponse} object otherwise.
99
+ * @param {number} superAreaId The id of the super area (as returned by the {@link getSuperAreas} method).
100
+ * @param {number | null} termsTypeId The id of the terms type (as returned by the {@link getTermsTypes} method).
101
+ * If null, tariffs from all terms types will be considered.
102
+ * @param {boolean} onlyTickets If true, only only return the tariffs that are for single tickets.
103
+ * @param {boolean} onlySubscriptions If true, only return the tariffs that are for subscriptions.
104
+ * @returns A {@link GetTariffsResponse} if the call is successful, an {@link ErrorResponse} object otherwise.
100
105
  */
101
- getTariffs(superAreaId: number, termsTypeId: number): Promise<ErrorResponse | GetTariffsResponse>;
106
+ getTariffs(superAreaId: number, termsTypeId: number | null, onlyTickets: boolean, onlySubscriptions: boolean): Promise<ErrorResponse | GetTariffsResponse>;
102
107
  /**
103
108
  * This method allows to create a TPL cart.
104
109
  * @param {Map<number, number>} tariffIdToQuantity A map that associates a tariff id (the one chosen by the user) to the number of tickets to buy for that tariff.
@@ -251,14 +251,20 @@ var TplBooking = /** @class */ (function (_super) {
251
251
  };
252
252
  /**
253
253
  * This method fetches the list of available tariffs for the selected terms type in a given super area.
254
- * @returns An array of {@link GetTariffsResponse} if the call is successful, an {@link ErrorResponse} object otherwise.
254
+ * @param {number} superAreaId The id of the super area (as returned by the {@link getSuperAreas} method).
255
+ * @param {number | null} termsTypeId The id of the terms type (as returned by the {@link getTermsTypes} method).
256
+ * If null, tariffs from all terms types will be considered.
257
+ * @param {boolean} onlyTickets If true, only only return the tariffs that are for single tickets.
258
+ * @param {boolean} onlySubscriptions If true, only return the tariffs that are for subscriptions.
259
+ * @returns A {@link GetTariffsResponse} if the call is successful, an {@link ErrorResponse} object otherwise.
255
260
  */
256
- TplBooking.prototype.getTariffs = function (superAreaId, termsTypeId) {
261
+ TplBooking.prototype.getTariffs = function (superAreaId, termsTypeId, onlyTickets, onlySubscriptions) {
257
262
  return __awaiter(this, void 0, void 0, function () {
258
263
  var searchParams, url;
259
264
  return __generator(this, function (_a) {
260
- searchParams = new URLSearchParams({ superAreaId: superAreaId.toString(), termsTypeId: termsTypeId.toString() });
265
+ searchParams = new URLSearchParams(__assign(__assign({ superAreaId: superAreaId.toString() }, (termsTypeId && { termsTypeId: termsTypeId.toString() })), { onlyTickets: onlyTickets.toString(), onlySubscriptions: onlySubscriptions.toString() }));
261
266
  url = "".concat(this.config.API_ENDPOINT, "/v3_booking/tpl/tariffs?").concat(searchParams);
267
+ // Call the API
262
268
  return [2 /*return*/, this.callGetApi(url).then(function (response) {
263
269
  // Check for error
264
270
  if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mts-booking-library",
3
- "version": "1.3.4",
3
+ "version": "1.3.6",
4
4
  "description": "Library for using MyTicketSolution Booking API",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -17,7 +17,7 @@
17
17
  "@types/jest": "^29.5.12",
18
18
  "jest": "^29.7.0",
19
19
  "ts-jest": "^29.1.2",
20
- "typescript": "^5.4.4"
20
+ "typescript": "^5.4.5"
21
21
  },
22
22
  "files": [
23
23
  "lib/**/*"