mts-booking-library 1.3.25 → 2.0.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 +37 -10
- package/lib/booking/booking.js +110 -9
- package/lib/booking/journeyBooking.d.ts +8 -21
- package/lib/booking/journeyBooking.js +21 -58
- package/lib/booking/serviceBooking.d.ts +9 -22
- package/lib/booking/serviceBooking.js +23 -58
- package/lib/booking/subscriptionBooking.d.ts +8 -21
- package/lib/booking/subscriptionBooking.js +20 -55
- package/lib/booking/tplBooking.d.ts +13 -31
- package/lib/booking/tplBooking.js +29 -68
- package/lib/index.d.ts +8 -7
- package/lib/index.js +3 -3
- package/lib/mtsStorage.d.ts +1 -3
- package/lib/mtsStorage.js +4 -5
- package/lib/types/common/Cart.d.ts +0 -5
- package/lib/types/common/Extra.d.ts +13 -1
- package/lib/types/common/Payment.d.ts +3 -3
- package/lib/types/common/Payment.js +1 -1
- package/lib/types/common/Person.d.ts +8 -8
- package/lib/types/common/Person.js +3 -3
- package/lib/types/common/Tariffs.d.ts +2 -0
- package/lib/types/journeys/JourneyCart.d.ts +14 -9
- package/lib/types/journeys/JourneyCart.js +1 -1
- package/lib/types/services/ServiceCart.d.ts +4 -0
- package/lib/types/tpl/SuperArea.d.ts +6 -0
- package/lib/types/tpl/TplCart.d.ts +19 -0
- package/lib/utils/apiCall.d.ts +1 -0
- package/lib/utils/apiCall.js +70 -9
- package/package.json +6 -6
    
        package/lib/utils/apiCall.js
    CHANGED
    
    | @@ -27,8 +27,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge | |
| 27 27 | 
             
                });
         | 
| 28 28 | 
             
            };
         | 
| 29 29 | 
             
            var __generator = (this && this.__generator) || function (thisArg, body) {
         | 
| 30 | 
            -
                var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
         | 
| 31 | 
            -
                return g =  | 
| 30 | 
            +
                var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
         | 
| 31 | 
            +
                return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
         | 
| 32 32 | 
             
                function verb(n) { return function (v) { return step([n, v]); }; }
         | 
| 33 33 | 
             
                function step(op) {
         | 
| 34 34 | 
             
                    if (f) throw new TypeError("Generator is already executing.");
         | 
| @@ -54,7 +54,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { | |
| 54 54 | 
             
                }
         | 
| 55 55 | 
             
            };
         | 
| 56 56 | 
             
            Object.defineProperty(exports, "__esModule", { value: true });
         | 
| 57 | 
            -
            exports.makeDelete = exports.makePost = exports.makeGet = void 0;
         | 
| 57 | 
            +
            exports.makeDelete = exports.makePut = exports.makePost = exports.makeGet = void 0;
         | 
| 58 58 | 
             
            var axios_1 = require("axios");
         | 
| 59 59 | 
             
            var config_1 = require("../config");
         | 
| 60 60 | 
             
            var utils_1 = require("./utils");
         | 
| @@ -190,17 +190,17 @@ var makePost = function (url, data) { return __awaiter(void 0, void 0, void 0, f | |
| 190 190 | 
             
                });
         | 
| 191 191 | 
             
            }); };
         | 
| 192 192 | 
             
            exports.makePost = makePost;
         | 
| 193 | 
            -
            var  | 
