mts-booking-library 1.1.10 → 1.2.0

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.
@@ -52,6 +52,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
52
52
  };
53
53
  Object.defineProperty(exports, "__esModule", { value: true });
54
54
  exports.SubscriptionBooking = void 0;
55
+ var ErrorResponse_1 = require("../types/ErrorResponse");
55
56
  var booking_1 = require("./booking");
56
57
  var SubscriptionBooking = /** @class */ (function (_super) {
57
58
  __extends(SubscriptionBooking, _super);
@@ -90,7 +91,14 @@ var SubscriptionBooking = /** @class */ (function (_super) {
90
91
  if (cartDate > new Date()) {
91
92
  _this.cart = cart;
92
93
  _this.bookingDueDate = cartDate; // See Booking class
93
- _this.cartStatus = cart.status;
94
+ // Fill the booking process status
95
+ _this.bookingStepsToStatus = new Map(Object.entries(cart.stepsToStatus).map(function (_a) {
96
+ var bookingStep = _a[0], values = _a[1];
97
+ return [
98
+ bookingStep,
99
+ values
100
+ ];
101
+ }));
94
102
  _this.createCartTimer(cartDate);
95
103
  }
96
104
  });
@@ -105,7 +113,7 @@ var SubscriptionBooking = /** @class */ (function (_super) {
105
113
  setTimeout(function () {
106
114
  localStorage.removeItem("cartId");
107
115
  // Put actions that have to be done when timer expires here
108
- _this.cartStatus = booking_1.Booking.CartStatus.EMPTY;
116
+ _this.bookingStepsToStatus = new Map();
109
117
  _this.cart = undefined;
110
118
  _this.bookingDueDate = undefined; // See Booking class
111
119
  _this.onCartExpiration();
@@ -119,7 +127,13 @@ var SubscriptionBooking = /** @class */ (function (_super) {
119
127
  var url;
120
128
  return __generator(this, function (_a) {
121
129
  url = "".concat(this.config.API_ENDPOINT, "/booking/cart?").concat(new URLSearchParams({ cartId: cartId.toString() }));
122
- return [2 /*return*/, this.callGetApi(url)];
130
+ return [2 /*return*/, this.callGetApi(url).then(function (response) {
131
+ if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
132
+ localStorage.removeItem("cartId");
133
+ throw new Error("Error ".concat(response.httpStatus, " ").concat(response.message));
134
+ }
135
+ return response.cart;
136
+ })];
123
137
  });
124
138
  });
125
139
  };
@@ -132,7 +146,9 @@ var SubscriptionBooking = /** @class */ (function (_super) {
132
146
  var url;
133
147
  return __generator(this, function (_a) {
134
148
  url = "".concat(this.config.API_ENDPOINT, "/booking/subscriptions/departures?");
135
- return [2 /*return*/, this.callGetApi(url)];
149
+ return [2 /*return*/, this.callGetApi(url).then(function (response) {
150
+ return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response) ? response : response.departures;
151
+ })];
136
152
  });
137
153
  });
138
154
  };
@@ -147,7 +163,9 @@ var SubscriptionBooking = /** @class */ (function (_super) {
147
163
  return __generator(this, function (_a) {
148
164
  searchParams = new URLSearchParams({ departureStopName: departureStopName });
149
165
  url = "".concat(this.config.API_ENDPOINT, "/booking/subscriptions/destinations?").concat(searchParams);
150
- return [2 /*return*/, this.callGetApi(url)];
166
+ return [2 /*return*/, this.callGetApi(url).then(function (response) {
167
+ return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response) ? response : response.destinations;
168
+ })];
151
169
  });
152
170
  });
153
171
  };
@@ -167,7 +185,9 @@ var SubscriptionBooking = /** @class */ (function (_super) {
167
185
  destinationStopName: destinationStopName
168
186
  });
169
187
  url = "".concat(this.config.API_ENDPOINT, "/booking/subscriptions/validityTypes?").concat(searchParams);
