mts-booking-library 1.2.7 → 1.2.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,6 +14,17 @@ var __extends = (this && this.__extends) || (function () {
14
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
15
  };
16
16
  })();
17
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
17
28
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
29
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
30
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -334,7 +345,7 @@ var JourneyBooking = /** @class */ (function (_super) {
334
345
  */
335
346
  JourneyBooking.prototype.updateBuyerPassengersDetails = function (passengersDetails) {
336
347
  return __awaiter(this, void 0, void 0, function () {
337
- var buyerPassengersDetails, url;
348
+ var buyerPassengersDetails, request, url;
338
349
  return __generator(this, function (_a) {
339
350
  // First check that it is possible to call this API
340
351
  if (!this.cart) {
@@ -344,8 +355,16 @@ var JourneyBooking = /** @class */ (function (_super) {
344
355
  if (!buyerPassengersDetails || !buyerPassengersDetails[0]) {
345
356
  throw Error("The status of the cart does not allow to call this API");
346
357
  }
358
+ request = __assign({}, passengersDetails);
359
+ passengersDetails.passengers.map(function (passenger, passengerIndex) {
360
+ var tripsToTariffsToJson = {};
361
+ passenger.tripsToTariffs.forEach(function (value, key) {
362
+ tripsToTariffsToJson[key] = value;
363
+ });
364
+ request.passengers[passengerIndex].tripsToTariffs = tripsToTariffsToJson;
365
+ });
347
366
  url = "".concat(this.config.API_ENDPOINT, "/booking/cart/").concat(this.cart.id, "/details");
348
- return [2 /*return*/, this.callPostApi(url, passengersDetails).then(function (response) {
367
+ return [2 /*return*/, this.callPostApi(url, request).then(function (response) {
349
368
  return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response) ? response : response;
350
369
  })];
351
370
  });
@@ -14,6 +14,17 @@ var __extends = (this && this.__extends) || (function () {
14
14
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
15
  };
16
16
  })();
17
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
17
28
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
29
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
30
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -383,7 +394,7 @@ var SubscriptionBooking = /** @class */ (function (_super) {
383
394
  */
384
395
  SubscriptionBooking.prototype.updateBuyerPassengersDetails = function (passengersDetails) {
385
396
  return __awaiter(this, void 0, void 0, function () {
386
- var buyerPassengersDetails, url;
397
+ var buyerPassengersDetails, request, url;
387
398
  return __generator(this, function (_a) {
388
399
  // First check that it is possible to call this API
389
400
  if (!this.cart) {
@@ -393,8 +404,16 @@ var SubscriptionBooking = /** @class */ (function (_super) {
393
404
  if (!buyerPassengersDetails || !buyerPassengersDetails[0]) {
394
405
  throw Error("The status of the cart does not allow to call this API");
395
406
  }
407
+ request = __assign({}, passengersDetails);
408
+ passengersDetails.passengers.map(function (passenger, passengerIndex) {
409
+ var tripsToTariffsToJson = {};
410
+ passenger.tripsToTariffs.forEach(function (value, key) {
411
+ tripsToTariffsToJson[key] = value;
412
+ });
413
+ request.passengers[passengerIndex].tripsToTariffs = tripsToTariffsToJson;
414
+ });
396
415
  url = "".concat(this.config.API_ENDPOINT, "/booking/cart/").concat(this.cart.id, "/details");
397
- return [2 /*return*/, this.callPostApi(url, passengersDetails).then(function (response) {
416
+ return [2 /*return*/, this.callPostApi(url, request).then(function (response) {
398
417
  return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response) ? response : response;
399
418
  })];
400
419
  });
@@ -54,11 +54,10 @@ export type GetBuyerPassengersDetailsResponse = {
54
54
  };
55
55
  /**
56
56
  * @description Represents the type of the passengers array in {@link EditPassengersDetailsRequest}.
57
+ * Note that in the `tripsToTariffs` map, the key is the trip id and the value is the chosen tariff id.
57
58
  */
58
59
  export type EditPassengerRequestType = Person & {
59
- tripsToTariffs: {
60
- [tripId: number]: number;
61
- };
60
+ tripsToTariffs: Map<number, number>;
62
61
  };
63
62
  /**
64
63
  * @description Represents the passengers details.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mts-booking-library",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "Library for use MyTicketSolution Booking API",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",