mts-booking-library 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. package/lib/booking/booking.d.ts +44 -0
  2. package/lib/booking/journeyBooking.d.ts +49 -0
  3. package/lib/booking/serviceBooking.d.ts +36 -0
  4. package/lib/booking/subscriptionBooking.d.ts +50 -0
  5. package/lib/config.d.ts +2 -1
  6. package/lib/index.d.ts +15 -140
  7. package/lib/types/common/Cart.d.ts +47 -0
  8. package/lib/types/common/Person.d.ts +31 -0
  9. package/lib/types/{TermsAndTariffs.d.ts → common/Tariffs.d.ts} +5 -0
  10. package/lib/types/journeys/JourneyCart.d.ts +55 -0
  11. package/lib/types/journeys/JourneyInfo.d.ts +18 -0
  12. package/lib/types/journeys/JourneySearch.d.ts +19 -0
  13. package/lib/types/journeys/Stop.d.ts +16 -0
  14. package/lib/types/{Journeys → journeys}/Trip.d.ts +1 -1
  15. package/lib/types/services/Line.d.ts +14 -0
  16. package/lib/types/services/Service.d.ts +33 -0
  17. package/lib/types/services/ServiceCart.d.ts +46 -0
  18. package/lib/types/services/ServiceInfo.d.ts +14 -0
  19. package/package.json +1 -1
  20. package/lib/types/Booking.d.ts +0 -0
  21. package/lib/types/Booking.js +0 -1
  22. package/lib/types/Cart.d.ts +0 -79
  23. package/lib/types/Cart.js +0 -2
  24. package/lib/types/Details.d.ts +0 -9
  25. package/lib/types/Details.js +0 -2
  26. package/lib/types/Info.d.ts +0 -8
  27. package/lib/types/Info.js +0 -2
  28. package/lib/types/Journey.d.ts +0 -8
  29. package/lib/types/Journey.js +0 -2
  30. package/lib/types/JourneySearch.d.ts +0 -9
  31. package/lib/types/JourneySearch.js +0 -2
  32. package/lib/types/Journeys/BusMatrix.d.ts +0 -0
  33. package/lib/types/Journeys/BusMatrix.js +0 -1
  34. package/lib/types/Journeys/Journey.d.ts +0 -8
  35. package/lib/types/Journeys/Journey.js +0 -2
  36. package/lib/types/Journeys/JourneySearch.d.ts +0 -11
  37. package/lib/types/Journeys/Stop.d.ts +0 -7
  38. package/lib/types/Line.d.ts +0 -6
  39. package/lib/types/Line.js +0 -2
  40. package/lib/types/Person.d.ts +0 -7
  41. package/lib/types/Person.js +0 -2
  42. package/lib/types/Stop.d.ts +0 -7
  43. package/lib/types/Stop.js +0 -2
  44. package/lib/types/Subscriptions/ValidityTypes.d.ts +0 -6
  45. package/lib/types/Subscriptions/ValidityTypes.js +0 -10
  46. package/lib/types/TermsAndTariffs.js +0 -2
  47. package/lib/types/Tour.d.ts +0 -18
  48. package/lib/types/Tour.js +0 -2
  49. package/lib/types/Tours/Tour.d.ts +0 -18
  50. package/lib/types/Tours/Tour.js +0 -2
  51. package/lib/types/Tours.d.ts +0 -0
  52. package/lib/types/Tours.js +0 -1
  53. package/lib/types/Trip.d.ts +0 -9
  54. package/lib/types/Trip.js +0 -2
  55. package/lib/types/TripSearch.d.ts +0 -9
  56. package/lib/types/TripSearch.js +0 -2
  57. /package/lib/types/{BusMatrix.d.ts → journeys/BusMatrix.d.ts} +0 -0
  58. /package/lib/types/{BusMatrix.js → journeys/BusMatrix.js} +0 -0
  59. /package/lib/types/{Journeys → journeys}/JourneyCart.js +0 -0
  60. /package/lib/types/{Journeys → journeys}/JourneyInfo.js +0 -0
  61. /package/lib/types/{Journeys → journeys}/JourneySearch.js +0 -0
  62. /package/lib/types/{Journeys → journeys}/Stop.js +0 -0
  63. /package/lib/types/{Journeys → journeys}/Trip.js +0 -0
  64. /package/lib/types/{Subscriptions → subscriptions}/Subscrptions.d.ts +0 -0
  65. /package/lib/types/{Subscriptions → subscriptions}/Subscrptions.js +0 -0