170
- return [2 /*return*/, this.callGetApi(url)];
188
+ return [2 /*return*/, this.callGetApi(url).then(function (response) {
189
+ return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response) ? response : response.validityTypes;
190
+ })];
171
191
  });
172
192
  });
173
193
  };
@@ -190,7 +210,9 @@ var SubscriptionBooking = /** @class */ (function (_super) {
190
210
  validityType: validityType
191
211
  });
192
212
  url = "".concat(this.config.API_ENDPOINT, "/booking/subscriptions/search?").concat(searchParams);
193
- return [2 /*return*/, this.callGetApi(url)];
213
+ return [2 /*return*/, this.callGetApi(url).then(function (response) {
214
+ return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response) ? response : response.subscriptions;
215
+ })];
194
216
  });
195
217
  });
196
218
  };
@@ -215,14 +237,16 @@ var SubscriptionBooking = /** @class */ (function (_super) {
215
237
  validityType: request.validityType
216
238
  });
217
239
  url = "".concat(this.config.API_ENDPOINT, "/booking/subscriptions/availabilities?").concat(searchParams);
218
- return [2 /*return*/, this.callGetApi(url)];
240
+ return [2 /*return*/, this.callGetApi(url).then(function (response) {
241
+ return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response) ? response : response;
242
+ })];
219
243
  });
220
244
  });
221
245
  };
222
246
  /**
223
247
  * This method creates a subscription cart for the given parameters.
224
248
  * @param {CreateSubscriptionCartRequest} request the request object containing the parameters for the availability check
225
- * @returns
249
+ * @returns {SubscriptionCart} The created cart
226
250
  */
