mts-booking-library 1.2.33 → 1.2.34

Sign up to get free protection for your applications and to get access to all the features.
@@ -47,10 +47,10 @@ export declare class ServiceBooking extends Booking {
47
47
  * and/or a specific hour for the tour.
48
48
  * You should call this method only if {@link Service.isDateOptional} or {@link Service.isDateRequired} is true for the selected tour.
49
49
  * @param {number} serviceId The id of the selected tour (can be retrieved in the object {@link Service} returned by {@link getTours})
50
- * @param {Date} date The date on which to get the tours
50
+ * @param {string} date The date on which to get the tours, in ISO string format
51
51
  * @returns {ServiceTrip[]} The returned information about the tour (tripId and hour)
52
52
  */
53
- getServiceTrips(serviceId: number, date: Date): Promise<ErrorResponse | ServiceTrip[]>;
53
+ getServiceTrips(serviceId: number, date: string): Promise<ErrorResponse | ServiceTrip[]>;
54
54
  createServiceCart(serviceCart: CreateServiceCartRequest): Promise<ErrorResponse | ServiceCart>;
55
55
  /**
56
56
  * @description This method shall be called when the user wants to retrieve information about the buyer and the passengers.
@@ -232,14 +232,14 @@ var ServiceBooking = /** @class */ (function (_super) {
232
232
  * and/or a specific hour for the tour.
233
233
  * You should call this method only if {@link Service.isDateOptional} or {@link Service.isDateRequired} is true for the selected tour.
234
234
  * @param {number} serviceId The id of the selected tour (can be retrieved in the object {@link Service} returned by {@link getTours})
235
- * @param {Date} date The date on which to get the tours
235
+ * @param {string} date The date on which to get the tours, in ISO string format
236
236
  * @returns {ServiceTrip[]} The returned information about the tour (tripId and hour)
237
237
  */
238
238
  ServiceBooking.prototype.getServiceTrips = function (serviceId, date) {
239
239
  return __awaiter(this, void 0, void 0, function () {
240
240
  var searchParams, url;
241
241
  return __generator(this, function (_a) {
242
- searchParams = new URLSearchParams({ date: date.toDateString() });
242
+ searchParams = new URLSearchParams({ date: date });
243
243
  url = "".concat(this.config.API_ENDPOINT, "/booking/services/").concat(serviceId, "/trips?").concat(searchParams);
244
244
  return [2 /*return*/, this.callGetApi(url).then(function (response) {
245
245
  return (0, ErrorResponse_1.objectIsMTSErrorResponse)(response) ? response : response.trips;
@@ -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 (_d) {
80
- switch (_d.label) {
78
+ var _a, _b, _c, _d, _e, _f, _g;
79
+ return __generator(this, function (_h) {
80
+ switch (_h.label) {
81
81
  case 0:
82
- _d.trys.push([0, 2, , 3]);
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 = _d.sent();
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 = _d.sent();
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: ((_c = error_1.response) === null || _c === void 0 ? void 0 : _c.data.error.message) || "Unknown error",
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 (_f) {
130
- switch (_f.label) {
128
+ var _a, _b, _c, _d, _e, _f, _g;
129
+ return __generator(this, function (_h) {
130
+ switch (_h.label) {
131
131
  case 0:
132
- _f.trys.push([0, 2, , 3]);
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 = _f.sent();
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 = _f.sent();
145
+ error_2 = _h.sent();
146
146
  if (axios_1.default.isAxiosError(error_2)) {
147
147
  resError = {
148
148
  httpStatus: ((_a = error_2.response) === null || _a === void 0 ? void 0 : _a.status) || 500,
149
- mtsCode: ((_c = (_b = error_2.response) === null || _b === void 0 ? void 0 : _b.data.error) === null || _c === void 0 ? void 0 : _c.code) || 500,
150
- message: ((_e = (_d = error_2.response) === null || _d === void 0 ? void 0 : _d.data.error) === null || _e === void 0 ? void 0 : _e.message) || "Unknown error",
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) || 500,
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 (_f) {
180
- switch (_f.label) {
178
+ var _a, _b, _c, _d, _e, _f, _g;
179
+ return __generator(this, function (_h) {
180
+ switch (_h.label) {
181
181
  case 0:
182
- _f.trys.push([0, 2, , 3]);
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 = _f.sent();
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 = _f.sent();
195
+ error_3 = _h.sent();
196
196
  if (axios_1.default.isAxiosError(error_3)) {
197
197
  resError = {
198
198
  httpStatus: ((_a = error_3.response) === null || _a === void 0 ? void 0 : _a.status) || 500,
199
- mtsCode: ((_c = (_b = error_3.response) === null || _b === void 0 ? void 0 : _b.data.error) === null || _c === void 0 ? void 0 : _c.code) || 500,
200
- message: ((_e = (_d = error_3.response) === null || _d === void 0 ? void 0 : _d.data.error) === null || _e === void 0 ? void 0 : _e.message) || "Unknown error",
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) || 500,
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,6 +1,6 @@
1
1
  {
2
2
  "name": "mts-booking-library",
3
- "version": "1.2.33",
3
+ "version": "1.2.34",
4
4
  "description": "Library for use MyTicketSolution Booking API",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",