mts-booking-library 1.2.4 → 1.2.6
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.
- package/lib/booking/journeyBooking.js +22 -10
- package/lib/booking/subscriptionBooking.js +22 -10
- package/lib/index.d.ts +3 -2
- package/lib/index.js +5 -1
- package/lib/types/common/Person.d.ts +25 -5
- package/lib/types/common/Person.js +7 -1
- package/package.json +1 -1
@@ -260,18 +260,30 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
260
260
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
261
261
|
return response;
|
262
262
|
}
|
263
|
-
//
|
264
|
-
var
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
263
|
+
// For each passenger, parse the outbound and return tariffs
|
264
|
+
var passengers = response.passengers;
|
265
|
+
passengers.map(function (passenger) {
|
266
|
+
// Parse the outbound tariffs
|
267
|
+
passenger.outboundTariffs = new Map(Object.entries(passenger.outboundTariffs).map(function (_a) {
|
268
|
+
var tripId = _a[0], tariffs = _a[1];
|
269
|
+
return [
|
270
|
+
+tripId,
|
271
|
+
tariffs
|
272
|
+
];
|
273
|
+
}));
|
274
|
+
// Parse the return tariffs
|
275
|
+
passenger.returnTariffs = new Map(Object.entries(passenger.returnTariffs).map(function (_a) {
|
276
|
+
var tripId = _a[0], tariffs = _a[1];
|
277
|
+
return [
|
278
|
+
+tripId,
|
279
|
+
tariffs
|
280
|
+
];
|
281
|
+
}));
|
282
|
+
});
|
271
283
|
return {
|
284
|
+
buyerDataStatus: response.buyerDataStatus,
|
272
285
|
buyer: response.buyer,
|
273
|
-
passengers:
|
274
|
-
tariffs: tripsToTariffs
|
286
|
+
passengers: passengers,
|
275
287
|
};
|
276
288
|
})];
|
277
289
|
});
|
@@ -309,18 +309,30 @@ var SubscriptionBooking = /** @class */ (function (_super) {
|
|
309
309
|
if ((0, ErrorResponse_1.objectIsMTSErrorResponse)(response)) {
|
310
310
|
return response;
|
311
311
|
}
|
312
|
-
//
|
313
|
-
var
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
312
|
+
// For each passenger, parse the outbound and return tariffs
|
313
|
+
var passengers = response.passengers;
|
314
|
+
passengers.map(function (passenger) {
|
315
|
+
// Parse the outbound tariffs
|
316
|
+
passenger.outboundTariffs = new Map(Object.entries(passenger.outboundTariffs).map(function (_a) {
|
317
|
+
var tripId = _a[0], tariffs = _a[1];
|
318
|
+
return [
|
319
|
+
+tripId,
|
320
|
+
tariffs
|
321
|
+
];
|
322
|
+
}));
|
323
|
+
// Parse the return tariffs
|
324
|
+
passenger.returnTariffs = new Map(Object.entries(passenger.returnTariffs).map(function (_a) {
|
325
|
+
var tripId = _a[0], tariffs = _a[1];
|
326
|
+
return [
|
327
|
+
+tripId,
|
328
|
+
tariffs
|
329
|
+
];
|
330
|
+
}));
|
331
|
+
});
|
320
332
|
return {
|
333
|
+
buyerDataStatus: response.buyerDataStatus,
|
321
334
|
buyer: response.buyer,
|
322
|
-
passengers:
|
323
|
-
tariffs: tripsToTariffs
|
335
|
+
passengers: passengers,
|
324
336
|
};
|
325
337
|
})];
|
326
338
|
});
|
package/lib/index.d.ts
CHANGED
@@ -3,11 +3,12 @@ export { JourneyBooking } from "./booking/journeyBooking";
|
|
3
3
|
export { ServiceBooking } from "./booking/serviceBooking";
|
4
4
|
export { SubscriptionBooking } from "./booking/subscriptionBooking";
|
5
5
|
export { Person, DEFAULT_PERSON, initializePerson } from "./types/common/Person";
|
6
|
-
export {
|
6
|
+
export { GetBuyerPassengersDetailsResponse, GetPassenger, BuyerDataStatus } from "./types/common/Person";
|
7
|
+
export { EditPassengerRequestType, EditPassengersDetailsRequest } from "./types/common/Person";
|
7
8
|
export { Tariff, TariffsMatrix, TariffSummary, TariffType, TermsType, PassengerTariff, ExtraTariff } from "./types/common/Tariffs";
|
8
9
|
export { Reduction, AddReductionRequest } from "./types/common/Reduction";
|
9
10
|
export { Gateway, GetSellerGatewaysResponse, GetPaymentInformationFromGatewayResponse, GatewayTypes, PaymentMethods } from "./types/common/Payment";
|
10
|
-
export { ErrorResponse } from "./types/ErrorResponse";
|
11
|
+
export { ErrorResponse, objectIsMTSErrorResponse } from "./types/ErrorResponse";
|
11
12
|
export { BusLayoutCell, BusMatrix, BusCellTypes, SeatStatus } from "./types/journeys/BusMatrix";
|
12
13
|
export { JourneyCart, JourneyBookingType, CreateJourneyCartRequest, TripBookingInfo, DEFAULT_CREATE_JOURNEY_CART } from "./types/journeys/JourneyCart";
|
13
14
|
export { JourneyInfo } from "./types/journeys/JourneyInfo";
|
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.SeatStatus = exports.BusCellTypes = exports.PaymentMethods = exports.GatewayTypes = exports.initializePerson = 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.objectIsMTSErrorResponse = exports.PaymentMethods = exports.GatewayTypes = exports.BuyerDataStatus = exports.initializePerson = 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; } });
|
@@ -16,9 +16,13 @@ Object.defineProperty(exports, "SubscriptionBooking", { enumerable: true, get: f
|
|
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
18
|
Object.defineProperty(exports, "initializePerson", { enumerable: true, get: function () { return Person_1.initializePerson; } });
|
19
|
+
var Person_2 = require("./types/common/Person");
|
20
|
+
Object.defineProperty(exports, "BuyerDataStatus", { enumerable: true, get: function () { return Person_2.BuyerDataStatus; } });
|
19
21
|
var Payment_1 = require("./types/common/Payment");
|
20
22
|
Object.defineProperty(exports, "GatewayTypes", { enumerable: true, get: function () { return Payment_1.GatewayTypes; } });
|
21
23
|
Object.defineProperty(exports, "PaymentMethods", { enumerable: true, get: function () { return Payment_1.PaymentMethods; } });
|
24
|
+
var ErrorResponse_1 = require("./types/ErrorResponse");
|
25
|
+
Object.defineProperty(exports, "objectIsMTSErrorResponse", { enumerable: true, get: function () { return ErrorResponse_1.objectIsMTSErrorResponse; } });
|
22
26
|
//#endregion
|
23
27
|
//#region Export JourneyBooking types
|
24
28
|
var BusMatrix_1 = require("./types/journeys/BusMatrix");
|
@@ -19,18 +19,38 @@ export type Person = {
|
|
19
19
|
};
|
20
20
|
export declare const DEFAULT_PERSON: Person;
|
21
21
|
export declare const initializePerson: (person?: Person | undefined | null) => Person;
|
22
|
+
/**
|
23
|
+
* @description Represents a passenger in the response of the {@link getPassengersDetails} method. This type extends the {@link Person} type
|
24
|
+
* with the `outboundTariffs` and `returnTariffs` properties.
|
25
|
+
*
|
26
|
+
* @property { Map<number, PassengerTariff>} outboundTariffs - A map containing the outbound tariffs for this passenger. The key is the trip id.
|
27
|
+
* For every trip, the first element the value is the suggested tariff. The other elements are the other tariffs, so that the user can adjust
|
28
|
+
* the tariff for the passenger.
|
29
|
+
* @property { Map<number, PassengerTariff>} returnTariffs - Same of `outboundTariffs`, but for the return trip.
|
30
|
+
*/
|
31
|
+
export type GetPassenger = Person & {
|
32
|
+
outboundTariffs: Map<number, PassengerTariff[]>;
|
33
|
+
returnTariffs: Map<number, PassengerTariff[]>;
|
34
|
+
};
|
35
|
+
export declare enum BuyerDataStatus {
|
36
|
+
OPTIONAL = 0,
|
37
|
+
REQUIRED = 1,
|
38
|
+
CANNOT_BE_SPECIFIED = 2
|
39
|
+
}
|
22
40
|
/**
|
23
41
|
* @description Represents the response of the {@link getBuyerPassengersDetails} method.
|
24
42
|
*
|
43
|
+
* @property {BuyerDataStatus} buyerDataStatus - Whether the for for the buyer data are required, optional or cannot be specified.
|
44
|
+
* - `OPTIONAL`: The buyer data are optional. Buyer form shall be displayed, but the user can skip it.
|
45
|
+
* - `REQUIRED`: The buyer data are required. Buyer form shall be displayed and the user cannot skip it.
|
46
|
+
* - `CANNOT_BE_SPECIFIED`: The buyer data cannot be specified. Buyer form shall not be displayed.
|
25
47
|
* @property {Person} buyer - The {@link Person} object representing the buyer.
|
26
|
-
* @property {
|
27
|
-
* @property {Map<number, PassengerTariff>} tariffs - A map from the trip id to the {@link PassengerTariff} object,
|
28
|
-
* representing the available tariffs for that trip (from the ones chosen by the user when creating the cart).
|
48
|
+
* @property {GetPassenger[]} passengers - An array of {@link GetPassenger} objects representing the passengers.
|
29
49
|
*/
|
30
50
|
export type GetBuyerPassengersDetailsResponse = {
|
51
|
+
buyerDataStatus: BuyerDataStatus;
|
31
52
|
buyer: Person;
|
32
|
-
passengers:
|
33
|
-
tariffs: Map<number, PassengerTariff>;
|
53
|
+
passengers: GetPassenger[];
|
34
54
|
};
|
35
55
|
/**
|
36
56
|
* @description Represents the type of the passengers array in {@link EditPassengersDetailsRequest}.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
// This module contains the types to manage the passengers information
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
exports.initializePerson = exports.DEFAULT_PERSON = void 0;
|
4
|
+
exports.BuyerDataStatus = exports.initializePerson = exports.DEFAULT_PERSON = void 0;
|
5
5
|
exports.DEFAULT_PERSON = {
|
6
6
|
id: 0,
|
7
7
|
name: '',
|
@@ -16,3 +16,9 @@ var initializePerson = function (person) {
|
|
16
16
|
return person;
|
17
17
|
};
|
18
18
|
exports.initializePerson = initializePerson;
|
19
|
+
var BuyerDataStatus;
|
20
|
+
(function (BuyerDataStatus) {
|
21
|
+
BuyerDataStatus[BuyerDataStatus["OPTIONAL"] = 0] = "OPTIONAL";
|
22
|
+
BuyerDataStatus[BuyerDataStatus["REQUIRED"] = 1] = "REQUIRED";
|
23
|
+
BuyerDataStatus[BuyerDataStatus["CANNOT_BE_SPECIFIED"] = 2] = "CANNOT_BE_SPECIFIED";
|
24
|
+
})(BuyerDataStatus || (exports.BuyerDataStatus = BuyerDataStatus = {}));
|