mts-booking-library 1.2.27 → 1.2.28
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/booking/booking.js +1 -1
- package/lib/booking/journeyBooking.d.ts +2 -2
- package/lib/booking/journeyBooking.js +10 -10
- package/lib/booking/serviceBooking.d.ts +2 -2
- package/lib/booking/serviceBooking.js +9 -10
- package/lib/booking/subscriptionBooking.d.ts +2 -2
- package/lib/booking/subscriptionBooking.js +8 -8
- package/lib/index.d.ts +3 -3
- package/lib/types/common/Cart.d.ts +3 -0
- package/lib/types/journeys/JourneyCart.d.ts +0 -10
- package/lib/types/services/ServiceCart.d.ts +0 -10
- package/lib/types/subscriptions/SubscriptionCart.d.ts +0 -10
- package/package.json +1 -1
package/lib/booking/booking.js
CHANGED
@@ -233,7 +233,7 @@ var Booking = /** @class */ (function () {
|
|
233
233
|
}
|
234
234
|
_e.label = 5;
|
235
235
|
case 5:
|
236
|
-
url = "".concat(this.config.API_ENDPOINT, "/sellers/").concat(this.sellerId, "/gateways?language=").concat(this.language);
|
236
|
+
url = "".concat(this.config.API_ENDPOINT, "/booking/sellers/").concat(this.sellerId, "/gateways?language=").concat(this.language);
|
237
237
|
// We use directly makeGet because we don't want to add sellerId to the query string (it is already present in the url)
|
238
238
|
return [2 /*return*/, (0, apiCall_1.makeGet)(url).then(function (response) {
|
239
239
|
return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response) ? response : response;
|
@@ -3,7 +3,7 @@ import { ErrorResponse } from "../types/ErrorResponse";
|
|
3
3
|
import { EditPassengersDetailsRequest, GetBuyerPassengersDetailsResponse, Person } from "../types/common/Person";
|
4
4
|
import { AddReductionRequest } from "../types/common/Reduction";
|
5
5
|
import { BusMatrix } from "../types/journeys/BusMatrix";
|
6
|
-
import { CreateJourneyCartRequest,
|
6
|
+
import { CreateJourneyCartRequest, JourneyCart } from "../types/journeys/JourneyCart";
|
7
7
|
import { JourneySearchRequest, JourneySearchResult } from "../types/journeys/JourneySearch";
|
8
8
|
import { ReductionTrip } from "../types/journeys/Trip";
|
9
9
|
import { Booking } from "./booking";
|
@@ -23,7 +23,7 @@ export declare class JourneyBooking extends Booking {
|
|
23
23
|
getCart(): JourneyCart | undefined;
|
24
24
|
resetBooking(): void;
|
25
25
|
fetchAndSetCart(cartId: number): Promise<void>;
|
26
|
-
fetchCart(cartId: number): Promise<
|
26
|
+
fetchCart(cartId: number): Promise<JourneyCart>;
|
27
27
|
/**
|
28
28
|
* This method allows to delete a cart, thus allowing the user to exit from the booking process.
|
29
29
|
* @returns An {@link ErrorResponse} object in case of error, nothing otherwise. Note that also in case of error, all
|
@@ -115,15 +115,15 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
115
115
|
var _this = this;
|
116
116
|
return __generator(this, function (_a) {
|
117
117
|
switch (_a.label) {
|
118
|
-
case 0: return [4 /*yield*/, this.fetchCart(cartId).then(function (
|
119
|
-
if (
|
120
|
-
var cartDate = new Date(
|
121
|
-
if (cartDate > new Date()) {
|
122
|
-
_this.cart =
|
123
|
-
_this.cartId =
|
118
|
+
case 0: return [4 /*yield*/, this.fetchCart(cartId).then(function (cart) {
|
119
|
+
if (cart) {
|
120
|
+
var cartDate = new Date(cart.bookingDueDate);
|
121
|
+
if (cartDate > new Date() && !cart.hasIssuedTickets) {
|
122
|
+
_this.cart = cart;
|
123
|
+
_this.cartId = cart.id;
|
124
124
|
_this.bookingDueDate = cartDate; // See Booking class
|
125
125
|
// Fill the booking process status
|
126
|
-
_this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(
|
126
|
+
_this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(cart.stepsToStatus);
|
127
127
|
}
|
128
128
|
else {
|
129
129
|
// This should never happen, but just in case
|
@@ -149,11 +149,11 @@ var JourneyBooking = /** @class */ (function (_super) {
|
|
149
149
|
_this.resetBooking();
|
150
150
|
throw new Error(response);
|
151
151
|
}
|
152
|
-
// Check that the cart
|
153
|
-
if (response.hasIssuedTickets) {
|
152
|
+
// Check that the cart does not have issued tickets
|
153
|
+
if (response.cart.hasIssuedTickets) {
|
154
154
|
_this.resetBooking();
|
155
155
|
}
|
156
|
-
return response;
|
156
|
+
return response.cart;
|
157
157
|
})];
|
158
158
|
});
|
159
159
|
});
|
@@ -3,7 +3,7 @@ import { ErrorResponse } from "../types/ErrorResponse";
|
|
3
3
|
import { GetBuyerPassengersDetailsResponse, Person } from "../types/common/Person";
|
4
4
|
import { AddReductionRequest } from "../types/common/Reduction";
|
5
5
|
import { Service, ServiceTrip } from "../types/services/Service";
|
6
|
-
import { CreateServiceCartRequest,
|
6
|
+
import { CreateServiceCartRequest, ServiceCart } from "../types/services/ServiceCart";
|
7
7
|
import { Booking } from "./booking";
|
8
8
|
export declare class ServiceBooking extends Booking {
|
9
9
|
private cart?;
|
@@ -21,7 +21,7 @@ export declare class ServiceBooking extends Booking {
|
|
21
21
|
getCart(): ServiceCart | undefined;
|
22
22
|
resetBooking(): void;
|
23
23
|
fetchAndSetCart(cartId: number): Promise<void>;
|
24
|
-
fetchCart(cartId: number): Promise<
|
24
|
+
fetchCart(cartId: number): Promise<ServiceCart>;
|
25
25
|
/**
|
26
26
|
* This method allows to delete a cart, thus allowing the user to exit from the booking process.
|
27
27
|
* @returns An {@link ErrorResponse} object in case of error, nothing otherwise. Note that also in case of error, all
|
@@ -115,16 +115,15 @@ var ServiceBooking = /** @class */ (function (_super) {
|
|
115
115
|
var _this = this;
|
116
116
|
return __generator(this, function (_a) {
|
117
117
|
switch (_a.label) {
|
118
|
-
case 0: return [4 /*yield*/, this.fetchCart(cartId).then(function (
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
_this.
|
124
|
-
_this.cartId = response.cart.id;
|
118
|
+
case 0: return [4 /*yield*/, this.fetchCart(cartId).then(function (cart) {
|
119
|
+
if (cart) {
|
120
|
+
var cartDate = new Date(cart.bookingDueDate);
|
121
|
+
if (cartDate > new Date() && !cart.hasIssuedTickets) {
|
122
|
+
_this.cart = cart;
|
123
|
+
_this.cartId = cart.id;
|
125
124
|
_this.bookingDueDate = cartDate; // See Booking class
|
126
125
|
// Fill the booking process status
|
127
|
-
_this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(
|
126
|
+
_this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(cart.stepsToStatus);
|
128
127
|
}
|
129
128
|
else {
|
130
129
|
// This should never happen, but just in case
|
@@ -151,10 +150,10 @@ var ServiceBooking = /** @class */ (function (_super) {
|
|
151
150
|
throw new Error(response);
|
152
151
|
}
|
153
152
|
// Check that the cart doe not have issued tickets
|
154
|
-
if (response.hasIssuedTickets) {
|
153
|
+
if (response.cart.hasIssuedTickets) {
|
155
154
|
_this.resetBooking();
|
156
155
|
}
|
157
|
-
return response;
|
156
|
+
return response.cart;
|
158
157
|
})];
|
159
158
|
});
|
160
159
|
});
|
@@ -3,7 +3,7 @@ import { ErrorResponse } from "../types/ErrorResponse";
|
|
3
3
|
import { EditPassengersDetailsRequest, GetBuyerPassengersDetailsResponse, Person } from "../types/common/Person";
|
4
4
|
import { AddReductionRequest } from "../types/common/Reduction";
|
5
5
|
import { GetSubscriptionAvailabilityRequest, GetSubscriptionAvailabilityResponse } from "../types/subscriptions/SubscriptionAvailabilities";
|
6
|
-
import { CreateSubscriptionCartRequest,
|
6
|
+
import { CreateSubscriptionCartRequest, SubscriptionCart } from "../types/subscriptions/SubscriptionCart";
|
7
7
|
import { Subscription } from "../types/subscriptions/Subscriptions";
|
8
8
|
import { Booking } from "./booking";
|
9
9
|
export declare class SubscriptionBooking extends Booking {
|
@@ -22,7 +22,7 @@ export declare class SubscriptionBooking extends Booking {
|
|
22
22
|
getCart(): SubscriptionCart | undefined;
|
23
23
|
resetBooking(): void;
|
24
24
|
fetchAndSetCart(cartId: number): Promise<void>;
|
25
|
-
fetchCart(cartId: number): Promise<
|
25
|
+
fetchCart(cartId: number): Promise<SubscriptionCart>;
|
26
26
|
/**
|
27
27
|
* This method allows to delete a cart, thus allowing the user to exit from the booking process.
|
28
28
|
* @returns An {@link ErrorResponse} object in case of error, nothing otherwise. Note that also in case of error, all
|
@@ -115,15 +115,15 @@ var SubscriptionBooking = /** @class */ (function (_super) {
|
|
115
115
|
var _this = this;
|
116
116
|
return __generator(this, function (_a) {
|
117
117
|
switch (_a.label) {
|
118
|
-
case 0: return [4 /*yield*/, this.fetchCart(cartId).then(function (
|
119
|
-
if (
|
120
|
-
var cartDate = new Date(
|
121
|
-
if (cartDate > new Date()) {
|
122
|
-
_this.cart =
|
123
|
-
_this.cartId =
|
118
|
+
case 0: return [4 /*yield*/, this.fetchCart(cartId).then(function (cart) {
|
119
|
+
if (cart) {
|
120
|
+
var cartDate = new Date(cart.bookingDueDate);
|
121
|
+
if (cartDate > new Date() && !cart.hasIssuedTickets) {
|
122
|
+
_this.cart = cart;
|
123
|
+
_this.cartId = cart.id;
|
124
124
|
_this.bookingDueDate = cartDate; // See Booking class
|
125
125
|
// Fill the booking process status
|
126
|
-
_this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(
|
126
|
+
_this.bookingStepsToStatus = (0, processBookingSteps_1.processBookingSteps)(cart.stepsToStatus);
|
127
127
|
}
|
128
128
|
else {
|
129
129
|
// This should never happen, but just in case
|
@@ -150,7 +150,7 @@ var SubscriptionBooking = /** @class */ (function (_super) {
|
|
150
150
|
throw new Error(response);
|
151
151
|
}
|
152
152
|
// Check that the cart doe not have issued tickets
|
153
|
-
if (response.hasIssuedTickets) {
|
153
|
+
if (response.cart.hasIssuedTickets) {
|
154
154
|
_this.resetBooking();
|
155
155
|
}
|
156
156
|
return response;
|
package/lib/index.d.ts
CHANGED
@@ -10,15 +10,15 @@ export { Reduction, AddReductionRequest } from "./types/common/Reduction";
|
|
10
10
|
export { Gateway, GetSellerGatewaysResponse, GetPaymentInformationFromGatewayResponse, IssueTicketsResponse, GatewayTypes, PaymentMethods } from "./types/common/Payment";
|
11
11
|
export { ErrorResponse, objectIsMTSErrorResponse } from "./types/ErrorResponse";
|
12
12
|
export { BusLayoutCell, BusMatrix, BusCellTypes, SeatStatus } from "./types/journeys/BusMatrix";
|
13
|
-
export { JourneyCart,
|
13
|
+
export { JourneyCart, JourneyBookingType, CreateJourneyCartRequest, TripBookingInfo, DEFAULT_CREATE_JOURNEY_CART } from "./types/journeys/JourneyCart";
|
14
14
|
export { JourneyInfo } from "./types/journeys/JourneyInfo";
|
15
15
|
export { JourneySearchRequest, JourneySearchResult, DEFAULT_JOURNEY_SEARCH } from "./types/journeys/JourneySearch";
|
16
16
|
export { Stop } from "./types/journeys/Stop";
|
17
17
|
export { Trip, CartTrip, ReductionTrip } from "./types/journeys/Trip";
|
18
18
|
export { Line } from "./types/services/Line";
|
19
19
|
export { Service, ServiceTrip } from "./types/services/Service";
|
20
|
-
export { ServiceCart,
|
20
|
+
export { ServiceCart, ServiceBookingType, CreateServiceCartRequest } from "./types/services/ServiceCart";
|
21
21
|
export { ServiceInfo } from "./types/services/ServiceInfo";
|
22
22
|
export { Subscription } from "./types/subscriptions/Subscriptions";
|
23
23
|
export { GetSubscriptionAvailabilityRequest, GetSubscriptionAvailabilityResponse, SubscriptionCalendarDayPeriodInfo } from "./types/subscriptions/SubscriptionAvailabilities";
|
24
|
-
export { SubscriptionCart,
|
24
|
+
export { SubscriptionCart, SubscriptionBookingType, CreateSubscriptionCartRequest, SubscriptionPeriod } from "./types/subscriptions/SubscriptionCart";
|
@@ -9,6 +9,8 @@ import { Extra } from "./Extra";
|
|
9
9
|
* - SubscriptionCart: {@link SubscriptionCart}
|
10
10
|
* @property {number} id The id of the cart
|
11
11
|
* @property {string} cartCode The code of the cart
|
12
|
+
* @property {boolean} hasIssuedTickets - A boolean telling whether the cart has issued tickets. Note that if this is the case,
|
13
|
+
* the cart will be null because it is not possible to add tickets to an issued cart. Thus, all data should be reset.
|
12
14
|
* @property {number} sellerId The id of the seller of the tickets in the cart
|
13
15
|
* @property {Map<string, boolean[]>} stepsToStatus This data structure describes the steps of the booking process.
|
14
16
|
* The keys of this dictionary represent the booking steps. See ... for the list of possible steps. If the
|
@@ -23,6 +25,7 @@ export type Cart = {
|
|
23
25
|
id: number;
|
24
26
|
sellerId: number;
|
25
27
|
cartCode: string;
|
28
|
+
hasIssuedTickets: boolean;
|
26
29
|
stepsToStatus: Map<string, boolean[]>;
|
27
30
|
currency: Booking.Currencies;
|
28
31
|
bookingDueDate: string;
|
@@ -35,16 +35,6 @@ export type CreateJourneyCartRequest = {
|
|
35
35
|
returnJourney: TripBookingInfo[] | null;
|
36
36
|
};
|
37
37
|
export declare const DEFAULT_CREATE_JOURNEY_CART: CreateJourneyCartRequest;
|
38
|
-
/**
|
39
|
-
* This type represents the response of the {@link JourneyBooking.fetchCart} API.
|
40
|
-
* @property {JourneyCart} cart - The {@link JourneyCart} object representing the cart.
|
41
|
-
* @property {boolean} hasIssuedTickets - A boolean telling whether the cart has issued tickets. Note that if this is the case,
|
42
|
-
* the cart will be null because it is not possible to add tickets to an issued cart. Thus, all data should be reset.
|
43
|
-
*/
|
44
|
-
export type GetJourneyCartResponse = {
|
45
|
-
cart: JourneyCart | null;
|
46
|
-
hasIssuedTickets: boolean;
|
47
|
-
};
|
48
38
|
/**
|
49
39
|
* @description Represents a `JourneyCart`, which extends the {@link Cart} type by including additional
|
50
40
|
* information about the bookings
|
@@ -31,16 +31,6 @@ export type CreateServiceCartRequest = {
|
|
31
31
|
export type ServiceCart = Cart & {
|
32
32
|
bookings: ServiceBookingType[];
|
33
33
|
};
|
34
|
-
/**
|
35
|
-
* This type represents the response of the {@link ServiceBooking.fetchCart} API.
|
36
|
-
* @property {JourneyCart} cart - The {@link ServiceCart} object representing the cart.
|
37
|
-
* @property {boolean} hasIssuedTickets - A boolean telling whether the cart has issued tickets. Note that if this is the case,
|
38
|
-
* the cart will be null because it is not possible to add tickets to an issued cart. Thus, all data should be reset.
|
39
|
-
*/
|
40
|
-
export type GetServiceCartResponse = {
|
41
|
-
cart: ServiceCart | null;
|
42
|
-
hasIssuedTickets: boolean;
|
43
|
-
};
|
44
34
|
/**
|
45
35
|
* @description Represents a `ServiceBooking`, which contains information about a service booking.
|
46
36
|
*
|
@@ -48,16 +48,6 @@ export type SubscriptionPeriod = {
|
|
48
48
|
export type SubscriptionCart = Cart & {
|
49
49
|
bookings: SubscriptionBookingType[];
|
50
50
|
};
|
51
|
-
/**
|
52
|
-
* This type represents the response of the {@link SubscriptionBooking.fetchCart} API.
|
53
|
-
* @property {JourneyCart} cart - The {@link SubscriptionCart} object representing the cart.
|
54
|
-
* @property {boolean} hasIssuedTickets - A boolean telling whether the cart has issued tickets. Note that if this is the case,
|
55
|
-
* the cart will be null because it is not possible to add tickets to an issued cart. Thus, all data should be reset.
|
56
|
-
*/
|
57
|
-
export type GetSubscriptionCartResponse = {
|
58
|
-
cart: SubscriptionCart | null;
|
59
|
-
hasIssuedTickets: boolean;
|
60
|
-
};
|
61
51
|
/**
|
62
52
|
* @description Represents a `SubscriptionBooking`, which contains information about a subscription booking.
|
63
53
|
*
|