@@ -0,0 +1,44 @@
1
+ import { MTSConfig, MTSEnvs } from "../config";
2
+ export declare abstract class Booking {
3
+ readonly sellerId?: number | undefined;
4
+ readonly config: MTSConfig;
5
+ cartStatus: Booking.CartStatus;
6
+ bookingDueDate: Date | undefined;
7
+ onCartExpiration: () => void;
8
+ /**
9
+ * This is the constructor of the Booking class.
10
+ * @param {string} env The environment in which the app is running. Can be "dev", "stag" or "prod"
11
+ * @param {string} sub_key The subscription key for using the APIs
12
+ * @param {() => void} onCartExpiration A callback function that will be called when the cart expires
13
+ * @param {string} [access_token=undefined] The access token for calling MTS APIs
14
+ * @param {number} [sellerId=undefined] The id of the seller. If not set, it will return the results for all sellers
15
+ */
16
+ constructor(env: MTSEnvs, sub_key: string, onCartExpiration: () => void, debug?: boolean, access_token?: string, sellerId?: number);
17
+ /**
18
+ * This method allows to renew the access token for calling MTS APIs
19
+ * @param {string} access_token The new access token
20
+ */
21
+ renewAccessToken(access_token: string): void;
22
+ getCartStatus(): Booking.CartStatus;
23
+ getCartExpirationTimeInMs(): Promise<number>;
24
+ }
25
+ export declare namespace Booking {
26
+ enum Currencies {
27
+ EUR = "EUR",
28
+ USD = "USD",
29
+ CHF = "CHF"
30
+ }
31
+ enum CartStatus {
32
+ EMPTY = "EMPTY",
33
+ CREATION = "CREATION",
34
+ PASSENGERS = "PASSENGERS",
35
+ SEATS = "SEATS",
36
+ EXTRAS = "EXTRAS",
37
+ PAYMENT = "PAYMENT"
38
+ }
39
+ enum BookingTypes {
40
+ MLP = "MLP",
41
+ SERVICE = "SERVICE",
42
+ MLP_SUBSCRIPTIONS = "MLP_SUBSCRIPTIONS"
43
+ }
44
+ }
@@ -0,0 +1,49 @@
1
+ import { MTSEnvs } from "../config";
2
+ import { PassengersDetails } from "../types/common/Person";
3
+ import { CreateJourneyCartRequest, JourneyCart } from "../types/journeys/JourneyCart";
4
+ import { JourneySearchRequest, JourneySearchResult } from "../types/journeys/JourneySearch";
5
+ import { Booking } from "./booking";
6
+ export declare class JourneyBooking extends Booking {
7
+ private cart?;
8
+ constructor(env: MTSEnvs, sub_key: string, onCartExpiration: () => void, debug?: boolean, access_token?: string, sellerId?: number);
9
+ getCart(): JourneyCart | undefined;
10
+ private fetchAndSetCart;
11
+ private createCartTimer;
12
+ fetchCart(cartId: number): Promise<JourneyCart>;
13
+ /**
14
+ * This method returns the possible departures for all journeys (MLP) sold by this seller.
15
+ * @returns {string[]} The list of possible departures
16
+ */
17
+ getJourneysDepartures(): Promise<string[]>;
18
+ /**
19
+ * This method returns the possible destination for the journeys sold by this seller that start at the selected departure.
20
+ * @param {string} departureStopName The departure stop name (as returned by {@link getJourneysDepartures})
21
+ * @returns {string[]} The list of possible destinations
22
+ */
23
+ getJourneysDestinations(departureStopName: string): Promise<string[]>;
24
+ /**
25
+ * This method returns the journeys that match the given parameters.
26
+ * Note that it will always return the journeys for the one-way trip.
27
+ * If you want to get the journeys for the round trip, you have to call this method twice (make sure to swap departureStopName and destinationStopName)
28
+ * @param {JourneySearch} params an object of type {@link JourneySearch} containing the parameters of the search
29
+ * @returns {JourneySearchResult[]} The returned journeys that match the given parameters
30
+ */
31
+ getJourneys(params: JourneySearchRequest): Promise<JourneySearchResult[]>;
32
+ createJourneyCart(tripCart: CreateJourneyCartRequest): Promise<JourneyCart>;
33
+ getBusMatrix(params: {
34
+ tripId: number;
35
+ departureStopId: number;
36
+ destinationStopId: number;
37
+ }): Promise<any>;
38
+ getSeatsStatus(params: {
39
+ tripId: number;
40
+ departureStopId: number;
41
+ destinationStopId: number;
42
+ }): Promise<any>;
43
+ movePassengers(params: {
44
+ tripId: number;
45
+ seatsIds: number[];
46
+ }): Promise<any>;
47
+ getPassengersDetails(): Promise<any>;
48
+ updatePassengersDetails(passengersDetails: PassengersDetails): Promise<any>;
49
+ }
@@ -0,0 +1,36 @@
1
+ import { MTSEnvs } from "../config";
2
+ import { Service, ServiceTrip } from "../types/services/Service";
3
+ import { CreateServiceCartRequest, ServiceCart } from "../types/services/ServiceCart";
4
+ import { Booking } from "./booking";
5
+ export declare class ServiceBooking extends Booking {
6
+ private cart?;
7
+ constructor(env: MTSEnvs, sub_key: string, onCartExpiration: () => void, debug?: boolean, access_token?: string, sellerId?: number);
8
+ getCart(): ServiceCart | undefined;
9
+ private fetchAndSetCart;
10
+ private createCartTimer;
11
+ fetchCart(cartId: number): Promise<ServiceCart>;
12
+ /**
13
+ * This method returns the list of cities in which the seller offers tours.
14
+ * If the sellerId is not set or it is 0, it will return the list of cities for all sellers.
15
+ * @returns {string[]} The list of possible cities
16
+ */
17
+ getServiceCities(): Promise<string[]>;
18
+ /**
19
+ * This method returns the tours sold by this seller in the given city.
20
+ * If the sellerId is not set or it is 0, it will return the tours in the given city for all sellers.
21
+ * @param {string} [cityName=undefined] The name of the selected city (as returned by {@link getTourCities})
22
+ * @param {Booking.Currencies} currency The currency in which the prices should be returned
23
+ * @returns {Tour[]} The returned tours
24
+ */
25
+ getServices(currency: Booking.Currencies, cityName?: string): Promise<Service[]>;
26
+ /**
27
+ * This method returns the tours available for the given date. This method can be used if the seller wants the user to book a specific date
28
+ * and/or a specific hour for the tour.
29
+ * You should call this method only if {@link Service.isDateOptional} or {@link Service.isDateRequired} is true for the selected tour.
30
+ * @param {number} serviceId The id of the selected tour (can be retrieved in the object {@link Service} returned by {@link getTours})
31
+ * @param {Date} date The date on which to get the tours
32
+ * @returns {ServiceTrip[]} The returned information about the tour (tripId and hour)
33
+ */
34
+ getServiceTrips(serviceId: number, date: Date): Promise<ServiceTrip[]>;
35
+ createServiceCart(serviceCart: CreateServiceCartRequest): Promise<ServiceCart>;
36
+ }
@@ -0,0 +1,50 @@
1
+ import { MTSEnvs } from "../config";
2
+ import { Cart } from "../types/common/Cart";
3
+ import { Subscription } from "../types/subscriptions/Subscrptions";
4
+ import { Booking } from "./booking";
5
+ export declare class SubscriptionBooking extends Booking {
6
+ private cart?;
7
+ constructor(env: MTSEnvs, sub_key: string, onCartExpiration: () => void, debug?: boolean, access_token?: string, sellerId?: number);
8
+ getCart(): Cart | undefined;
9
+ private fetchAndSetCart;
10
+ private createCartTimer;
11
+ fetchCart(cartId: number): Promise<Cart>;
12
+ /**
13
+ * This method returns the possible departures for all subscriptions sold by this seller.
14
+ * @returns {string[]} The list of possible departures
15
+ */
16
+ getSubscriptionsDepartures(): Promise<string[]>;
17
+ /**
18
+ * This method returns the possible destination for the subscriptions sold by this seller that start at the selected departure.
19
+ * @param {string} departureStopName The departure stop name (as returned by {@link getSubscriptionsDepartures})
20
+ * @returns {string[]} The list of possible destinations
21
+ */
22
+ getSubscrptionsDestinations(departureStopName: string): Promise<string[]>;
23
+ /**
24
+ * This method returns the possible validity types for the subscriptions sold by this seller between the selected departure and destination.
25
+ * The validity type is the duration of the subscription (1 week, 1 month, etc.). See {@link ValidityTypes} for more details.
26
+ * @param {string} departureStopName The departure stop name (as returned by {@link getSubscriptionsDepartures})
27
+ * @param {string} destinationStopName The destination stop name (as returned by {@link getSubscriptionsDstinations})
28
+ * @returns {ValidityTypes[]} The list of possible validity types
29
+ */
30
+ getSubscrptionsValidityTypes(departureStopName: string, destinationStopName: string): Promise<SubscriptionBooking.ValidityTypes[]>;
31
+ /**
32
+ * This method returns the subscriptions that match the given parameters.
33
+ * Note that it will always return the subscription for the one-way trip.
34
+ * If you want to get the subscription for the round trip, you have to call this method twice (make sure to swap departureStopName and destinationStopName)
35
+ * @param {string} departureStopName The departure stop name (as returned by {@link getSubscriptionsDepartures})
36
+ * @param {string} destinationStopName The destination stop name (as returned by {@link getSubscriptionsDstinations})
37
+ * @param {string} validityType The validity type (as returned by {@link getSubscriptionsValidityTypes})
38
+ * @returns {Array<Subscription>} The subscriptions that match the given parameters
39
+ */
40
+ getSubscrptions(departureStopName: string, destinationStopName: string, validityType: string): Promise<Subscription[]>;
41
+ getSubscrptionAvailabilities(departureStopName: string, destinationStopName: string, validityType: string): Promise<Subscription[]>;
42
+ }
43
+ export declare namespace SubscriptionBooking {
44
+ enum ValidityTypes {
45
+ WORKING_WEEK = "WORKING_WEEK",
46
+ WEEKLY = "WEEKLY",
47
+ MONTHLY = "MONTHLY",
48
+ YEARLY = "YEARLY"
49
+ }
50
+ }
package/lib/config.d.ts CHANGED
@@ -8,6 +8,7 @@ export type MTSConfig = {
8
8
  API_ENDPOINT: string;
9
9
  OCP_SUBSCRIPTION_KEY: string;
10
10
  ACCESS_TOKEN: string | undefined;
11
+ DEBUG: boolean;
11
12
  };