| 193 | 
            +
            var makePut = function (url, data) { return __awaiter(void 0, void 0, void 0, function () {
         | 
| 194 194 | 
             
                var debug, subKey, errorReport;
         | 
| 195 195 | 
             
                return __generator(this, function (_a) {
         | 
| 196 196 | 
             
                    debug = (0, config_1.getConfig)().DEBUG;
         | 
| 197 197 | 
             
                    if (debug) {
         | 
| 198 | 
            -
                        console.log(" | 
| 198 | 
            +
                        console.log("PUT_RequestData", url, data);
         | 
| 199 199 | 
             
                    }
         | 
| 200 200 | 
             
                    subKey = (0, config_1.getConfig)().OCP_SUBSCRIPTION_KEY;
         | 
| 201 201 | 
             
                    if ((0, utils_1.isNullOrWhiteSpace)(subKey)) {
         | 
| 202 202 | 
             
                        errorReport = "Sub Key: ".concat(subKey, ", url: ").concat(url, ", access token: ").concat((0, config_1.getConfig)().ACCESS_TOKEN);
         | 
| 203 | 
            -
                        throw new Error("MTS Library Error!  | 
| 203 | 
            +
                        throw new Error("MTS Library Error! makePut: missing OCP SUBSCRIPTION KEY! ".concat(errorReport));
         | 
| 204 204 | 
             
                    }
         | 
| 205 205 | 
             
                    return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
         | 
| 206 206 | 
             
                            var response, filteredResponse, error_3, message, resError, resError;
         | 
| @@ -209,14 +209,14 @@ var makeDelete = function (url) { return __awaiter(void 0, void 0, void 0, funct | |
| 209 209 | 
             
                                switch (_h.label) {
         | 
| 210 210 | 
             
                                    case 0:
         | 
| 211 211 | 
             
                                        _h.trys.push([0, 2, , 3]);
         | 
| 212 | 
            -
                                        return [4 /*yield*/, axios_1.default. | 
| 212 | 
            +
                                        return [4 /*yield*/, axios_1.default.put(url, data, {
         | 
| 213 213 | 
             
                                                headers: __assign(__assign({ "Content-Type": "application/json", "Ocp-Apim-Subscription-Key": subKey }, ((0, config_1.getConfig)().ACCESS_TOKEN && { Authorization: "Bearer ".concat((0, config_1.getConfig)().ACCESS_TOKEN) })), ((0, config_1.getConfig)().SESSION_ID && { SessionId: (0, config_1.getConfig)().SESSION_ID }))
         | 
| 214 214 | 
             
                                            })];
         | 
| 215 215 | 
             
                                    case 1:
         | 
| 216 216 | 
             
                                        response = _h.sent();
         | 
| 217 217 | 
             
                                        filteredResponse = removeNullError(response.data);
         | 
| 218 218 | 
             
                                        if (debug) {
         | 
| 219 | 
            -
                                            console.log(" | 
| 219 | 
            +
                                            console.log("PUT_ResponseData", url, filteredResponse);
         | 
| 220 220 | 
             
                                        }
         | 
| 221 221 | 
             
                                        resolve(filteredResponse);
         | 
| 222 222 | 
             
                                        return [3 /*break*/, 3];
         | 
| @@ -232,12 +232,73 @@ var makeDelete = function (url) { return __awaiter(void 0, void 0, void 0, funct | |
| 232 232 | 
             
                                                message: message || "Unknown error"
         | 
| 233 233 | 
             
                                            };
         | 
| 234 234 | 
             
                                            if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
         | 
| 235 | 
            -
                                                console.log(" | 
| 235 | 
            +
                                                console.log("PUT_ResponseAxiosError", url, resError);
         | 
| 236 236 | 
             
                                            }
         | 
| 237 237 | 
             
                                            reject(resError);
         | 
| 238 238 | 
             
                                        }
         | 
| 239 239 | 
             
                                        else {
         | 
| 240 240 | 
             
                                            resError = __assign(__assign({}, error_3), { httpStatus: 0, mtsCode: 0, message: "Unknown error" });
         | 
| 241 | 
            +
                                            if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
         | 
| 242 | 
            +
                                                console.log("PUT_ResponseError", url, resError);
         | 
| 243 | 
            +
                                            }
         | 
| 244 | 
            +
                                            reject(resError);
         | 
| 245 | 
            +
                                        }
         | 
| 246 | 
            +
                                        return [3 /*break*/, 3];
         | 
| 247 | 
            +
                                    case 3: return [2 /*return*/];
         | 
| 248 | 
            +
                                }
         | 
| 249 | 
            +
                            });
         | 
| 250 | 
            +
                        }); })];
         | 
| 251 | 
            +
                });
         | 
| 252 | 
            +
            }); };
         | 
| 253 | 
            +
            exports.makePut = makePut;
         | 
