mts-booking-library 1.0.5 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,13 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefaultJourneySearch = void 0;
4
- var __1 = require("../..");
5
- exports.DefaultJourneySearch = {
3
+ exports.DEFAULT_JOURNEY_SEARCH = void 0;
4
+ var booking_1 = require("../../booking/booking");
5
+ exports.DEFAULT_JOURNEY_SEARCH = {
6
6
  departureStopName: "",
7
7
  destinationStopName: "",
8
8
  passengersNumber: 1,
9
- date: new Date(Date.UTC(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), 0, 1)),
9
+ date: new Date(Date.UTC(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), 0, 1))
10
+ .toISOString()
11
+ .slice(0, -1),
10
12
  roundTripDate: null,
11
- currency: __1.Booking.Currencies.EUR,
13
+ currency: booking_1.Booking.Currencies.EUR,
12
14
  isRoundtrip: false,
13
15
  };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ // This module contains the types to manage the passengers information
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.DEFAULT_PERSON = void 0;
5
+ exports.DEFAULT_PERSON = {
6
+ id: 0,
7
+ name: '',
8
+ lastName: '',
9
+ email: '',
10
+ phoneNumber: ''
11
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -51,8 +51,12 @@ exports.makePost = exports.makeGet = void 0;
51
51
  var axios_1 = require("axios");
52
52
  var config_1 = require("../config");
53
53
  var makeGet = function (url) { return __awaiter(void 0, void 0, void 0, function () {
54
+ var debug;
54
55
  return __generator(this, function (_a) {
55
- console.log("GET ".concat(url));
56
+ debug = (0, config_1.getConfig)().DEBUG;
57
+ if (debug) {
58
+ console.log("GetRequestData", url);
59
+ }
56
60
  return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
57
61
  var response, error_1, resError;
58
62
  return __generator(this, function (_a) {
@@ -64,11 +68,17 @@ var makeGet = function (url) { return __awaiter(void 0, void 0, void 0, function
64
68
  })];
65
69
  case 1:
66
70
  response = _a.sent();
71
+ if (debug) {
72
+ console.log("GetResponseData", url, response.data);
73
+ }
67
74
  resolve(response.data);
68
75
  return [3 /*break*/, 3];
69
76
  case 2:
70
77
  error_1 = _a.sent();
71
78
  resError = error_1.response.data;
79
+ if (debug) {
80
+ console.log("GetResponseError", url, resError);
81
+ }
72
82
  reject(resError);
73
83
  return [3 /*break*/, 3];
74
84
  case 3: return [2 /*return*/];
@@ -79,8 +89,12 @@ var makeGet = function (url) { return __awaiter(void 0, void 0, void 0, function
79
89
  }); };
80
90
  exports.makeGet = makeGet;
81
91
  var makePost = function (url, data) { return __awaiter(void 0, void 0, void 0, function () {
92
+ var debug;
82
93
  return __generator(this, function (_a) {
83
- console.log("POST ".concat(url));
94
+ debug = (0, config_1.getConfig)().DEBUG;
95
+ if (debug) {
96
+ console.log("PostRequestData", url, data);
97
+ }
84
98
  return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
85
99
  var response, error_2, resError;
86
100
  return __generator(this, function (_a) {
@@ -92,11 +106,17 @@ var makePost = function (url, data) { return __awaiter(void 0, void 0, void 0, f
92
106
  })];
93
107
  case 1:
94
108
  response = _a.sent();
109
+ if (debug) {
110
+ console.log("PostResponseData", url, response.data);
111
+ }
95
112
  resolve(response.data);
96
113
  return [3 /*break*/, 3];
97
114
  case 2:
98
115
  error_2 = _a.sent();
99
116
  resError = error_2.response.data;
117
+ if (debug) {
118
+ console.log("PostResponseError", url, resError);
119
+ }
100
120
  reject(resError);
101
121
  return [3 /*break*/, 3];
102
122
  case 3: return [2 /*return*/];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mts-booking-library",
3
- "version": "1.0.5",
3
+ "version": "1.1.0",
4
4
  "description": "Library for use MyTicketSolution Booking API",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "license": "ISC",
16
16
  "devDependencies": {
17
- "@types/jest": "^29.5.4",
17
+ "@types/jest": "^29.5.5",
18
18
  "jest": "^29.7.0",
19
19
  "ts-jest": "^29.1.1",
20
20
  "typescript": "^5.2.2"
@@ -28,7 +28,7 @@
28
28
  ],
29
29
  "author": "M",
30
30
  "dependencies": {
31
- "axios": "^1.5.0",
31
+ "axios": "^1.5.1",
32
32
  "node-localstorage": "^3.0.5"
33
33
  }
34
34
  }