12
- export declare const setConfig: (env: MTSEnvs, sub_key: string, access_token?: string) => MTSConfig;
13
+ export declare const setConfig: (env: MTSEnvs, sub_key: string, debug: boolean, access_token?: string) => MTSConfig;
13
14
  export declare const getConfig: () => MTSConfig;
package/lib/index.d.ts CHANGED
@@ -1,140 +1,15 @@
1
- import { MTSEnvs } from "./config";
2
- import { Cart, TourCart, JourneyCart } from "./types/Cart";
3
- import { Details } from "./types/Details";
4
- import { Tour, TourTrip } from "./types/Tours/Tour";
5
- import { JourneySearch } from "./types/Journeys/JourneySearch";
6
- import { Subscription } from "./types/Subscriptions/Subscrptions";
7
- import { ValidityTypes } from "./types/Subscriptions/ValidityTypes";
8
- import { Journey } from "./types/Journeys/Journey";
9
- export declare class Booking {
10
- readonly sellerId?: number | undefined;
11
- private readonly config;
12
- private cart?;
13
- private cartStatus;
14
- private onCartExpiration;
15
- /**
16
- * This is the constructor of the Booking class.
17
- * @param {string} env The environment in which the app is running. Can be "dev", "stag" or "prod"
18
- * @param {string} sub_key The subscription key for using the APIs
19
- * @param {() => void} onCartExpiration A callback function that will be called when the cart expires
20
- * @param {string} [access_token=undefined] The access token for calling MTS APIs
21
- * @param {number} [sellerId=undefined] The id of the seller. If not set, it will return the results for all sellers
22
- */
23
- constructor(env: MTSEnvs, sub_key: string, onCartExpiration: () => void, access_token?: string, sellerId?: number);
24
- /**
25
- * This method allows to renew the access token for calling MTS APIs
26
- * @param {string} access_token The new access token
27
- */
28
- renewAccessToken(access_token: string): void;
29
- getCartStatus(): Booking.CartStatus;
30
- getCart(): Cart | undefined;
31
- private fetchAndSetCart;
32
- private createCartTimer;
33
- getCartExpirationTimeInMs(): Promise<number>;
34
- /**
35
- * This method returns the list of cities in which the seller offers tours.
36
- * If the sellerId is not set or it is 0, it will return the list of cities for all sellers.
37
- * @returns {string[]} The list of possible cities
38
- */
39
- getTourCities(): Promise<string[]>;
40
- /**
41
- * This method returns the tours sold by this seller in the given city.
42
- * If the sellerId is not set or it is 0, it will return the tours in the given city for all sellers.
43
- * @param {string} [cityName=undefined] The name of the selected city (as returned by {@link getTourCities})
44
- * @param {Booking.Currencies} currency The currency in which the prices should be returned
45
- * @returns {Tour[]} The returned tours
46
- */
47
- getTours(currency: Booking.Currencies, cityName?: string): Promise<Tour[]>;
48
- /**
49
- * This method returns the tours available for the given date. This method can be used if the seller wants the user to book a specific date
50
- * and/or a specific hour for the tour.
51
- * You should call this method only if {@link Tour.isDateOptional} or {@link Tour.isDateRequired} is true for the selected tour.
52
- * @param {number} tourId The id of the selected tour (can be retrieved in the object {@link Tour} returned by {@link getTours})
53
- * @param {Date} date The date on which to get the tours
54
- * @returns {TourTrip[]} The returned information about the tour (tripId and hour)
55
- */
56
- getToursTrips(tourId: number, date: Date): Promise<TourTrip[]>;
57
- createTourCart(tourCart: TourCart): Promise<Cart>;
58
- fetchCart(cartId: number): Promise<Cart>;
59
- /**
60
- * This method returns the possible departures for all journeys (MLP) sold by this seller.
61
- * @returns {string[]} The list of possible departures
62
- */
63
- getJourneysDepartures(): Promise<string[]>;
64
- /**
65
- * This method returns the possible destination for the journeys sold by this seller that start at the selected departure.
66
- * @param {string} departureStopName The departure stop name (as returned by {@link getJourneysDepartures})
67
- * @returns {string[]} The list of possible destinations
68
- */
69
- getJourneysDestinations(departureStopName: string): Promise<string[]>;
70
- /**
71
- * This method returns the journeys that match the given parameters.
72
- * Note that it will always return the journeys for the one-way trip.
73
- * If you want to get the journeys for the round trip, you have to call this method twice (make sure to swap departureStopName and destinationStopName)
74
- * @param {JourneySearch} params an object of type {@link JourneySearch} containing the parameters of the search
75
- * @returns {Journey[]} The returned journeys that match the given parameters
76
- */
77
- getJourneys(params: JourneySearch): Promise<Journey[]>;
78
- createJourneyCart(tripCart: JourneyCart): Promise<Cart>;
79
- getBusMatrix(params: {
80
- tripId: number;
81
- departureStopId: number;
82
- destinationStopId: number;
83
- }): Promise<any>;
84
- getSeatsStatus(params: {
85
- tripId: number;
86
- departureStopId: number;
87
- destinationStopId: number;
88
- }): Promise<any>;
89
- movePassengers(params: {
90
- tripId: number;
91
- seatsIds: number[];
92
- }): Promise<any>;
93
- /**
94
- * This method returns the possible departures for all subscriptions sold by this seller.
95
- * @returns {string[]} The list of possible departures
96
- */
97
- getSubscriptionsDepartures(): Promise<string[]>;
98
- /**
99
- * This method returns the possible destination for the subscriptions sold by this seller that start at the selected departure.
100
- * @param {string} departureStopName The departure stop name (as returned by {@link getSubscriptionsDepartures})
101
- * @returns {string[]} The list of possible destinations
102
- */
103
- getSubscrptionsDestinations(departureStopName: string): Promise<string[]>;
104
- /**
105
- * This method returns the possible validity types for the subscriptions sold by this seller between the selected departure and destination.
106
- * The validity type is the duration of the subscription (1 week, 1 month, etc.). See {@link ValidityTypes} for more details.
107
- * @param {string} departureStopName The departure stop name (as returned by {@link getSubscriptionsDepartures})
108
- * @param {string} destinationStopName The destination stop name (as returned by {@link getSubscriptionsDstinations})
109
- * @returns {ValidityTypes[]} The list of possible validity types
110
- */
111
- getSubscrptionsValidityTypes(departureStopName: string, destinationStopName: string): Promise<ValidityTypes[]>;
112
- /**
113
- * This method returns the subscriptions that match the given parameters.
114
- * Note that it will always return the subscription for the one-way trip.
115
- * If you want to get the subscription for the round trip, you have to call this method twice (make sure to swap departureStopName and destinationStopName)
116
- * @param {string} departureStopName The departure stop name (as returned by {@link getSubscriptionsDepartures})
117
- * @param {string} destinationStopName The destination stop name (as returned by {@link getSubscriptionsDstinations})
118
- * @param {string} validityType The validity type (as returned by {@link getSubscriptionsValidityTypes})
119
- * @returns {Array<Subscription>} The subscriptions that match the given parameters
120
- */
121
- getSubscrptions(departureStopName: string, destinationStopName: string, validityType: string): Promise<Subscription[]>;
122
- getSubscrptionAvailabilities(departureStopName: string, destinationStopName: string, validityType: string): Promise<Subscription[]>;
123
- getPassengersDetails(): Promise<any>;
124
- updatePassengersDetails(passengersDetails: Details): Promise<any>;
125
- }
126
- export declare namespace Booking {
127
- enum Currencies {
128
- EUR = "EUR",
129
- USD = "USD",
130
- CHF = "CHF"
131
- }
132
- enum CartStatus {
133
- EMPTY = "EMPTY",
134
- CREATION = "CREATION",
135
- PASSENGERS = "PASSENGERS",
136
- SEATS = "SEATS",
137
- EXTRAS = "EXTRAS",
138
- PAYMENT = "PAYMENT"
139
- }
140
- }
1
+ export { JourneyBooking } from "./booking/journeyBooking";
2
+ export { ServiceBooking } from "./booking/serviceBooking";
3
+ export { SubscriptionBooking } from "./booking/subscriptionBooking";
4
+ export { Person, PassengersDetails, DEFAULT_PERSON } from "./types/common/Person";
5
+ export { TariffMatrix, TariffSummary, TariffType, TermsType } from "./types/common/Tariffs";
6
+ export { JourneyCart, JourneyBookingType, CreateJourneyCartRequest, JourneyBookingInfo } from "./types/journeys/JourneyCart";
7
+ export { JourneyInfo } from "./types/journeys/JourneyInfo";
8
+ export { JourneySearchRequest, JourneySearchResult, DEFAULT_JOURNEY_SEARCH } from "./types/journeys/JourneySearch";
9
+ export { Stop } from "./types/journeys/Stop";
10
+ export { Trip } from "./types/journeys/Trip";
11
+ export { Line } from "./types/services/Line";
12
+ export { Service, ServiceTrip } from "./types/services/Service";
13
+ export { ServiceCart, ServiceBookingType, CreateServiceCartRequest } from "./types/services/ServiceCart";
14
+ export { ServiceInfo } from "./types/services/ServiceInfo";
15
+ export { Subscription } from "./types/subscriptions/Subscrptions";
@@ -0,0 +1,47 @@
1
+ import { Booking } from "../../booking/booking";
2
+ import { Person } from "./Person";
3
+ /**
4
+ * @description Cart is the object returned by the API when a cart is created.
5
+ * Note that depending on the type of booking, this type will be extended with different fields:
6
+ * - TourCart: {@link TourCart.ts}
7
+ * - JourneyCart: {@link JourneyCart.ts}
8
+ * - SubscriptionCart: {@link SubscriptionCart.ts}
9
+ * @property {number} id The id of the cart
10
+ * @property {string} cartCode The code of the cart
11
+ * @property {Booking.CartStatus} status The status of the cart. See {@link Booking.CartStatus}
12
+ * @property {Booking.CartStatus} nextStatus The next status of the cart. See {@link Booking.CartStatus}
13
+ * @property {Booking.Currencies} currency The currency of the cart. See {@link Booking.Currencies}
14
+ */
15
+ export type Cart = {
16
+ id: number;
17
+ cartCode: string;
18
+ status: Booking.CartStatus;
19
+ nextStatus: Booking.CartStatus;
20
+ currency: Booking.Currencies;
21
+ bookingDueDate: string;
22
+ buyer: Person;
23
+ reductions: {
24
+ tripId: number;
25
+ tripName: string;
26
+ value: number;
27
+ isPercentage: boolean;
28
+ voucherCode?: string;
29
+ }[];
30
+ isSeatsSelectionAllowed: boolean;
31
+ sellingMethod: string;
32
+ totalValue: number;
33
+ totalResellerFee?: number;
34
+ totalCreditFromChange: number;
35
+ totalAmountToPay: number;
36
+ extas: {
37
+ id: number;
38
+ resourceId: number;
39
+ name: string;
40
+ description: string;
41
+ notes: string;
42
+ tariff: {
43
+ tariffId: number;
44
+ tariffName: string;
45
+ };
46
+ }[];
47
+ };
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @description Represents a person, that can be a passenger or the buyer.
3
+ *
4
+ * @property {number} id - The unique identifier for the person.
5
+ * @property {string} name - The name of the person.
6
+ * @property {string} lastName - The last name of the person.
7
+ * @property {string} email - The email of the person.
8
+ * @property {string} phoneNumber - The phone number of the person.
9
+ */
10
+ export type Person = {
11
+ id: number;
12
+ name: string;
13
+ lastName: string;
14
+ email: string;
15
+ phoneNumber: string;
16
+ };
17
+ export declare const DEFAULT_PERSON: Person;
18
+ /**
19
+ * @description Represents the passengers details.
20
+ *
21
+ * @property {Person[]} passengers - An array of {@link Person} extended by the map `tripsToTariffs` objects representing the passengers.
22
+ * @property {Person} buyer - The {@link Person} object representing the buyer.
23
+ */
24
+ export type PassengersDetails = {
25
+ passengers: Person[] & {
26
+ tripsToTariffs: {
27
+ [tripId: number]: number;
28
+ };
29
+ };
30
+ buyer: Person;
31
+ };
@@ -19,3 +19,8 @@ export type TermsType = {
19
19
  validationRulesString: string;
20
20
  bookingProcessDescription: string;
21
21
  };