| 254 | 
            +
            var makeDelete = function (url) { return __awaiter(void 0, void 0, void 0, function () {
         | 
| 255 | 
            +
                var debug, subKey, errorReport;
         | 
| 256 | 
            +
                return __generator(this, function (_a) {
         | 
| 257 | 
            +
                    debug = (0, config_1.getConfig)().DEBUG;
         | 
| 258 | 
            +
                    if (debug) {
         | 
| 259 | 
            +
                        console.log("DELETE_RequestData", url);
         | 
| 260 | 
            +
                    }
         | 
| 261 | 
            +
                    subKey = (0, config_1.getConfig)().OCP_SUBSCRIPTION_KEY;
         | 
| 262 | 
            +
                    if ((0, utils_1.isNullOrWhiteSpace)(subKey)) {
         | 
| 263 | 
            +
                        errorReport = "Sub Key: ".concat(subKey, ", url: ").concat(url, ", access token: ").concat((0, config_1.getConfig)().ACCESS_TOKEN);
         | 
| 264 | 
            +
                        throw new Error("MTS Library Error! makeDelete: missing OCP SUBSCRIPTION KEY! ".concat(errorReport));
         | 
| 265 | 
            +
                    }
         | 
| 266 | 
            +
                    return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
         | 
| 267 | 
            +
                            var response, filteredResponse, error_4, message, resError, resError;
         | 
| 268 | 
            +
                            var _a, _b, _c, _d, _e, _f, _g;
         | 
| 269 | 
            +
                            return __generator(this, function (_h) {
         | 
| 270 | 
            +
                                switch (_h.label) {
         | 
| 271 | 
            +
                                    case 0:
         | 
| 272 | 
            +
                                        _h.trys.push([0, 2, , 3]);
         | 
| 273 | 
            +
                                        return [4 /*yield*/, axios_1.default.delete(url, {
         | 
| 274 | 
            +
                                                headers: __assign(__assign({ "Content-Type": "application/json", "Ocp-Apim-Subscription-Key": subKey }, ((0, config_1.getConfig)().ACCESS_TOKEN && { Authorization: "Bearer ".concat((0, config_1.getConfig)().ACCESS_TOKEN) })), ((0, config_1.getConfig)().SESSION_ID && { SessionId: (0, config_1.getConfig)().SESSION_ID }))
         | 
| 275 | 
            +
                                            })];
         | 
| 276 | 
            +
                                    case 1:
         | 
| 277 | 
            +
                                        response = _h.sent();
         | 
| 278 | 
            +
                                        filteredResponse = removeNullError(response.data);
         | 
| 279 | 
            +
                                        if (debug) {
         | 
| 280 | 
            +
                                            console.log("DELETE_ResponseData", url, filteredResponse);
         | 
| 281 | 
            +
                                        }
         | 
| 282 | 
            +
                                        resolve(filteredResponse);
         | 
| 283 | 
            +
                                        return [3 /*break*/, 3];
         | 
| 284 | 
            +
                                    case 2:
         | 
| 285 | 
            +
                                        error_4 = _h.sent();
         | 
| 286 | 
            +
                                        if (axios_1.default.isAxiosError(error_4)) {
         | 
| 287 | 
            +
                                            message = "error" in ((_a = error_4.response) === null || _a === void 0 ? void 0 : _a.data)
         | 
| 288 | 
            +
                                                ? (_b = error_4.response) === null || _b === void 0 ? void 0 : _b.data.error.message
         | 
| 289 | 
            +
                                                : (_c = error_4.response) === null || _c === void 0 ? void 0 : _c.data.message;
         | 
| 290 | 
            +
                                            resError = {
         | 
| 291 | 
            +
                                                httpStatus: ((_d = error_4.response) === null || _d === void 0 ? void 0 : _d.status) || 0,
         | 
| 292 | 
            +
                                                mtsCode: ((_g = (_f = (_e = error_4.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.error) === null || _g === void 0 ? void 0 : _g.code) || 0,
         | 
| 293 | 
            +
                                                message: message || "Unknown error"
         | 
| 294 | 
            +
                                            };
         | 
| 295 | 
            +
                                            if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
         | 
| 296 | 
            +
                                                console.log("DELETE_ResponseAxiosError", url, resError);
         | 
| 297 | 
            +
                                            }
         | 
| 298 | 
            +
                                            reject(resError);
         | 
| 299 | 
            +
                                        }
         | 
| 300 | 
            +
                                        else {
         | 
| 301 | 
            +
                                            resError = __assign(__assign({}, error_4), { httpStatus: 0, mtsCode: 0, message: "Unknown error" });
         | 
| 241 302 | 
             
                                            if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
         | 
| 242 303 | 
             
                                                console.log("DELETE_ResponseError", url, resError);
         | 
| 243 304 | 
             
                                            }
         | 
    
        package/package.json
    CHANGED
    
    | @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            {
         | 
| 2 2 | 
             
              "name": "mts-booking-library",
         | 
| 3 | 
            -
              "version": " | 
| 3 | 
            +
              "version": "2.0.0",
         | 
| 4 4 | 
             
              "description": "Library for using MyTicketSolution Booking API",
         | 
| 5 5 | 
             
              "main": "lib/index.js",
         | 
| 6 6 | 
             
              "types": "lib/index.d.ts",
         | 
| @@ -16,11 +16,11 @@ | |
| 16 16 | 
             
              },
         | 
| 17 17 | 
             
              "license": "ISC",
         | 
| 18 18 | 
             
              "devDependencies": {
         | 
| 19 | 
            -
                "@types/jest": "^29.5. | 
| 19 | 
            +
                "@types/jest": "^29.5.13",
         | 
| 20 20 | 
             
                "jest": "^29.7.0",
         | 
| 21 21 | 
             
                "prettier": "^3.3.3",
         | 
| 22 | 
            -
                "ts-jest": "^29.2. | 
| 23 | 
            -
                "typescript": "^5. | 
| 22 | 
            +
                "ts-jest": "^29.2.5",
         | 
| 23 | 
            +
                "typescript": "^5.6.2"
         | 
| 24 24 | 
             
              },
         | 
| 25 25 | 
             
              "files": [
         | 
| 26 26 | 
             
                "lib/**/*"
         | 
| @@ -31,8 +31,8 @@ | |
| 31 31 | 
             
              ],
         | 
| 32 32 | 
             
              "author": "Infoservice s.r.l.",
         | 
| 33 33 | 
             
              "dependencies": {
         | 
| 34 | 
            -
                "@react-native-async-storage/async-storage": "^ | 
| 35 | 
            -
                "axios": "^1.7. | 
| 34 | 
            +
                "@react-native-async-storage/async-storage": "^2.0.0",
         | 
| 35 | 
            +
                "axios": "^1.7.7",
         | 
| 36 36 | 
             
                "dotenv": "^16.4.5",
         | 
| 37 37 | 
             
                "node-localstorage": "^3.0.5",
         | 
| 38 38 | 
             
                "zustand": "^4.5.5"
         |