227
251
  SubscriptionBooking.prototype.createSubscriptionCart = function (request) {
228
252
  return __awaiter(this, void 0, void 0, function () {
@@ -230,12 +254,89 @@ var SubscriptionBooking = /** @class */ (function (_super) {
230
254
  var _this = this;
231
255
  return __generator(this, function (_a) {
232
256
  url = "".concat(this.config.API_ENDPOINT, "/booking/subscriptions");
233
- return [2 /*return*/, this.callPostApi(url, request).then(function (cart) {
234
- _this.cart = cart.cart;
235
- _this.cartStatus = cart.cart.status;
236
- _this.bookingDueDate = new Date(cart.cart.bookingDueDate);
237
- _this.createCartTimer(new Date(cart.cart.bookingDueDate));
238
- return cart.cart;
257
+ return [2 /*return*/, this.callPostApi(url, request).then(function (response) {
258
+ // Check for errors
259
+ if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
260
+ return response;
261
+ }
262
+ _this.cart = response.cart;
263
+ // Save the cartId in the localStorage
264
+ localStorage.setItem("cartId", response.cart.id.toString());
265
+ // Fill the booking process status
266
+ _this.bookingStepsToStatus = new Map(Object.entries(response.cart.stepsToStatus).map(function (_a) {
267
+ var bookingStep = _a[0], values = _a[1];
268
+ return [
269
+ bookingStep,
270
+ values
271
+ ];
272
+ }));
273
+ _this.bookingDueDate = new Date(response.cart.bookingDueDate);
274
+ _this.createCartTimer(new Date(response.cart.bookingDueDate));
275
+ return response.cart;
276
+ })];
277
+ });
278
+ });
279
+ };
280
+ /**
281
+ * @description This method shall be called when the user wants to retrieve information about the buyer and the passengers.
282
+ * @returns An object of type {@link GetBuyerPassengersDetailsResponse} containing the buyer and the passengers information,
283
+ * as well as a list of the available tariffs for each trip.
284
+ */
285
+ SubscriptionBooking.prototype.getBuyerPassengersDetails = function () {
286
+ return __awaiter(this, void 0, void 0, function () {
287
+ var buyerPassengersDetails, url;
288
+ return __generator(this, function (_a) {
289
+ // First check that it is possible to call this API
290
+ if (!this.cart) {
291
+ throw Error("Cart is not initialized yet");
292
+ }
293
+ buyerPassengersDetails = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.BUYER_PASSENGERS);
294
+ if (!buyerPassengersDetails || !buyerPassengersDetails[0]) {
295
+ throw Error("The status of the cart does not allow to call this API");
296
+ }
297
+ url = "".concat(this.config.API_ENDPOINT, "/booking/cart/").concat(this.cart.id, "/details?");
298
+ return [2 /*return*/, this.callGetApi(url).then(function (response) {
299
+ // Check for errors
300
+ if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
301
+ return response;
302
+ }
303
+ // Parse the map for the tariffs
304
+ var tripsToTariffs = new Map(Object.entries(response.tariffs).map(function (_a) {
305
+ var tripId = _a[0], tariff = _a[1];
306
+ return [
307
+ +tripId,
308
+ tariff
309
+ ];
310
+ }));
311
+ return {
312
+ buyer: response.buyer,
313
+ passengers: response.passengers,
314
+ tariffs: tripsToTariffs
315
+ };
316
+ })];
317
+ });
318
+ });
319
+ };
320
+ /**
321
+ * @description This methosd shall be called when the user wants to update the buyer and the passengers information.
322
+ * @param {EditPassengersDetailsRequest} passengersDetails The object containing the buyer and the passengers information.
323
+ * @returns An {@link ErrorResponse} object in case of error, nothing otherwise.
324
+ */
325
+ SubscriptionBooking.prototype.updateBuyerPassengersDetails = function (passengersDetails) {
326
+ return __awaiter(this, void 0, void 0, function () {
327
+ var buyerPassengersDetails, url;
328
+ return __generator(this, function (_a) {
329
+ // First check that it is possible to call this API
330
+ if (!this.cart) {
331
+ throw Error("Cart is not initialized yet");
332
+ }
333
+ buyerPassengersDetails = this.bookingStepsToStatus.get(booking_1.Booking.BookingSteps.BUYER_PASSENGERS);
334
+ if (!buyerPassengersDetails || !buyerPassengersDetails[0]) {
335
+ throw Error("The status of the cart does not allow to call this API");
336
+ }
337
+ url = "".concat(this.config.API_ENDPOINT, "/booking/cart/").concat(this.cart.id, "/details");
338
+ return [2 /*return*/, this.callPostApi(url, passengersDetails).then(function (response) {
339
+ return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response) ? response : response;
239
340
  })];
240
341
  });
241
342
  });
package/lib/index.d.ts CHANGED
@@ -2,9 +2,12 @@ export { Booking } from "./booking/booking";
2
2
  export { JourneyBooking } from "./booking/journeyBooking";
3
3
  export { ServiceBooking } from "./booking/serviceBooking";
4
4
  export { SubscriptionBooking } from "./booking/subscriptionBooking";
5
- export { Person, PassengersDetails, DEFAULT_PERSON } from "./types/common/Person";
6
- export { Tariff, TariffsMatrix, TariffSummary, TariffType, TermsType } from "./types/common/Tariffs";
5
+ export { Person, EditPassengersDetailsRequest, GetBuyerPassengersDetailsResponse, DEFAULT_PERSON } from "./types/common/Person";
6
+ export { Tariff, TariffsMatrix, TariffSummary, TariffType, TermsType, PassengerTariff, ExtraTariff } from "./types/common/Tariffs";
7
+ export { Reduction, AddReductionRequest } from "./types/common/Reduction";
8
+ export { Gateway, GetSellerGatewaysResponse, GetPaymentInformationFromGatewayResponse, GatewayTypes, PaymentMethods } from "./types/common/Payment";
7
9
  export { ErrorResponse } from "./types/ErrorResponse";
10
+ export { BusLayoutCell, BusMatrix, BusCellTypes, SeatStatus } from "./types/journeys/BusMatrix";
8
11
  export { JourneyCart, JourneyBookingType, CreateJourneyCartRequest, TripBookingInfo, DEFAULT_CREATE_JOURNEY_CART } from "./types/journeys/JourneyCart";
9
12
  export { JourneyInfo } from "./types/journeys/JourneyInfo";
10
13
  export { JourneySearchRequest, JourneySearchResult, DEFAULT_JOURNEY_SEARCH } from "./types/journeys/JourneySearch";
package/lib/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_JOURNEY_SEARCH = exports.DEFAULT_CREATE_JOURNEY_CART = exports.DEFAULT_PERSON = exports.SubscriptionBooking = exports.ServiceBooking = exports.JourneyBooking = exports.Booking = void 0;
3
+ exports.DEFAULT_JOURNEY_SEARCH = exports.DEFAULT_CREATE_JOURNEY_CART = exports.SeatStatus = exports.BusCellTypes = exports.PaymentMethods = exports.GatewayTypes = exports.DEFAULT_PERSON = exports.SubscriptionBooking = exports.ServiceBooking = exports.JourneyBooking = exports.Booking = void 0;
4
4
  //#region Export Booking classes
5
5
  var booking_1 = require("./booking/booking");
6
6
  Object.defineProperty(exports, "Booking", { enumerable: true, get: function () { return booking_1.Booking; } });
@@ -15,9 +15,14 @@ Object.defineProperty(exports, "SubscriptionBooking", { enumerable: true, get: f
15
15
  // @note: Cart is not exported because it is extended by other types
16
16
  var Person_1 = require("./types/common/Person");
17
17
  Object.defineProperty(exports, "DEFAULT_PERSON", { enumerable: true, get: function () { return Person_1.DEFAULT_PERSON; } });
18
+ var Payment_1 = require("./types/common/Payment");
19
+ Object.defineProperty(exports, "GatewayTypes", { enumerable: true, get: function () { return Payment_1.GatewayTypes; } });
20
+ Object.defineProperty(exports, "PaymentMethods", { enumerable: true, get: function () { return Payment_1.PaymentMethods; } });
18
21
  //#endregion
19
22
  //#region Export JourneyBooking types
20
- // TODO: BusMatrix.ts
23
+ var BusMatrix_1 = require("./types/journeys/BusMatrix");
24
+ Object.defineProperty(exports, "BusCellTypes", { enumerable: true, get: function () { return BusMatrix_1.BusCellTypes; } });
25
+ Object.defineProperty(exports, "SeatStatus", { enumerable: true, get: function () { return BusMatrix_1.SeatStatus; } });
21
26
  var JourneyCart_1 = require("./types/journeys/JourneyCart");
22
27
  Object.defineProperty(exports, "DEFAULT_CREATE_JOURNEY_CART", { enumerable: true, get: function () { return JourneyCart_1.DEFAULT_CREATE_JOURNEY_CART; } });
23
28
  var JourneySearch_1 = require("./types/journeys/JourneySearch");
@@ -10,3 +10,4 @@ export type ErrorResponse = {
10
10
  mtsCode: number;
11
11
  message: string;
12
12
  };
13
+ export declare const objectIsMTSErrorResponse: (error: any) => boolean;
@@ -1,2 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.objectIsMTSErrorResponse = void 0;
4
+ var objectIsMTSErrorResponse = function (error) {
5
+ return "mtsCode" in error && "httpStatus" in error && "message" in error;
6
+ };
7
+ exports.objectIsMTSErrorResponse = objectIsMTSErrorResponse;
@@ -1,14 +1,20 @@
1
1
  import { Booking } from "../../booking/booking";
2
+ import { Reduction } from "./Reduction";
3
+ import { Extra } from "./Extra";
2
4
  /**
3
5
  * @description Cart is the object returned by the API when a cart is created.
4
6
  * Note that depending on the type of booking, this type will be extended with different fields:
5
- * - TourCart: {@link TourCart.ts}
6
- * - JourneyCart: {@link JourneyCart.ts}
7
- * - SubscriptionCart: {@link SubscriptionCart.ts}
7
+ * - TourCart: {@link ServiceCart}
8
+ * - JourneyCart: {@link JourneyCart}
9
+ * - SubscriptionCart: {@link SubscriptionCart}
8
10
  * @property {number} id The id of the cart
9
11
  * @property {string} cartCode The code of the cart
10
- * @property {Booking.CartStatus} status The status of the cart. See {@link Booking.CartStatus}
11
- * @property {Booking.CartStatus} nextStatus The next status of the cart. See {@link Booking.CartStatus}
12
+ * @property {Map<string, boolean[]>} stepsToStatus This data structure describes the steps of the booking process.
13
+ * The keys of this dictionary represent the booking steps. See ... for the list of possible steps. If the
14
+ * key is present, then the booking step shall be displayed. The value is a list of 3 booleans:
15
+ * - The first tells whether it is possible to go to that section. If not, other sections must be completed first.
16
+ * - The second tells whether the section is completed.
17
+ * - The third tells whether the section is required.
12
18
  * @property {Booking.Currencies} currency The currency of the cart. See {@link Booking.Currencies}
13
19
  * @property {string} bookingDueDate The date and time when the cart expires
14
20
  * @property {number} buyerId The id of the buyer
@@ -16,33 +22,15 @@ import { Booking } from "../../booking/booking";
16
22
  export type Cart = {
17
23
  id: number;
18
24
  cartCode: string;
19
- status: Booking.CartStatus;
20
- nextStatus: Booking.CartStatus;
25
+ stepsToStatus: Map<string, boolean[]>;
21
26
  currency: Booking.Currencies;
22
27
  bookingDueDate: string;
23
28
  buyerId: number;
24
- reductions: {
25
- tripId: number;
26
- tripName: string;
27
- value: number;
28
- isPercentage: boolean;
29
- voucherCode?: string;
30
- }[];
31
- isSeatsSelectionAllowed: boolean;
29
+ reductions: Reduction[];
32
30
  sellingMethod: string;
33
31
  totalValue: number;
34
32
  totalResellerFee?: number;
35
33
  totalCreditFromChange: number;
36
34
  totalAmountToPay: number;
37
- extas: {
38
- id: number;
39
- resourceId: number;
40
- name: string;
41
- description: string;
42
- notes: string;
43
- tariff: {
44
- tariffId: number;
45
- tariffName: string;
46
- };
47
- }[];
35
+ extras: Extra[];
48
36
  };
@@ -0,0 +1,20 @@
1
+ import { ExtraTariff } from "./Tariffs";
2
+ /**
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
+ *
5
+ * @property {number} id The id of the extra
6
+ * @property {number} resourceId The id of a resource associated with this extra, for description purposes.
7
+ * Could the be the id of an image, text or HTML that the seller wants to display to the customer.
8
+ * @property {string} name The name of the extra
9
+ * @property {string} description The description of the extra
10
+ * @property {string} notes Some notes about the extra
11
+ * @property {ExtraTariff} tariff The tariff at which the extra was sold
12
+ */
13
+ export type Extra = {
14
+ id: number;
15
+ resourceId: number;
16
+ name: string;
17
+ description: string;
18
+ notes: string;
19
+ tariff: ExtraTariff;
20
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @description This type represents a payment method available for the cart
3
+ * @param {number} id The id of the payment method
4
+ * @param {GatewayTypes} type The type of the payment method
5
+ * @param {string} name The name of the payment method, to be displayed to the user
6
+ */
7
+ export type Gateway = {
8
+ id: number;
9
+ type: GatewayTypes;
10
+ name: string;
11
+ };
12
+ /**
13
+ * @description This type represents the response of the {@link Booking.getSellerGateways} API. Note that at least
14
+ * one of the two fields will be null, depending on the seller configuration.
15
+ * @param {Gateway | null} cardGatewayDTO The card gateway, if available. Currecntly this can only be {@link GatewayTypes.AXEPTA_BNL}
16
+ * or {@link GatewayTypes.AXERVE_BANCASELLA}
17
+ * @param {Gateway | null} payPalGatewayDTO The PayPal gateway, if available.
18
+ */
19
+ export type GetSellerGatewaysResponse = {
20
+ cardGatewayDTO: Gateway | null;
21
+ payPalGatewayDTO: Gateway | null;
22
+ };
23
+ /**
24
+ * @description This type represents the response of the {@link Booking.getPaymentInformationFromGateway} API.
25
+ * Note that only the fields of the chosen gateway will be populated.
26
+ * @param {string | null} axervE_BANCASELLA_PaymentId The payment id of the Axerve Bancasella gateway
27
+ * @param {string | null} axervE_BANCASELLA_PaymentToken The payment token of the Axerve Bancasella gateway
28
+ * @param {string | null} axervE_BANCASELLA_ShopLogin The shop login of the Axerve Bancasella gateway
29
+ * @param {string | null} axeptA_BNL_PaymentId The payment id of the Axepta BNL gateway
30
+ * @param {string | null} axeptA_BNL_SmartLicenseKey The smart license key of the Axepta BNL gateway
31
+ * @param {string | null} paypaL_ClientId The client id of the PayPal gateway
32
+ * @param {string | null} paypaL_OrderId The order id of the PayPal gateway
33
+ * @param {string | null} paypaL_Link The link of the PayPal gateway
34
+ */
35
+ export type GetPaymentInformationFromGatewayResponse = {
36
+ axervE_BANCASELLA_PaymentId: string | null;
37
+ axervE_BANCASELLA_PaymentToken: string | null;
38
+ axervE_BANCASELLA_ShopLogin: string | null;
39
+ axeptA_BNL_PaymentId: string | null;
40
+ axeptA_BNL_SmartLicenseKey: string | null;
41
+ paypaL_ClientId: string | null;
42
+ paypaL_OrderId: string | null;
43
+ paypaL_Link: string | null;
44
+ };
45
+ /**
46
+ * @description This enum contains the possible values for the `type` field of the {@link Gateway} type
47
+ */
48
+ export declare enum GatewayTypes {
49
+ AXEPTA_BNL = "AXEPTA_BNL",
50
+ AXERVE_BANCASELLA = "AXERVE_BANCASELLA",
51
+ PAYPAL = "PAYPAL"
52
+ }
53
+ /**
54
+ * @description This enum contains the possible values for the `paymentMethod` parameter of the {@link Booking.issueTickets} function.
55
+ */
56
+ export declare enum PaymentMethods {
57
+ CARD = "CARD",
58
+ CASH = "CASH",
59
+ CREDIT_FROM_CHANGE = "CREDIT_FROM_CHANGE",
60
+ PAY_LATER = "PAY_LATER",
61
+ ONLINE_CARD = "ONLINE CARD",
62
+ WALLET = "WALLET"
63
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PaymentMethods = exports.GatewayTypes = void 0;
4
+ /**
5
+ * @description This enum contains the possible values for the `type` field of the {@link Gateway} type
6
+ */
7
+ var GatewayTypes;
8
+ (function (GatewayTypes) {
9
+ GatewayTypes["AXEPTA_BNL"] = "AXEPTA_BNL";
10
+ GatewayTypes["AXERVE_BANCASELLA"] = "AXERVE_BANCASELLA";
11
+ GatewayTypes["PAYPAL"] = "PAYPAL";
12
+ })(GatewayTypes || (exports.GatewayTypes = GatewayTypes = {}));
13
+ /**
14
+ * @description This enum contains the possible values for the `paymentMethod` parameter of the {@link Booking.issueTickets} function.
15
+ */
16
+ var PaymentMethods;
17
+ (function (PaymentMethods) {
18
+ PaymentMethods["CARD"] = "CARD";
19
+ PaymentMethods["CASH"] = "CASH";
20
+ PaymentMethods["CREDIT_FROM_CHANGE"] = "CREDIT_FROM_CHANGE";
21
+ PaymentMethods["PAY_LATER"] = "PAY_LATER";
22
+ PaymentMethods["ONLINE_CARD"] = "ONLINE CARD";
23
+ PaymentMethods["WALLET"] = "WALLET";
24
+ })(PaymentMethods || (exports.PaymentMethods = PaymentMethods = {}));
@@ -1,3 +1,4 @@
1
+ import { PassengerTariff } from "./Tariffs";
1
2
  /**
2
3
  * @description Represents a person, that can be a passenger or the buyer.
3
4
  *
@@ -6,6 +7,7 @@
6
7
  * @property {string} lastName - The last name of the person.
7
8
  * @property {string} email - The email of the person.
8
9
  * @property {string} phoneNumber - The phone number of the person.
10
+ * @property {string} [notes=undefined] - The notes for this person.
9
11
  */
10
12
  export type Person = {
11
13
  id: number;
@@ -13,15 +15,30 @@ export type Person = {
13
15
  lastName: string;
14
16
  email: string;
15
17
  phoneNumber: string;
18
+ notes?: string;
16
19
  };
17
20
  export declare const DEFAULT_PERSON: Person;
21
+ /**
22
+ * @description Represents the response of the {@link getBuyerPassengersDetails} method.
23
+ *
24
+ * @property {Person} buyer - The {@link Person} object representing the buyer.
25
+ * @property {Person[]} passengers - An array of {@link Person} objects representing the passengers.
26
+ * @property {Map<number, PassengerTariff>} tariffs - A map from the trip id to the {@link PassengerTariff} object,
27
+ * representing the available tariffs for that trip (from the ones chosen by the user when creating the cart).
28
+ */
29
+ export type GetBuyerPassengersDetailsResponse = {
30
+ buyer: Person;
31
+ passengers: Person[];
32
+ tariffs: Map<number, PassengerTariff>;
33
+ };
18
34
  /**
19
35
  * @description Represents the passengers details.
36
+ * This type shall be used as request for the {@link updatePassengersDetails} method.
20
37
  *
21
38
  * @property {Person[]} passengers - An array of {@link Person} extended by the map `tripsToTariffs` objects representing the passengers.
22
39
  * @property {Person} buyer - The {@link Person} object representing the buyer.
23
40
  */
24
- export type PassengersDetails = {
41
+ export type EditPassengersDetailsRequest = {
25
42
  passengers: Person[] & {
26
43
  tripsToTariffs: {
27
44
  [tripId: number]: number;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @description This type represents a reduction applied to the cart. Reductions are applied in the booking step `DISCOUNTS`.
3
+ *
4
+ * @property {number} tripId The id of the trip to which the reduction is applied
5
+ * @property {string} tripName The name of the trip to which the reduction is applied
6
+ * @property {number} value The value of the reduction
7
+ * @property {boolean} isPercentage If true, the reduction is a percentage. In this case, it is a number from 0 to 1.
8
+ * Otherwise, it is in the currency of the cart.
9
+ * @property {string} [voucherCode=undefined] The voucher code used to apply the reduction
10
+ */
11
+ export type Reduction = {
12
+ tripId: number;
13
+ tripName: string;
14
+ value: number;
15
+ isPercentage: boolean;
16
+ voucherCode?: string;
17
+ };
18
+ /**
19
+ * @description This type represents a request to add a reduction to the cart
20
+ *
21
+ * @property {number} tripId The id of the trip to which the reduction is applied. If the tripId is 0,
22
+ * then the reduction will be applied to the whole cart
23
+ * @property {number} reduction The value of the reduction
24
+ * @property {boolean} isPercentage If true, the reduction is a percentage. In this case, it is a number from 0 to 1.
25
+ * Otherwise, it is in the currency of the cart (the value must be greater than 0)
26
+ */
27
+ export type AddReductionRequest = {
28
+ tripId: number;
29
+ reduction: number;
30
+ isPercentage: boolean;
31
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -55,3 +55,24 @@ export type TariffSummary = {
55
55
  label: string;
56
56
  value: number;
57
57
  };
58
+ /**
59
+ * @description This type represent a tariff on a particular trip. It shall be used for selecting the tariffs
60
+ * of the passenger (in the passenger details page).
61
+ *
62
+ * @property {number} id The id of the tariff
63
+ * @property {string} tariffName The name of the tariff
64
+ */
65
+ export type PassengerTariff = {
66
+ id: number;
67
+ tariffName: string;
68
+ };
69
+ /**
70
+ * @description This type represents the tariff at which the extra was sold.
71
+ *
72
+ * @property {number} tariffId The id of the tariff
73
+ * @property {string} tariffName The name of the tariff
74
+ */
75
+ export type ExtraTariff = {
76
+ tariffId: number;
77
+ tariffName: string;
78
+ };
@@ -0,0 +1,34 @@
1
+ /**
2
+ * This represents a a bus layout cell, a part of a {@link BusMatrix}.
3
+ * @param {number} id - The id of bus layout cell.
4
+ * @param {BusCellTypes} type - The id of the bus layout cell. It shall be used to select what to display when rendering the bus layout.
5
+ * @param {string} label - The label to display on the seat (e.g. 8A)
6
+ * @param {SeatStatus} status - The status of the seat.
7
+ */
8
+ export type BusLayoutCell = {
9
+ id: number;
10
+ type: BusCellTypes;
11
+ label: string;
12
+ status: SeatStatus;
13
+ };
14
+ /**
15
+ * This represents a tariff matrix. It is a 3D array of {@link BusLayoutCell} objects.
16
+ * - On the first dimension, there is the floor of the bus.
17
+ * - On the second dimentsion, there are the rows.
18
+ * - On the third dimension, the are the columns.
19
+ */
20
+ export type BusMatrix = BusLayoutCell[][][];
21
+ export declare enum BusCellTypes {
22
+ SEAT = "SEAT",
23
+ SELECTED_SEAT = "SELECTED_SEAT",
24
+ DRIVER = "DRIVER",
25
+ WC = "WC",
26
+ EXIT = "EXIT",
27
+ TABLE = "TABLE",
28
+ STAIRS = "STAIRS"
29
+ }
30
+ export declare enum SeatStatus {
31
+ RESERVED = "RESERVED",
32
+ AVAILABLE = "AVAILABLE",
33
+ OCCUPIED = "OCCUPIED"
34
+ }
@@ -1 +1,21 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SeatStatus = exports.BusCellTypes = void 0;
4
+ // Possible type BusSeat
5
+ var BusCellTypes;
6
+ (function (BusCellTypes) {
7
+ BusCellTypes["SEAT"] = "SEAT";
8
+ BusCellTypes["SELECTED_SEAT"] = "SELECTED_SEAT";
9
+ BusCellTypes["DRIVER"] = "DRIVER";
10
+ BusCellTypes["WC"] = "WC";
11
+ BusCellTypes["EXIT"] = "EXIT";
12
+ BusCellTypes["TABLE"] = "TABLE";
13
+ BusCellTypes["STAIRS"] = "STAIRS";
14
+ })(BusCellTypes || (exports.BusCellTypes = BusCellTypes = {}));
15
+ // Possible status for a seat
16
+ var SeatStatus;
17
+ (function (SeatStatus) {
18
+ SeatStatus["RESERVED"] = "RESERVED";
19
+ SeatStatus["AVAILABLE"] = "AVAILABLE";
20
+ SeatStatus["OCCUPIED"] = "OCCUPIED";
21
+ })(SeatStatus || (exports.SeatStatus = SeatStatus = {}));
@@ -22,7 +22,7 @@ export type CreateServiceCartRequest = {
22
22
  };
23
23
  };
24
24
  /**
25
- * @description Represents a `JourneyCart`, which extends the {@link Cart} type by including additional
25
+ * @description Represents a `ServiceCart`, which extends the {@link Cart} type by including additional
26
26
  * information about the bookings
27
27
  *
28
28
  * @property {ServiceBooking[]} bookings - An array of {@link ServiceBookingType} objects representing the bookings associated