mts-booking-library 1.3.10 → 1.3.11
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.
@@ -2,14 +2,14 @@
|
|
2
2
|
* @description Represents information about a service.
|
3
3
|
*
|
4
4
|
* @property {string} sellerName - The name of the seller offering the service.
|
5
|
-
* @property {
|
5
|
+
* @property {number} sellerId - The id of the seller offering the service.
|
6
6
|
* @property {string} minimumTotalPrice - The minimum total price for booking the service, meaning the price if all passenger choose the cheapest tariff.
|
7
7
|
* @property {string} bookingProcessMessage - Optional message to be displayed to the user when booking this service.
|
8
8
|
* @property {boolean} isBookable - Indicates whether the service is bookable (true) or not (false).
|
9
9
|
*/
|
10
10
|
export type ServiceInfo = {
|
11
11
|
sellerName: string;
|
12
|
-
sellerId:
|
12
|
+
sellerId: number;
|
13
13
|
minimumTotalPrice: string;
|
14
14
|
bookingProcessMessage: string;
|
15
15
|
isBookable: boolean;
|
package/lib/utils/apiCall.js
CHANGED
@@ -57,6 +57,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
57
|
exports.makeDelete = exports.makePost = exports.makeGet = void 0;
|
58
58
|
var axios_1 = require("axios");
|
59
59
|
var config_1 = require("../config");
|
60
|
+
var utils_1 = require("./utils");
|
60
61
|
var removeNullError = function (resData) {
|
61
62
|
var filteredResponse = {};
|
62
63
|
Object.keys(resData)
|
@@ -68,12 +69,17 @@ var removeNullError = function (resData) {
|
|
68
69
|
return filteredResponse;
|
69
70
|
};
|
70
71
|
var makeGet = function (url) { return __awaiter(void 0, void 0, void 0, function () {
|
71
|
-
var debug;
|
72
|
+
var debug, subKey, errorReport;
|
72
73
|
return __generator(this, function (_a) {
|
73
74
|
debug = (0, config_1.getConfig)().DEBUG;
|
74
75
|
if (debug) {
|
75
76
|
console.log("GET_RequestData", url);
|
76
77
|
}
|
78
|
+
subKey = (0, config_1.getConfig)().OCP_SUBSCRIPTION_KEY;
|
79
|
+
if ((0, utils_1.isNullOrWhiteSpace)(subKey)) {
|
80
|
+
errorReport = "Sub Key: ".concat(subKey, ", url: ").concat(url, ", access token: ").concat((0, config_1.getConfig)().ACCESS_TOKEN);
|
81
|
+
throw new Error("MTS Library Error! makeGet: missing OCP SUBSCRIPTION KEY! ".concat(errorReport));
|
82
|
+
}
|
77
83
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
|
78
84
|
var response, filteredResponse, error_1, resError, resError;
|
79
85
|
var _a, _b, _c, _d, _e, _f, _g;
|
@@ -82,7 +88,7 @@ var makeGet = function (url) { return __awaiter(void 0, void 0, void 0, function
|
|
82
88
|
case 0:
|
83
89
|
_h.trys.push([0, 2, , 3]);
|
84
90
|
return [4 /*yield*/, axios_1.default.get(url, {
|
85
|
-
headers: __assign({ "Content-Type": "application/json", "Ocp-Apim-Subscription-Key":
|
91
|
+
headers: __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) }))
|
86
92
|
})];
|
87
93
|
case 1:
|
88
94
|
response = _h.sent();
|
@@ -118,12 +124,17 @@ var makeGet = function (url) { return __awaiter(void 0, void 0, void 0, function
|
|
118
124
|
}); };
|
119
125
|
exports.makeGet = makeGet;
|
120
126
|
var makePost = function (url, data) { return __awaiter(void 0, void 0, void 0, function () {
|
121
|
-
var debug;
|
127
|
+
var debug, subKey, errorReport;
|
122
128
|
return __generator(this, function (_a) {
|
123
129
|
debug = (0, config_1.getConfig)().DEBUG;
|
124
130
|
if (debug) {
|
125
131
|
console.log("POST_RequestData", url, data);
|
126
132
|
}
|
133
|
+
subKey = (0, config_1.getConfig)().OCP_SUBSCRIPTION_KEY;
|
134
|
+
if ((0, utils_1.isNullOrWhiteSpace)(subKey)) {
|
135
|
+
errorReport = "Sub Key: ".concat(subKey, ", url: ").concat(url, ", access token: ").concat((0, config_1.getConfig)().ACCESS_TOKEN);
|
136
|
+
throw new Error("MTS Library Error! makePost: missing OCP SUBSCRIPTION KEY! ".concat(errorReport));
|
137
|
+
}
|
127
138
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
|
128
139
|
var response, filteredResponse, error_2, resError;
|
129
140
|
var _a, _b, _c, _d, _e, _f, _g;
|
@@ -132,7 +143,7 @@ var makePost = function (url, data) { return __awaiter(void 0, void 0, void 0, f
|
|
132
143
|
case 0:
|
133
144
|
_h.trys.push([0, 2, , 3]);
|
134
145
|
return [4 /*yield*/, axios_1.default.post(url, data, {
|
135
|
-
headers: __assign({ "Content-Type": "application/json", "Ocp-Apim-Subscription-Key":
|
146
|
+
headers: __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) }))
|
136
147
|
})];
|
137
148
|
case 1:
|
138
149
|
response = _h.sent();
|
@@ -168,12 +179,17 @@ var makePost = function (url, data) { return __awaiter(void 0, void 0, void 0, f
|
|
168
179
|
}); };
|
169
180
|
exports.makePost = makePost;
|
170
181
|
var makeDelete = function (url) { return __awaiter(void 0, void 0, void 0, function () {
|
171
|
-
var debug;
|
182
|
+
var debug, subKey, errorReport;
|
172
183
|
return __generator(this, function (_a) {
|
173
184
|
debug = (0, config_1.getConfig)().DEBUG;
|
174
185
|
if (debug) {
|
175
186
|
console.log("DELETE_RequestData", url);
|
176
187
|
}
|
188
|
+
subKey = (0, config_1.getConfig)().OCP_SUBSCRIPTION_KEY;
|
189
|
+
if ((0, utils_1.isNullOrWhiteSpace)(subKey)) {
|
190
|
+
errorReport = "Sub Key: ".concat(subKey, ", url: ").concat(url, ", access token: ").concat((0, config_1.getConfig)().ACCESS_TOKEN);
|
191
|
+
throw new Error("MTS Library Error! makeDelete: missing OCP SUBSCRIPTION KEY! ".concat(errorReport));
|
192
|
+
}
|
177
193
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
|
178
194
|
var response, filteredResponse, error_3, resError;
|
179
195
|
var _a, _b, _c, _d, _e, _f, _g;
|
@@ -182,7 +198,7 @@ var makeDelete = function (url) { return __awaiter(void 0, void 0, void 0, funct
|
|
182
198
|
case 0:
|
183
199
|
_h.trys.push([0, 2, , 3]);
|
184
200
|
return [4 /*yield*/, axios_1.default.delete(url, {
|
185
|
-
headers: __assign({ "Content-Type": "application/json", "Ocp-Apim-Subscription-Key":
|
201
|
+
headers: __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) }))
|
186
202
|
})];
|
187
203
|
case 1:
|
188
204
|
response = _h.sent();
|
package/lib/utils/utils.d.ts
CHANGED
@@ -12,3 +12,10 @@ export declare const getISOStringWithoutGMT: (date: Date | string | null | undef
|
|
12
12
|
* @returns True if the value is null or undefined, false otherwise
|
13
13
|
*/
|
14
14
|
export declare const isNullOrUndefined: (value: any) => boolean;
|
15
|
+
/**
|
16
|
+
* This method check whether the input string is null, undefined, or made only by white spaces.
|
17
|
+
* It is the equivalent of C# method string.IsNullOrWhiteSpace used in the backend.
|
18
|
+
* @param {string | null | undefined} input the string to be tested
|
19
|
+
* @returns {boolean} true if the string is null, undefined, or made only by white spaces, false otherwise
|
20
|
+
*/
|
21
|
+
export declare const isNullOrWhiteSpace: (input: string | null | undefined) => boolean;
|
package/lib/utils/utils.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.isNullOrUndefined = exports.getISOStringWithoutGMT = void 0;
|
3
|
+
exports.isNullOrWhiteSpace = exports.isNullOrUndefined = exports.getISOStringWithoutGMT = void 0;
|
4
4
|
/**
|
5
5
|
* This method return the ISO string of the date without GMT. An ISO string looks like this: YYYY-MM-DDThh:mm:ss.mmmZ
|
6
6
|
* @param {Date | string} date the date to convert
|
@@ -24,3 +24,13 @@ exports.getISOStringWithoutGMT = getISOStringWithoutGMT;
|
|
24
24
|
*/
|
25
25
|
var isNullOrUndefined = function (value) { return value === null || value === undefined; };
|
26
26
|
exports.isNullOrUndefined = isNullOrUndefined;
|
27
|
+
/**
|
28
|
+
* This method check whether the input string is null, undefined, or made only by white spaces.
|
29
|
+
* It is the equivalent of C# method string.IsNullOrWhiteSpace used in the backend.
|
30
|
+
* @param {string | null | undefined} input the string to be tested
|
31
|
+
* @returns {boolean} true if the string is null, undefined, or made only by white spaces, false otherwise
|
32
|
+
*/
|
33
|
+
var isNullOrWhiteSpace = function (input) {
|
34
|
+
return input === null || input === undefined || input.trim() === "";
|
35
|
+
};
|
36
|
+
exports.isNullOrWhiteSpace = isNullOrWhiteSpace;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "mts-booking-library",
|
3
|
-
"version": "1.3.
|
3
|
+
"version": "1.3.11",
|
4
4
|
"description": "Library for using MyTicketSolution Booking API",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"types": "lib/index.d.ts",
|
@@ -18,8 +18,8 @@
|
|
18
18
|
"devDependencies": {
|
19
19
|
"@types/jest": "^29.5.12",
|
20
20
|
"jest": "^29.7.0",
|
21
|
-
"prettier": "^3.
|
22
|
-
"ts-jest": "^29.1.
|
21
|
+
"prettier": "^3.3.0",
|
22
|
+
"ts-jest": "^29.1.4",
|
23
23
|
"typescript": "^5.4.5"
|
24
24
|
},
|
25
25
|
"files": [
|
@@ -32,7 +32,7 @@
|
|
32
32
|
"author": "Infoservice s.r.l.",
|
33
33
|
"dependencies": {
|
34
34
|
"@react-native-async-storage/async-storage": "^1.23.1",
|
35
|
-
"axios": "^1.
|
35
|
+
"axios": "^1.7.2",
|
36
36
|
"dotenv": "^16.4.5",
|
37
37
|
"node-localstorage": "^3.0.5",
|
38
38
|
"zustand": "^4.5.2"
|