22
+ export type TariffSummary = {
23
+ quantity: number;
24
+ label: string;
25
+ value: number;
26
+ };
@@ -0,0 +1,55 @@
1
+ import { Booking } from "../../booking/booking";
2
+ import { Cart } from "../common/Cart";
3
+ import { TariffMatrix, TariffSummary } from "../common/Tariffs";
4
+ import { Stop } from "./Stop";
5
+ /**
6
+ * @description Object containing information about the selected journey, to be used when booking the journey.
7
+ *
8
+ * @property {number} tripId - The unique identifier for the trip.
9
+ * @property {number} departureStopId - The unique identifier for the departure stop.
10
+ * @property {number} destinationStopId - The unique identifier for the destination stop.
11
+ * @property {TariffMatrix} tariffsMatrix - The tariff matrix for pricing the outbound journey.
12
+ */
13
+ export type JourneyBookingInfo = {
14
+ tripId: number;
15
+ departureStopId: number;
16
+ destinationStopId: number;
17
+ tariffsMatrix: TariffMatrix;
18
+ };
19
+ /**
20
+ * @description This is the object to be passed to `JourneyBooking.createJourneyCart`, containing information about the selected service.
21
+ *
22
+ * @property {number|undefined} [cartId=0] - The unique identifier for the cart (optional).
23
+ * @property {Booking.Currencies} currency - The currency in which the journey is priced.
24
+ * @property {JourneyBookingInfo[]} outboundJourney - Information about outbound journeys.
25
+ * @property {JourneyBookingInfo[]|null} returnJourney - Information about return journeys (optional, can be null).
26
+ */
27
+ export type CreateJourneyCartRequest = {
28
+ cartId?: number;
29
+ currency: Booking.Currencies;
30
+ outboundJourney: JourneyBookingInfo[];
31
+ returnJourney: JourneyBookingInfo[] | null;
32
+ };
33
+ /**
34
+ * @description Represents a `JourneyCart`, which extends the {@link Cart} type by including additional
35
+ * information about the bookings
36
+ *
37
+ * @property {JourneyBookingType[]} bookings - An array of {@link JourneyBookingType} objects representing the bookings associated
38
+ * with this journey cart.
39
+ */
40
+ export type JourneyCart = Cart & {
41
+ bookings: JourneyBookingType[];
42
+ };
43
+ /**
44
+ * @description Represents a `JourneyBooking`, which contains information about a journey booking.
45
+ *
46
+ * @property {Booking.BookingTypes} type - The type of booking.
47
+ * @property {TariffSummary[]} summary - An array of {@link TariffSummary} objects representing the tariff summary
48
+ * associated with this journey booking.
49
+ * @property {Stop[]} info - An array of {@link Stop} objects representing the stops associated with this journey booking.
50
+ */
51
+ export type JourneyBookingType = {
52
+ type: Booking.BookingTypes;
53
+ summary: TariffSummary[];
54
+ info: Stop[];
55
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @description Represents information about a journey.
3
+ *
4
+ * @property {string} sellerName - The name of the seller offering the journey.
5
+ * @property {string} minimumTotalPrice - The minimum total price for booking the journey, meaning the price if all passenger choose the cheapest tariff.
6
+ * @property {number} remainingSeats - The number of remaining seats for the journey.
7
+ * @property {number} totalNumberOfSeats - The total number of seats for the journey (including booked seats).
8
+ * @property {string} bookingProcessMessage - Optional message to be displayed to the user when booking this journey.
9
+ * @property {boolean} isBookable - Indicates whether the journey is bookable (true) or not (false).
10
+ */
11
+ export type JourneyInfo = {
12
+ sellerName: string;
13
+ minimumTotalPrice: string;
14
+ remainingSeats: number;
15
+ totalNumberOfSeats: number;
16
+ bookingProcessMessage: string;
17
+ isBookable: boolean;
18
+ };
@@ -0,0 +1,19 @@
1
+ import { Booking } from "../../booking/booking";
2
+ import { JourneyInfo } from "./JourneyInfo";
3
+ import { Stop } from "./Stop";
4
+ import { Trip } from "./Trip";
5
+ export type JourneySearchRequest = {
6
+ departureStopName: string | undefined;
7
+ destinationStopName: string | undefined;
8
+ passengersNumber: number;
9
+ date: string;
10
+ roundTripDate: string | null;
11
+ currency: Booking.Currencies;
12
+ isRoundtrip: boolean;
13
+ };
14
+ export declare const DEFAULT_JOURNEY_SEARCH: JourneySearchRequest;
15
+ export type JourneySearchResult = {
16
+ stops: Stop[];
17
+ info: JourneyInfo;
18
+ trips: Trip[];
19
+ };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @description Represents a stop in a journey.
3
+ *
4
+ * @property {number} id - The unique identifier for the stop.
5
+ * @property {Date} departureTime - The time when the journey departs from this stop.
6
+ * @property {Date} destinationTime - The time when the journey arrives at this stop.
7
+ * @property {string} name - The name of the stop.
8
+ * @property {string} address - The address of the stop.
9
+ */
10
+ export type Stop = {
11
+ id: number;
12
+ departureTime: Date;
13
+ destinationTime: Date;
14
+ name: string;
15
+ address: string;
16
+ };
@@ -1,4 +1,4 @@
1
- import { TariffMatrix, TariffType, TermsType } from "../TermsAndTariffs";
1
+ import { TariffMatrix, TariffType, TermsType } from "../common/Tariffs";
2
2
  export type Trip = {
3
3
  id: number;
4
4
  date: Date;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @description Represents a line on which the service is sold.
3
+ *
4
+ * @property {number} id - The unique identifier for the line.
5
+ * @property {string} name - The name of the line.
6
+ * @property {string} linkavelDescription - A description of the line, to be used in {@link https://linkavel.com/} or in other ecommerses.
7
+ * @property {string} backofficeNotes - Additional notes or information about the line for internal use.
8
+ */
9
+ export type Line = {
10
+ id: number;
11
+ name: string;
12
+ linkavelDescription: string;
13
+ backofficeNotes: string;
14
+ };
@@ -0,0 +1,33 @@
1
+ import { TariffMatrix, TariffType, TermsType } from "../common/Tariffs";
2
+ import { Line } from "./Line";
3
+ import { ServiceInfo } from "./ServiceInfo";
4
+ /**
5
+ * @description Represents a service offering, including information about the service, tariffs,
6
+ * terms, and other details.
7
+ *
8
+ * @property {number} id - The unique identifier for the service.
9
+ * @property {Line} line - Information about the line or route associated with the service.
10
+ * @property {ServiceInfo} info - Information about the service itself.
11
+ * @property {TariffMatrix} tariffsMatrix - The tariff matrix for pricing.
12
+ * @property {TariffType[]} tariffTypes - An array of tariff types available for the service.
13
+ * @property {TermsType[]} termsTypes - An array of terms types related to the service.
14
+ * @property {boolean} isDateOptional - Indicates whether a date can be optionally specified for this service.
15
+ * @property {boolean} isDateRequired - Indicates whether specifying a date is required for booking.
16
+ * @property {boolean} isTripMandatory - Indicates whether the selection of the trip in the selected date is mandatory.
17
+ */
18
+ export type Service = {
19
+ id: number;
20
+ line: Line;
21
+ info: ServiceInfo;
22
+ tariffsMatrix: TariffMatrix;
23
+ tariffTypes: TariffType[];
24
+ termsTypes: TermsType[];
25
+ isDateOptional: boolean;
26
+ isDateRequired: boolean;
27
+ isTripMandatory: boolean;
28
+ };
29
+ export type ServiceTrip = {
30
+ tripId?: number;
31
+ date: Date;
32
+ name: string;
33
+ };
@@ -0,0 +1,46 @@
1
+ import { Booking } from "../../booking/booking";
2
+ import { Cart } from "../common/Cart";
3
+ import { TariffMatrix, TariffSummary } from "../common/Tariffs";
4
+ import { ServiceTrip } from "./Service";
5
+ /**
6
+ * @description This is the object to be passed to `ServiceBooking.createServiceCart`, containing information about the selected service.
7
+ *
8
+ * @property {Booking.Currencies} currency - The currency in which the service is priced.
9
+ * @property {Object} service - Information about the selected service.
10
+ * @property {number} service.serviceId - The unique identifier for the service.
11
+ * @property {TariffMatrix} service.tariffsMatrix - The tariff matrix for pricing the service.
12
+ * @property {Date|undefined} [service.date] - The date for the service (optional).
13
+ * @property {number|undefined} [service.tripId] - The unique identifier for the trip (optional).
14
+ */
15
+ export type CreateServiceCartRequest = {
16
+ currency: Booking.Currencies;
17
+ service: {
18
+ serviceId: number;
19
+ tariffsMatrix: TariffMatrix;
20
+ date?: Date;
21
+ tripId?: number;
22
+ };
23
+ };
24
+ /**
25
+ * @description Represents a `JourneyCart`, which extends the {@link Cart} type by including additional
26
+ * information about the bookings
27
+ *
28
+ * @property {ServiceBooking[]} bookings - An array of {@link ServiceBookingType} objects representing the bookings associated
29
+ * with this journey cart.
30
+ */
31
+ export type ServiceCart = Cart & {
32
+ bookings: ServiceBookingType[];
33
+ };
34
+ /**
35
+ * @description Represents a `JourneyBooking`, which contains information about a journey booking.
36
+ *
37
+ * @property {Booking.BookingTypes} type - The type of booking.
38
+ * @property {TariffSummary[]} summary - An array of {@link TariffSummary} objects representing the tariff summary
39
+ * associated with this journey booking.
40
+ * @property {ServiceTrip} info - An array of {@link ServiceTrip} objects representing the stops associated with this journey booking.
41
+ */
42
+ export type ServiceBookingType = {
43
+ type: Booking.BookingTypes;
44
+ summary: TariffSummary[];
45
+ info: ServiceTrip;
46
+ };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @description Represents information about a service.
3
+ *
4
+ * @property {string} sellerName - The name of the seller offering the service.
5
+ * @property {string} minimumTotalPrice - The minimum total price for booking the service, meaning the price if all passenger choose the cheapest tariff.
6
+ * @property {string} bookingProcessMessage - Optional message to be displayed to the user when booking this service.
7
+ * @property {boolean} isBookable - Indicates whether the service is bookable (true) or not (false).
8
+ */
9
+ export type ServiceInfo = {
10
+ sellerName: string;
11
+ minimumTotalPrice: string;
12
+ bookingProcessMessage: string;
13
+ isBookable: boolean;
14
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mts-booking-library",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Library for use MyTicketSolution Booking API",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
File without changes
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,79 +0,0 @@
1
- import { Booking } from "..";
2
- import { Person } from "./Person";
3
- import { TariffMatrix } from "./TermsAndTariffs";
4
- export type Cart = {
5
- id: number;
6
- cartCode: string;
7
- status: Booking.CartStatus;
8
- nextStatus: Booking.CartStatus;
9
- currency: string;
10
- bookingDueDate: string;
11
- bookings: {
12
- type: string;
13
- summary: {
14
- quantity: number;
15
- label: string;
16
- value: number;
17
- }[];
18
- }[];
19
- info: {
20
- stops: {
21
- id: number;
22
- departureTime: Date;
23
- destinationTime: Date;
24
- name: string;
25
- address: string;
26
- }[];
27
- };
28
- buyer: Person;
29
- reductions: {
30
- tripId: number;
31
- tripName: string;
32
- value: number;
33
- isPercentage: boolean;
34
- voucherCode?: string;
35
- }[];
36
- isSeatsSelectionAllowed: boolean;
37
- sellingMethod: string;
38
- totalValue: number;
39
- totalResellerFee?: number;
40
- totalCreditFromChange: number;
41
- totalAmountToPay: number;
42
- extas: {
43
- id: number;
44
- resourceId: number;
45
- name: string;
46
- description: string;
47
- notes: string;
48
- tariff: {
49
- tariffId: number;
50
- tariffName: string;
51
- };
52
- }[];
53
- };
54
- export type TourCart = {
55
- cartId?: number;
56
- currency: Booking.Currencies;
57
- tour: {
58
- tourId: number;
59
- date?: Date;
60
- tripId?: number;
61
- tariffsMatrix: TariffMatrix;
62
- };
63
- };
64
- export type JourneyCart = {
65
- cartId?: number;
66
- currency: Booking.Currencies;
67
- outboundJourney: {
68
- departureStopId: number;
69
- destinationStopId: number;
70
- tripId: number;
71
- tariffsMatrix: TariffMatrix;
72
- }[];
73
- returnJourney: {
74
- tripId: number;
75
- departureStopId: number;
76
- destinationStopId: number;
77
- tariffsMatrix: TariffMatrix;
78
- }[] | null;
79
- };
package/lib/types/Cart.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,9 +0,0 @@
1
- import { Person } from "./Person";
2
- export type Details = {
3
- passengers: Person[] & {
4
- tripsToTariffs: {
5
- [tripId: number]: number;
6
- };
7
- };
8
- buyer: Person;
9
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,8 +0,0 @@
1
- export type Info = {
2
- sellerName: string;
3
- minimumTotalPrice: string;
4
- remainingSeats?: number;
5
- totalNumberOfSeats?: number;
6
- bookingProcessMessage: string;
7
- isBookable: boolean;
8
- };
package/lib/types/Info.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,8 +0,0 @@
1
- import { Info } from "./Info";
2
- import { Stop } from "./Stop";
3
- import { Trip } from "./Trip";
4
- export type Journey = {
5
- stops: Stop[];
6
- info: Info;
7
- trips: Trip[];
8
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,9 +0,0 @@
1
- import { Booking } from "..";
2
- export type JourneySearch = {
3
- departureStopName: string;
4
- destinationStopName: string;
5
- passengersNumber: number;
6
- date: Date;
7
- currency: Booking.Currencies;
8
- isRoundtrip: boolean;
9
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
File without changes
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,8 +0,0 @@
1
- import { Stop } from "./Stop";
2
- import { Info } from "../Info";
3
- import { Trip } from "./Trip";
4
- export type Journey = {
5
- stops: Stop[];
6
- info: Info;
7
- trips: Trip[];
8
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,11 +0,0 @@
1
- import { Booking } from "../..";
2
- export type JourneySearch = {
3
- departureStopName: string | undefined;
4
- destinationStopName: string | undefined;
5
- passengersNumber: number;
6
- date: Date;
7
- roundTripDate: Date | null;
8
- currency: Booking.Currencies;
9
- isRoundtrip: boolean;
10
- };
11
- export declare const DefaultJourneySearch: JourneySearch;
@@ -1,7 +0,0 @@
1
- export type Stop = {
2
- id: number;
3
- departureTime: Date;
4
- destinationTime: Date;
5
- name: string;
6
- address: string;
7
- };
@@ -1,6 +0,0 @@
1
- export type Line = {
2
- id: number;
3
- name: string;
4
- linkavelDescription: string;
5
- backofficeNotes: string;
6
- };
package/lib/types/Line.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,7 +0,0 @@
1
- export type Person = {
2
- id: number;
3
- name: string;
4
- lastName: string;
5
- email: string;
6
- phoneNumber: string;
7
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,7 +0,0 @@
1
- export type Stop = {
2
- id: number;
3
- departureTime: Date;
4
- destinationTime: Date;
5
- name: string;
6
- address: string;
7
- };
package/lib/types/Stop.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +0,0 @@
1
- export declare enum ValidityTypes {
2
- WORKING_WEEK = "WORKING_WEEK",
3
- WEEKLY = "WEEKLY",
4
- MONTHLY = "MONTHLY",
5
- YEARLY = "YEARLY"
6
- }
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ValidityTypes = void 0;
4
- var ValidityTypes;
5
- (function (ValidityTypes) {
6
- ValidityTypes["WORKING_WEEK"] = "WORKING_WEEK";
7
- ValidityTypes["WEEKLY"] = "WEEKLY";
8
- ValidityTypes["MONTHLY"] = "MONTHLY";
9
- ValidityTypes["YEARLY"] = "YEARLY";
10
- })(ValidityTypes || (exports.ValidityTypes = ValidityTypes = {}));
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,18 +0,0 @@
1
- import { Info } from "./Info";
2
- import { Line } from "./Line";
3
- import { TariffMatrix, TariffType, TermsType } from "./TermsAndTariffs";
4
- export type Tour = {
5
- id: number;
6
- line: Line;
7
- info: Info;
8
- tariffsMatrix: TariffMatrix;
9
- tariffTypes: TariffType[];
10
- termsTypes: TermsType[];
11
- isDateOptional: boolean;
12
- isDateRequired: boolean;
13
- isTripMandatory: boolean;
14
- };
15
- export type TourTrip = {
16
- tripId: number;
17
- hour: Date;
18
- };
package/lib/types/Tour.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,18 +0,0 @@
1
- import { Info } from "../Info";
2
- import { Line } from "../Line";
3
- import { TariffMatrix, TariffType, TermsType } from "../TermsAndTariffs";
4
- export type Tour = {
5
- id: number;
6
- line: Line;
7
- info: Info;
8
- tariffsMatrix: TariffMatrix;
9
- tariffTypes: TariffType[];
10
- termsTypes: TermsType[];
11
- isDateOptional: boolean;
12
- isDateRequired: boolean;
13
- isTripMandatory: boolean;
14
- };
15
- export type TourTrip = {
16
- tripId: number;
17
- hour: Date;
18
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
File without changes
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,9 +0,0 @@
1
- import { TariffMatrix, TariffType, TermsType } from "./TermsAndTariffs";
2
- export type Trip = {
3
- id: number;
4
- departureStopName: string;
5
- destinationStopName: string;
6
- tariffsMatrix: TariffMatrix;
7
- tariffTypes: TariffType[];
8
- termsTypes: TermsType[];
9
- };
package/lib/types/Trip.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,9 +0,0 @@
1
- import { Booking } from "..";
2
- export type TripSearch = {
3
- departureStopName: string;
4
- destinationStopName: string;
5
- passengersNumber: number;
6
- date: Date;
7
- currency: Booking.Currencies;
8
- isRoundtrip: boolean;
9
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
File without changes
File without changes
File without changes
File without changes