mts-booking-library 1.2.32 → 1.3.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.
- package/lib/booking/booking.d.ts +2 -1
- package/lib/booking/booking.js +33 -44
- package/lib/booking/journeyBooking.d.ts +46 -0
- package/lib/booking/journeyBooking.js +77 -88
- package/lib/booking/serviceBooking.d.ts +46 -0
- package/lib/booking/serviceBooking.js +74 -85
- package/lib/booking/subscriptionBooking.d.ts +46 -0
- package/lib/booking/subscriptionBooking.js +75 -86
- package/lib/booking/tplBooking.d.ts +168 -0
- package/lib/booking/tplBooking.js +705 -0
- package/lib/config.js +5 -5
- package/lib/index.d.ts +4 -0
- package/lib/index.js +3 -1
- package/lib/mtsStorage.d.ts +44 -0
- package/lib/mtsStorage.js +48 -0
- package/lib/types/common/City.d.ts +17 -0
- package/lib/types/common/City.js +2 -0
- package/lib/types/common/Tariffs.d.ts +9 -3
- package/lib/types/journeys/JourneyInfo.d.ts +3 -1
- package/lib/types/tpl/GetTariffsResponse.d.ts +12 -0
- package/lib/types/tpl/GetTariffsResponse.js +2 -0
- package/lib/types/tpl/SuperArea.d.ts +13 -0
- package/lib/types/tpl/SuperArea.js +2 -0
- package/lib/types/tpl/TplCart.d.ts +41 -0
- package/lib/types/tpl/TplCart.js +2 -0
- package/lib/utils/apiCall.js +26 -26
- package/package.json +8 -6
package/lib/config.js
CHANGED
@@ -10,7 +10,7 @@ var MTSEnvs;
|
|
10
10
|
})(MTSEnvs || (exports.MTSEnvs = MTSEnvs = {}));
|
11
11
|
var config = {
|
12
12
|
ENV: MTSEnvs.PROD,
|
13
|
-
API_ENDPOINT: "https://myticketsolutionapim.azure-api.net/api",
|
13
|
+
API_ENDPOINT: "https://prod-myticketsolutionapim.azure-api.net/api",
|
14
14
|
OCP_SUBSCRIPTION_KEY: "",
|
15
15
|
ACCESS_TOKEN: undefined,
|
16
16
|
DEBUG: false
|
@@ -21,18 +21,18 @@ var setConfig = function (env, sub_key, debug, access_token) {
|
|
21
21
|
switch (config.ENV) {
|
22
22
|
case MTSEnvs.TEST:
|
23
23
|
case MTSEnvs.DEV:
|
24
|
-
config.API_ENDPOINT = "https://myticketsolutionapim.azure-api.net/api
|
24
|
+
config.API_ENDPOINT = "https://dev-myticketsolutionapim.azure-api.net/api";
|
25
25
|
break;
|
26
26
|
case MTSEnvs.STAGING:
|
27
|
-
config.API_ENDPOINT = "https://myticketsolutionapim.azure-api.net/api
|
27
|
+
config.API_ENDPOINT = "https://stag-myticketsolutionapim.azure-api.net/api";
|
28
28
|
break;
|
29
29
|
case MTSEnvs.PROD:
|
30
|
-
config.API_ENDPOINT = "https://myticketsolutionapim.azure-api.net/api";
|
30
|
+
config.API_ENDPOINT = "https://prod-myticketsolutionapim.azure-api.net/api";
|
31
31
|
break;
|
32
32
|
default:
|
33
33
|
throw new Error("Invalid environment");
|
34
34
|
}
|
35
|
-
// Set
|
35
|
+
// Set OCP and access token
|
36
36
|
config.OCP_SUBSCRIPTION_KEY = sub_key;
|
37
37
|
config.ACCESS_TOKEN = access_token;
|
38
38
|
// Set debug
|
package/lib/index.d.ts
CHANGED
@@ -2,6 +2,7 @@ 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 { TplBooking } from "./booking/tplBooking";
|
5
6
|
export { Person, DEFAULT_PERSON, initializePerson } from "./types/common/Person";
|
6
7
|
export { GetBuyerPassengersDetailsResponse, GetPassenger, BuyerDataStatus } from "./types/common/Person";
|
7
8
|
export { EditPassengerRequestType, EditPassengersDetailsRequest } from "./types/common/Person";
|
@@ -19,6 +20,9 @@ export { Line } from "./types/services/Line";
|
|
19
20
|
export { Service, ServiceTrip } from "./types/services/Service";
|
20
21
|
export { ServiceCart, ServiceBookingType, CreateServiceCartRequest } from "./types/services/ServiceCart";
|
21
22
|
export { ServiceInfo } from "./types/services/ServiceInfo";
|
23
|
+
export { GetTariffsResponse } from "./types/tpl/GetTariffsResponse";
|
24
|
+
export { SuperArea } from "./types/tpl/SuperArea";
|
25
|
+
export { TplCart, TplBookingType, TplBookingInfo } from "./types/tpl/TplCart";
|
22
26
|
export { Subscription } from "./types/subscriptions/Subscriptions";
|
23
27
|
export { GetSubscriptionAvailabilityRequest, GetSubscriptionAvailabilityResponse, SubscriptionCalendarDayPeriodInfo } from "./types/subscriptions/SubscriptionAvailabilities";
|
24
28
|
export { SubscriptionCart, SubscriptionBookingType, CreateSubscriptionCartRequest, SubscriptionPeriod } from "./types/subscriptions/SubscriptionCart";
|
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.objectIsMTSErrorResponse = exports.PaymentMethods = exports.GatewayTypes = exports.BuyerDataStatus = 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.TplBooking = 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; } });
|
@@ -10,6 +10,8 @@ var serviceBooking_1 = require("./booking/serviceBooking");
|
|
10
10
|
Object.defineProperty(exports, "ServiceBooking", { enumerable: true, get: function () { return serviceBooking_1.ServiceBooking; } });
|
11
11
|
var subscriptionBooking_1 = require("./booking/subscriptionBooking");
|
12
12
|
Object.defineProperty(exports, "SubscriptionBooking", { enumerable: true, get: function () { return subscriptionBooking_1.SubscriptionBooking; } });
|
13
|
+
var tplBooking_1 = require("./booking/tplBooking");
|
14
|
+
Object.defineProperty(exports, "TplBooking", { enumerable: true, get: function () { return tplBooking_1.TplBooking; } });
|
13
15
|
//#endregion
|
14
16
|
//#region Export common types
|
15
17
|
// @note: Cart is not exported because it is extended by other types
|
@@ -0,0 +1,44 @@
|
|
1
|
+
type MtsBookingState = {
|
2
|
+
cartId: number | undefined;
|
3
|
+
};
|
4
|
+
type MtsBookingAction = {
|
5
|
+
updateCartId: (cartId: MtsBookingState["cartId"]) => void;
|
6
|
+
resetState: () => void;
|
7
|
+
};
|
8
|
+
export declare const useMtsBookingLocalState: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<MtsBookingState & MtsBookingAction>, "persist"> & {
|
9
|
+
persist: {
|
10
|
+
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<MtsBookingState & MtsBookingAction, MtsBookingState & MtsBookingAction>>) => void;
|
11
|
+
clearStorage: () => void;
|
12
|
+
rehydrate: () => void | Promise<void>;
|
13
|
+
hasHydrated: () => boolean;
|
14
|
+
onHydrate: (fn: (state: MtsBookingState & MtsBookingAction) => void) => () => void;
|
15
|
+
onFinishHydration: (fn: (state: MtsBookingState & MtsBookingAction) => void) => () => void;
|
16
|
+
getOptions: () => Partial<import("zustand/middleware").PersistOptions<MtsBookingState & MtsBookingAction, MtsBookingState & MtsBookingAction>>;
|
17
|
+
};
|
18
|
+
}>;
|
19
|
+
/**
|
20
|
+
* This hook will return the correct Zustand state based on the application which runs the library
|
21
|
+
*/
|
22
|
+
export declare const useMtsBookingState: () => import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<MtsBookingState & MtsBookingAction>, "persist"> & {
|
23
|
+
persist: {
|
24
|
+
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<MtsBookingState & MtsBookingAction, MtsBookingState & MtsBookingAction>>) => void;
|
25
|
+
clearStorage: () => void;
|
26
|
+
rehydrate: () => void | Promise<void>;
|
27
|
+
hasHydrated: () => boolean;
|
28
|
+
onHydrate: (fn: (state: MtsBookingState & MtsBookingAction) => void) => () => void;
|
29
|
+
onFinishHydration: (fn: (state: MtsBookingState & MtsBookingAction) => void) => () => void;
|
30
|
+
getOptions: () => Partial<import("zustand/middleware").PersistOptions<MtsBookingState & MtsBookingAction, MtsBookingState & MtsBookingAction>>;
|
31
|
+
};
|
32
|
+
}>;
|
33
|
+
export declare const useTestState: () => import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<MtsBookingState & MtsBookingAction>, "persist"> & {
|
34
|
+
persist: {
|
35
|
+
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<MtsBookingState & MtsBookingAction, MtsBookingState & MtsBookingAction>>) => void;
|
36
|
+
clearStorage: () => void;
|
37
|
+
rehydrate: () => void | Promise<void>;
|
38
|
+
hasHydrated: () => boolean;
|
39
|
+
onHydrate: (fn: (state: MtsBookingState & MtsBookingAction) => void) => () => void;
|
40
|
+
onFinishHydration: (fn: (state: MtsBookingState & MtsBookingAction) => void) => () => void;
|
41
|
+
getOptions: () => Partial<import("zustand/middleware").PersistOptions<MtsBookingState & MtsBookingAction, MtsBookingState & MtsBookingAction>>;
|
42
|
+
};
|
43
|
+
}>;
|
44
|
+
export {};
|
@@ -0,0 +1,48 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
3
|
+
__assign = Object.assign || function(t) {
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
5
|
+
s = arguments[i];
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
7
|
+
t[p] = s[p];
|
8
|
+
}
|
9
|
+
return t;
|
10
|
+
};
|
11
|
+
return __assign.apply(this, arguments);
|
12
|
+
};
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
14
|
+
exports.useTestState = exports.useMtsBookingState = exports.useMtsBookingLocalState = void 0;
|
15
|
+
var async_storage_1 = require("@react-native-async-storage/async-storage");
|
16
|
+
var zustand_1 = require("zustand");
|
17
|
+
var middleware_1 = require("zustand/middleware");
|
18
|
+
var INITIAL_STATE = {
|
19
|
+
cartId: 0,
|
20
|
+
};
|
21
|
+
var useMtsBookingAsyncState = (0, zustand_1.create)((0, middleware_1.persist)(function (set) { return (__assign(__assign({}, INITIAL_STATE), { updateCartId: function (cartId) { return set(function () { return ({ cartId: cartId }); }); }, resetState: function () { return set(function () { return INITIAL_STATE; }); } })); }, {
|
22
|
+
name: "mts-booking-storage",
|
23
|
+
storage: (0, middleware_1.createJSONStorage)(function () { return async_storage_1.default; })
|
24
|
+
}));
|
25
|
+
exports.useMtsBookingLocalState = (0, zustand_1.create)((0, middleware_1.persist)(function (set) { return (__assign(__assign({}, INITIAL_STATE), { updateCartId: function (cartId) { return set(function () { return ({ cartId: cartId }); }); }, resetState: function () { return set(function () { return INITIAL_STATE; }); } })); }, {
|
26
|
+
name: "mts-booking-storage",
|
27
|
+
storage: (0, middleware_1.createJSONStorage)(function () { return localStorage; })
|
28
|
+
}));
|
29
|
+
/**
|
30
|
+
* This hook will return the correct Zustand state based on the application which runs the library
|
31
|
+
*/
|
32
|
+
var useMtsBookingState = function () {
|
33
|
+
if (typeof document !== 'undefined') {
|
34
|
+
// Web application
|
35
|
+
return exports.useMtsBookingLocalState;
|
36
|
+
}
|
37
|
+
// react-native application
|
38
|
+
return useMtsBookingAsyncState;
|
39
|
+
};
|
40
|
+
exports.useMtsBookingState = useMtsBookingState;
|
41
|
+
var useTestState = function () {
|
42
|
+
if (typeof localStorage === "undefined" || localStorage === null) {
|
43
|
+
var LocalStorage = require("node-localstorage").LocalStorage;
|
44
|
+
global.localStorage = new LocalStorage("./scratch");
|
45
|
+
}
|
46
|
+
return exports.useMtsBookingLocalState;
|
47
|
+
};
|
48
|
+
exports.useTestState = useTestState;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
/**
|
2
|
+
* This type represents a city
|
3
|
+
* @param {number} id The id of the city in the database
|
4
|
+
* @param {string} name The name of the city
|
5
|
+
* @param {string} stateName The name of the state where the city is located (e.g. "Italy")
|
6
|
+
* @param {string} regionName The name of the region where the city is located (e.g. "Lombardia")
|
7
|
+
* @param {string} provinceName The name of the province where the city is located (e.g. "Milano")
|
8
|
+
* @param {string} shortProvinceName The short name of the province where the city is located (e.g. "MI")
|
9
|
+
*/
|
10
|
+
export type City = {
|
11
|
+
id: number;
|
12
|
+
name: string;
|
13
|
+
stateName: string;
|
14
|
+
regionName: string;
|
15
|
+
provinceName: string;
|
16
|
+
shortProvinceName: string;
|
17
|
+
};
|
@@ -1,11 +1,13 @@
|
|
1
1
|
/**
|
2
|
-
* This represents a tariff,
|
2
|
+
* This represents a tariff, which defined the price to pay for a certain ticket.
|
3
|
+
* @param {number} id - The id of the tariff.
|
3
4
|
* @param {number} tariffTypeId - The id of the tariff type.
|
4
5
|
* @param {number} termsTypeId - The id of the terms type.
|
5
6
|
* @param {number} value - The value of the tariff (in the currency specified in the {@link Booking} object).
|
6
7
|
* @param {number} quantity - The number of passengers to which this tariff applies.
|
7
8
|
*/
|
8
9
|
export type Tariff = {
|
10
|
+
id: number;
|
9
11
|
tariffTypeId: number;
|
10
12
|
termsTypeId: number;
|
11
13
|
value: number;
|
@@ -17,7 +19,8 @@ export type Tariff = {
|
|
17
19
|
*/
|
18
20
|
export type TariffsMatrix = Tariff[][];
|
19
21
|
/**
|
20
|
-
* This represents a tariff type
|
22
|
+
* This represents a tariff type (e.g. "Adult", "Child", "Over65", ...).
|
23
|
+
* @param {number} id - The id of the tariff type in the db.
|
21
24
|
* @param {string} name - The name of the tariff type.
|
22
25
|
* @param {string} description - The description of the tariff type.
|
23
26
|
* @param {boolean} requiredPassengersName - Whether the passengers' names are required for this tariff type.
|
@@ -26,6 +29,7 @@ export type TariffsMatrix = Tariff[][];
|
|
26
29
|
* including info on the rules that apply to it.
|
27
30
|
*/
|
28
31
|
export type TariffType = {
|
32
|
+
id: number;
|
29
33
|
name: string;
|
30
34
|
description: string;
|
31
35
|
requiredPassengersName: boolean;
|
@@ -33,7 +37,8 @@ export type TariffType = {
|
|
33
37
|
bookingProcessDescription: string;
|
34
38
|
};
|
35
39
|
/**
|
36
|
-
* This represents a terms type
|
40
|
+
* This represents a terms type (e.g. "Standard", "Business", ...).
|
41
|
+
* @param {number} id - The id of the terms type in the db.
|
37
42
|
* @param {string} name - The name of the terms type.
|
38
43
|
* @param {string} description - The description of the terms type.
|
39
44
|
* @param {boolean} isRefundAllowed - Whether tickets refunds are allowed for this terms type.
|
@@ -43,6 +48,7 @@ export type TariffType = {
|
|
43
48
|
* including info on the rules that apply to it.
|
44
49
|
*/
|
45
50
|
export type TermsType = {
|
51
|
+
id: number;
|
46
52
|
name: string;
|
47
53
|
description: string;
|
48
54
|
isRefundAllowed: boolean;
|
@@ -1,7 +1,8 @@
|
|
1
1
|
/**
|
2
2
|
* @description Represents information about a journey.
|
3
3
|
*
|
4
|
-
* @property {string} sellerName - The name of the seller
|
4
|
+
* @property {string} sellerName - The name of the seller operating the journey.
|
5
|
+
* @property {string} sellerId - The id of the seller operating the journey.
|
5
6
|
* @property {string} minimumTotalPrice - The minimum total price for booking the journey, meaning the price if all passenger choose the cheapest tariff.
|
6
7
|
* @property {number} remainingSeats - The number of remaining seats for the journey.
|
7
8
|
* @property {number} totalNumberOfSeats - The total number of seats for the journey (including booked seats).
|
@@ -10,6 +11,7 @@
|
|
10
11
|
*/
|
11
12
|
export type JourneyInfo = {
|
12
13
|
sellerName: string;
|
14
|
+
sellerId: string;
|
13
15
|
minimumTotalPrice: string;
|
14
16
|
remainingSeats: number;
|
15
17
|
totalNumberOfSeats: number;
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { Tariff } from "../common/Tariffs";
|
2
|
+
/**
|
3
|
+
* This represents the response of the API {@link TplBooking.getTariffs}.
|
4
|
+
* @param {Tariff[]} tariffs - The list of available tariffs. This is meant to be a fast access for displaying the data.
|
5
|
+
* In particular, this array is equivalent to `tariffPlanToTariffs[0]`
|
6
|
+
* @param {Map<number, Tariff[]>} tariffPlanToTariffs - A map that associates a tariff plan to the list of tariffs available for that tariff plan.
|
7
|
+
* The key is the tariff plan id, while the value is the list of available tariffs.
|
8
|
+
*/
|
9
|
+
export type GetTariffsResponse = {
|
10
|
+
tariffs: Tariff[];
|
11
|
+
tariffPlanToTariffs: Map<number, Tariff[]>;
|
12
|
+
};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/**
|
2
|
+
* This type represents a super area. It is the return object of the {@link TplBooking.getSuperAreas} method.
|
3
|
+
* @param {number} id The id of the super area in the database
|
4
|
+
* @param {string} name The name of the super area
|
5
|
+
* @param {string} shortName The short name of the super area
|
6
|
+
* @param {string} description The description of the super area
|
7
|
+
*/
|
8
|
+
export type SuperArea = {
|
9
|
+
id: number;
|
10
|
+
name: string;
|
11
|
+
shortName: string;
|
12
|
+
description: string;
|
13
|
+
};
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import { Booking } from "../../booking/booking";
|
2
|
+
import { Cart } from "../common/Cart";
|
3
|
+
import { TariffSummary } from "../common/Tariffs";
|
4
|
+
/**
|
5
|
+
* @description Represents a `TplCart`, which extends the {@link Cart} type by including additional
|
6
|
+
* information about the bookings
|
7
|
+
*
|
8
|
+
* @property {JourneyBookingType[]} bookings - An array of {@link TplBookingType} objects representing the bookings associated
|
9
|
+
* with this tpl cart.
|
10
|
+
*/
|
11
|
+
export type TplCart = Cart & {
|
12
|
+
bookings: TplBookingType[];
|
13
|
+
};
|
14
|
+
/**
|
15
|
+
* @description Represents a `Tpl`, which contains information about a tpl booking.
|
16
|
+
*
|
17
|
+
* @property {Booking.BookingTypes} type - The type of booking. For journeys, this is always `Booking.BookingTypes.TPL`.
|
18
|
+
* @property {TariffSummary[]} summary - An array of {@link TariffSummary} objects representing the tariff summary
|
19
|
+
* associated with this tpl booking.
|
20
|
+
* @property {TplBookingInfo} info - An {@link TplBookingInfo} object containing general information about the booking.
|
21
|
+
*/
|
22
|
+
export type TplBookingType = {
|
23
|
+
type: Booking.BookingTypes;
|
24
|
+
info: TplBookingInfo;
|
25
|
+
summary: TariffSummary[];
|
26
|
+
};
|
27
|
+
/**
|
28
|
+
* @description Represents a `TplBookingInfo`, which contains general information about a tpl booking.
|
29
|
+
* @property {boolean} isSubscription - Whether the booking is a subscription or a single ticket.
|
30
|
+
* @property {number} superAreaId - The id of the super area.
|
31
|
+
* @property {number} validity - The validity of the ticket (or of the subscription).
|
32
|
+
* @property {string} startDate - The start date of the ticket (or of the subscription).
|
33
|
+
* @property {string} endDate - The end date of the ticket (or of the subscription).
|
34
|
+
*/
|
35
|
+
export type TplBookingInfo = {
|
36
|
+
isSubscription: boolean;
|
37
|
+
superAreaId: number;
|
38
|
+
validity: number;
|
39
|
+
startDate: string;
|
40
|
+
endDate: string;
|
41
|
+
};
|
package/lib/utils/apiCall.js
CHANGED
@@ -75,16 +75,16 @@ var makeGet = function (url) { return __awaiter(void 0, void 0, void 0, function
|
|
75
75
|
}
|
76
76
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
|
77
77
|
var response, filteredResponse, error_1, resError, resError;
|
78
|
-
var _a, _b, _c;
|
79
|
-
return __generator(this, function (
|
80
|
-
switch (
|
78
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
79
|
+
return __generator(this, function (_h) {
|
80
|
+
switch (_h.label) {
|
81
81
|
case 0:
|
82
|
-
|
82
|
+
_h.trys.push([0, 2, , 3]);
|
83
83
|
return [4 /*yield*/, axios_1.default.get(url, {
|
84
84
|
headers: __assign({ "Content-Type": "application/json", "Ocp-Apim-Subscription-Key": (0, config_1.getConfig)().OCP_SUBSCRIPTION_KEY }, ((0, config_1.getConfig)().ACCESS_TOKEN && { "Authorization": "Bearer ".concat((0, config_1.getConfig)().ACCESS_TOKEN) })),
|
85
85
|
})];
|
86
86
|
case 1:
|
87
|
-
response =
|
87
|
+
response = _h.sent();
|
88
88
|
filteredResponse = removeNullError(response.data);
|
89
89
|
if (debug) {
|
90
90
|
console.log("GET_ResponseData", url, filteredResponse);
|
@@ -92,12 +92,12 @@ var makeGet = function (url) { return __awaiter(void 0, void 0, void 0, function
|
|
92
92
|
resolve(filteredResponse);
|
93
93
|
return [3 /*break*/, 3];
|
94
94
|
case 2:
|
95
|
-
error_1 =
|
95
|
+
error_1 = _h.sent();
|
96
96
|
if (axios_1.default.isAxiosError(error_1)) {
|
97
97
|
resError = {
|
98
98
|
httpStatus: ((_a = error_1.response) === null || _a === void 0 ? void 0 : _a.status) || 0,
|
99
|
-
mtsCode: ((_b = error_1.response) === null || _b === void 0 ? void 0 : _b.data.error.code) || 0,
|
100
|
-
message: ((
|
99
|
+
mtsCode: ((_d = (_c = (_b = error_1.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.error) === null || _d === void 0 ? void 0 : _d.code) || 0,
|
100
|
+
message: ((_g = (_f = (_e = error_1.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.error) === null || _g === void 0 ? void 0 : _g.message) || "Unknown error",
|
101
101
|
};
|
102
102
|
if (debug) {
|
103
103
|
console.log("GET_ResponseError", url, resError);
|
@@ -125,16 +125,16 @@ var makePost = function (url, data) { return __awaiter(void 0, void 0, void 0, f
|
|
125
125
|
}
|
126
126
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
|
127
127
|
var response, filteredResponse, error_2, resError;
|
128
|
-
var _a, _b, _c, _d, _e;
|
129
|
-
return __generator(this, function (
|
130
|
-
switch (
|
128
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
129
|
+
return __generator(this, function (_h) {
|
130
|
+
switch (_h.label) {
|
131
131
|
case 0:
|
132
|
-
|
132
|
+
_h.trys.push([0, 2, , 3]);
|
133
133
|
return [4 /*yield*/, axios_1.default.post(url, data, {
|
134
134
|
headers: __assign({ "Content-Type": "application/json", "Ocp-Apim-Subscription-Key": (0, config_1.getConfig)().OCP_SUBSCRIPTION_KEY }, ((0, config_1.getConfig)().ACCESS_TOKEN && { "Authorization": "Bearer ".concat((0, config_1.getConfig)().ACCESS_TOKEN) })),
|
135
135
|
})];
|
136
136
|
case 1:
|
137
|
-
response =
|
137
|
+
response = _h.sent();
|
138
138
|
filteredResponse = removeNullError(response.data);
|
139
139
|
if (debug) {
|
140
140
|
console.log("POST_ResponseData", url, filteredResponse);
|
@@ -142,12 +142,12 @@ var makePost = function (url, data) { return __awaiter(void 0, void 0, void 0, f
|
|
142
142
|
resolve(filteredResponse);
|
143
143
|
return [3 /*break*/, 3];
|
144
144
|
case 2:
|
145
|
-
error_2 =
|
145
|
+
error_2 = _h.sent();
|
146
146
|
if (axios_1.default.isAxiosError(error_2)) {
|
147
147
|
resError = {
|
148
|
-
httpStatus: ((_a = error_2.response) === null || _a === void 0 ? void 0 : _a.status) ||
|
149
|
-
mtsCode: ((_c = (_b = error_2.response) === null || _b === void 0 ? void 0 : _b.data
|
150
|
-
message: ((
|
148
|
+
httpStatus: ((_a = error_2.response) === null || _a === void 0 ? void 0 : _a.status) || 0,
|
149
|
+
mtsCode: ((_d = (_c = (_b = error_2.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.error) === null || _d === void 0 ? void 0 : _d.code) || 0,
|
150
|
+
message: ((_g = (_f = (_e = error_2.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.error) === null || _g === void 0 ? void 0 : _g.message) || "Unknown error",
|
151
151
|
};
|
152
152
|
if (debug) {
|
153
153
|
console.log("POST_ResponseError", url, resError);
|
@@ -175,16 +175,16 @@ var makeDelete = function (url) { return __awaiter(void 0, void 0, void 0, funct
|
|
175
175
|
}
|
176
176
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
|
177
177
|
var response, filteredResponse, error_3, resError;
|
178
|
-
var _a, _b, _c, _d, _e;
|
179
|
-
return __generator(this, function (
|
180
|
-
switch (
|
178
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
179
|
+
return __generator(this, function (_h) {
|
180
|
+
switch (_h.label) {
|
181
181
|
case 0:
|
182
|
-
|
182
|
+
_h.trys.push([0, 2, , 3]);
|
183
183
|
return [4 /*yield*/, axios_1.default.delete(url, {
|
184
184
|
headers: __assign({ "Content-Type": "application/json", "Ocp-Apim-Subscription-Key": (0, config_1.getConfig)().OCP_SUBSCRIPTION_KEY }, ((0, config_1.getConfig)().ACCESS_TOKEN && { "Authorization": "Bearer ".concat((0, config_1.getConfig)().ACCESS_TOKEN) })),
|
185
185
|
})];
|
186
186
|
case 1:
|
187
|
-
response =
|
187
|
+
response = _h.sent();
|
188
188
|
filteredResponse = removeNullError(response.data);
|
189
189
|
if (debug) {
|
190
190
|
console.log("DELETE_ResponseData", url, filteredResponse);
|
@@ -192,12 +192,12 @@ var makeDelete = function (url) { return __awaiter(void 0, void 0, void 0, funct
|
|
192
192
|
resolve(filteredResponse);
|
193
193
|
return [3 /*break*/, 3];
|
194
194
|
case 2:
|
195
|
-
error_3 =
|
195
|
+
error_3 = _h.sent();
|
196
196
|
if (axios_1.default.isAxiosError(error_3)) {
|
197
197
|
resError = {
|
198
|
-
httpStatus: ((_a = error_3.response) === null || _a === void 0 ? void 0 : _a.status) ||
|
199
|
-
mtsCode: ((_c = (_b = error_3.response) === null || _b === void 0 ? void 0 : _b.data
|
200
|
-
message: ((
|
198
|
+
httpStatus: ((_a = error_3.response) === null || _a === void 0 ? void 0 : _a.status) || 0,
|
199
|
+
mtsCode: ((_d = (_c = (_b = error_3.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.error) === null || _d === void 0 ? void 0 : _d.code) || 0,
|
200
|
+
message: ((_g = (_f = (_e = error_3.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.error) === null || _g === void 0 ? void 0 : _g.message) || "Unknown error",
|
201
201
|
};
|
202
202
|
if (debug) {
|
203
203
|
console.log("DELETE_ResponseError", url, resError);
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "mts-booking-library",
|
3
|
-
"version": "1.
|
4
|
-
"description": "Library for
|
3
|
+
"version": "1.3.0",
|
4
|
+
"description": "Library for using MyTicketSolution Booking API",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"types": "lib/index.d.ts",
|
7
7
|
"scripts": {
|
@@ -17,7 +17,7 @@
|
|
17
17
|
"@types/jest": "^29.5.12",
|
18
18
|
"jest": "^29.7.0",
|
19
19
|
"ts-jest": "^29.1.2",
|
20
|
-
"typescript": "^5.
|
20
|
+
"typescript": "^5.4.2"
|
21
21
|
},
|
22
22
|
"files": [
|
23
23
|
"lib/**/*"
|
@@ -26,9 +26,11 @@
|
|
26
26
|
"myticketsolution",
|
27
27
|
"booking"
|
28
28
|
],
|
29
|
-
"author": "
|
29
|
+
"author": "Infoservice s.r.l.",
|
30
30
|
"dependencies": {
|
31
|
-
"
|
32
|
-
"
|
31
|
+
"@react-native-async-storage/async-storage": "^1.23.1",
|
32
|
+
"axios": "^1.6.8",
|
33
|
+
"node-localstorage": "^3.0.5",
|
34
|
+
"zustand": "^4.5.2"
|
33
35
|
}
|
34
36
|
}
|