mts-booking-library 2.2.2 → 2.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/SubscriptionBooking.d.ts +0 -0
- package/lib/SubscriptionBooking.js +148 -0
- package/lib/booking/booking.d.ts +7 -4
- package/lib/booking/booking.js +7 -11
- package/lib/booking/journeyBooking.d.ts +7 -0
- package/lib/booking/journeyBooking.js +53 -32
- package/lib/booking/serviceBooking.d.ts +7 -0
- package/lib/booking/serviceBooking.js +50 -24
- package/lib/booking/subscriptionBooking.d.ts +2 -1
- package/lib/booking/subscriptionBooking.js +17 -22
- package/lib/booking/tplBooking.d.ts +5 -1
- package/lib/booking/tplBooking.js +49 -27
- package/lib/index.d.ts +1 -0
- package/lib/index.js +0 -3
- package/lib/types/ErrorResponse.d.ts +6 -5
- package/lib/types/common/Cart.d.ts +31 -0
- package/lib/types/tpl/GetTariffsResponse.d.ts +1 -1
- package/lib/utils/apiCall.d.ts +4 -5
- package/lib/utils/apiCall.js +50 -228
- package/lib/utils/testUtils.d.ts +8 -0
- package/lib/utils/testUtils.js +19 -0
- package/package.json +4 -4
package/lib/utils/apiCall.js
CHANGED
@@ -68,43 +68,55 @@ var removeNullError = function (resData) {
|
|
68
68
|
});
|
69
69
|
return filteredResponse;
|
70
70
|
};
|
71
|
-
var
|
72
|
-
var debug, subKey, errorReport;
|
71
|
+
var makeRequest = function (method, url, data, options) { return __awaiter(void 0, void 0, void 0, function () {
|
72
|
+
var debug, subKey, errorReport, axiosConfig, requestFunctions;
|
73
73
|
return __generator(this, function (_a) {
|
74
|
+
if (data && method !== "POST" && method !== "PUT")
|
75
|
+
throw new Error("MTS Library Error! makeRequest: data is not supported for ".concat(method, " calls. url: ").concat(url));
|
74
76
|
debug = (0, config_1.getConfig)().DEBUG;
|
75
77
|
if (debug) {
|
76
|
-
console.log("
|
78
|
+
console.log("".concat(method, "_RequestData"), url);
|
77
79
|
}
|
78
80
|
subKey = (0, config_1.getConfig)().OCP_SUBSCRIPTION_KEY;
|
79
81
|
if ((0, utils_1.isNullOrWhiteSpace)(subKey)) {
|
80
82
|
errorReport = "Sub Key: ".concat(subKey, ", url: ").concat(url, ", access token: ").concat((0, config_1.getConfig)().ACCESS_TOKEN);
|
81
|
-
throw new Error("MTS Library Error!
|
83
|
+
throw new Error("MTS Library Error! makeRequest: missing OCP SUBSCRIPTION KEY! ".concat(errorReport));
|
84
|
+
}
|
85
|
+
axiosConfig = {
|
86
|
+
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 })),
|
87
|
+
signal: options === null || options === void 0 ? void 0 : options.signal
|
88
|
+
};
|
89
|
+
requestFunctions = {
|
90
|
+
GET: function () { return axios_1.default.get(url, axiosConfig); },
|
91
|
+
DELETE: function () { return axios_1.default.delete(url, axiosConfig); },
|
92
|
+
POST: function () { return axios_1.default.post(url, data, axiosConfig); },
|
93
|
+
PUT: function () { return axios_1.default.put(url, data, axiosConfig); }
|
94
|
+
};
|
95
|
+
if (!requestFunctions[method]) {
|
96
|
+
throw new Error("MTS Library Error! makeRequest: unsupported method ".concat(method));
|
82
97
|
}
|
83
98
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
|
84
|
-
var response, filteredResponse, error_1, message, resError, resError;
|
85
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
86
|
-
return __generator(this, function (
|
87
|
-
switch (
|
99
|
+
var response, filteredResponse, error_1, message, status_1, isAzureMaintenance, resError, resError;
|
100
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
101
|
+
return __generator(this, function (_m) {
|
102
|
+
switch (_m.label) {
|
88
103
|
case 0:
|
89
|
-
|
90
|
-
return [4 /*yield*/,
|
91
|
-
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 })),
|
92
|
-
signal: options === null || options === void 0 ? void 0 : options.signal
|
93
|
-
})];
|
104
|
+
_m.trys.push([0, 2, , 3]);
|
105
|
+
return [4 /*yield*/, requestFunctions[method]()];
|
94
106
|
case 1:
|
95
|
-
response =
|
107
|
+
response = _m.sent();
|
96
108
|
filteredResponse = removeNullError(response.data);
|
97
109
|
if (debug) {
|
98
|
-
console.log("
|
110
|
+
console.log("".concat(method, "_ResponseData"), url, filteredResponse);
|
99
111
|
}
|
100
112
|
resolve(filteredResponse);
|
101
113
|
return [3 /*break*/, 3];
|
102
114
|
case 2:
|
103
|
-
error_1 =
|
115
|
+
error_1 = _m.sent();
|
104
116
|
if (axios_1.default.isCancel(error_1)) {
|
105
117
|
// Log cancellation
|
106
118
|
if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST)
|
107
|
-
console.log("
|
119
|
+
console.log("".concat(method, "_RequestCanceled"), url);
|
108
120
|
// Resolve with empty object
|
109
121
|
resolve({});
|
110
122
|
}
|
@@ -112,20 +124,22 @@ var makeGet = function (url, options) { return __awaiter(void 0, void 0, void 0,
|
|
112
124
|
message = ((_b = (_a = error_1.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error)
|
113
125
|
? error_1.response.data.error.message
|
114
126
|
: (_d = (_c = error_1.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.message;
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
127
|
+
status_1 = ((_e = error_1.response) === null || _e === void 0 ? void 0 : _e.status) || 0;
|
128
|
+
isAzureMaintenance = status_1 === 403
|
129
|
+
? !((_f = error_1.response) === null || _f === void 0 ? void 0 : _f.data.error) &&
|
130
|
+
!!(((_g = error_1.response) === null || _g === void 0 ? void 0 : _g.data.includes("Web App - Unavailable")) ||
|
131
|
+
((_h = error_1.response) === null || _h === void 0 ? void 0 : _h.data.includes("Site Disabled")))
|
132
|
+
: undefined;
|
133
|
+
resError = __assign({ httpStatus: status_1, mtsCode: ((_l = (_k = (_j = error_1.response) === null || _j === void 0 ? void 0 : _j.data) === null || _k === void 0 ? void 0 : _k.error) === null || _l === void 0 ? void 0 : _l.code) || 0, message: message || "Unknown error" }, (isAzureMaintenance !== undefined && { isAzureMaintenance: isAzureMaintenance }));
|
120
134
|
if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
|
121
|
-
console.log("
|
135
|
+
console.log("".concat(method, "_ResponseAxiosError"), url, resError);
|
122
136
|
}
|
123
137
|
reject(resError);
|
124
138
|
}
|
125
139
|
else {
|
126
140
|
resError = __assign(__assign({}, error_1), { httpStatus: 0, mtsCode: 0, message: "Unknown error" });
|
127
141
|
if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
|
128
|
-
console.log("
|
142
|
+
console.log("".concat(method, "_ResponseError"), url, resError);
|
129
143
|
}
|
130
144
|
reject(resError);
|
131
145
|
}
|
@@ -136,211 +150,19 @@ var makeGet = function (url, options) { return __awaiter(void 0, void 0, void 0,
|
|
136
150
|
}); })];
|
137
151
|
});
|
138
152
|
}); };
|
153
|
+
var makeGet = function (url, options) {
|
154
|
+
return makeRequest("GET", url, undefined, options);
|
155
|
+
};
|
139
156
|
exports.makeGet = makeGet;
|
140
|
-
var makePost = function (url, data, options) { return __awaiter(void 0, void 0, void 0, function () {
|
141
|
-
|
142
|
-
|
143
|
-
debug = (0, config_1.getConfig)().DEBUG;
|
144
|
-
if (debug) {
|
145
|
-
console.log("POST_RequestData", url, data);
|
146
|
-
}
|
147
|
-
subKey = (0, config_1.getConfig)().OCP_SUBSCRIPTION_KEY;
|
148
|
-
if ((0, utils_1.isNullOrWhiteSpace)(subKey)) {
|
149
|
-
errorReport = "Sub Key: ".concat(subKey, ", url: ").concat(url, ", access token: ").concat((0, config_1.getConfig)().ACCESS_TOKEN);
|
150
|
-
throw new Error("MTS Library Error! makePost: missing OCP SUBSCRIPTION KEY! ".concat(errorReport));
|
151
|
-
}
|
152
|
-
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
|
153
|
-
var response, filteredResponse, error_2, message, resError, resError;
|
154
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
155
|
-
return __generator(this, function (_j) {
|
156
|
-
switch (_j.label) {
|
157
|
-
case 0:
|
158
|
-
_j.trys.push([0, 2, , 3]);
|
159
|
-
return [4 /*yield*/, axios_1.default.post(url, data, {
|
160
|
-
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 })),
|
161
|
-
signal: options === null || options === void 0 ? void 0 : options.signal
|
162
|
-
})];
|
163
|
-
case 1:
|
164
|
-
response = _j.sent();
|
165
|
-
filteredResponse = removeNullError(response.data);
|
166
|
-
if (debug) {
|
167
|
-
console.log("POST_ResponseData", url, filteredResponse);
|
168
|
-
}
|
169
|
-
resolve(filteredResponse);
|
170
|
-
return [3 /*break*/, 3];
|
171
|
-
case 2:
|
172
|
-
error_2 = _j.sent();
|
173
|
-
if (axios_1.default.isCancel(error_2)) {
|
174
|
-
// Log cancellation
|
175
|
-
if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST)
|
176
|
-
console.log("POST_RequestCanceled", url);
|
177
|
-
// Resolve with empty object
|
178
|
-
resolve({});
|
179
|
-
}
|
180
|
-
else if (axios_1.default.isAxiosError(error_2)) {
|
181
|
-
message = ((_b = (_a = error_2.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error)
|
182
|
-
? error_2.response.data.error.message
|
183
|
-
: (_d = (_c = error_2.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.message;
|
184
|
-
resError = {
|
185
|
-
httpStatus: ((_e = error_2.response) === null || _e === void 0 ? void 0 : _e.status) || 0,
|
186
|
-
mtsCode: ((_h = (_g = (_f = error_2.response) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.error) === null || _h === void 0 ? void 0 : _h.code) || 0,
|
187
|
-
message: message || "Unknown error"
|
188
|
-
};
|
189
|
-
if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
|
190
|
-
console.log("POST_ResponseAxiosError", url, resError);
|
191
|
-
}
|
192
|
-
reject(resError);
|
193
|
-
}
|
194
|
-
else {
|
195
|
-
resError = __assign(__assign({}, error_2), { httpStatus: 0, mtsCode: 0, message: "Unknown error" });
|
196
|
-
if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
|
197
|
-
console.log("POST_ResponseError", url, resError);
|
198
|
-
}
|
199
|
-
reject(resError);
|
200
|
-
}
|
201
|
-
return [3 /*break*/, 3];
|
202
|
-
case 3: return [2 /*return*/];
|
203
|
-
}
|
204
|
-
});
|
205
|
-
}); })];
|
206
|
-
});
|
207
|
-
}); };
|
157
|
+
var makePost = function (url, data, options) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
158
|
+
return [2 /*return*/, makeRequest("POST", url, data, options)];
|
159
|
+
}); }); };
|
208
160
|
exports.makePost = makePost;
|
209
|
-
var makePut = function (url, data, options) { return __awaiter(void 0, void 0, void 0, function () {
|
210
|
-
|
211
|
-
|
212
|
-
debug = (0, config_1.getConfig)().DEBUG;
|
213
|
-
if (debug) {
|
214
|
-
console.log("PUT_RequestData", url, data);
|
215
|
-
}
|
216
|
-
subKey = (0, config_1.getConfig)().OCP_SUBSCRIPTION_KEY;
|
217
|
-
if ((0, utils_1.isNullOrWhiteSpace)(subKey)) {
|
218
|
-
errorReport = "Sub Key: ".concat(subKey, ", url: ").concat(url, ", access token: ").concat((0, config_1.getConfig)().ACCESS_TOKEN);
|
219
|
-
throw new Error("MTS Library Error! makePut: missing OCP SUBSCRIPTION KEY! ".concat(errorReport));
|
220
|
-
}
|
221
|
-
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
|
222
|
-
var response, filteredResponse, error_3, message, resError, resError;
|
223
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
224
|
-
return __generator(this, function (_j) {
|
225
|
-
switch (_j.label) {
|
226
|
-
case 0:
|
227
|
-
_j.trys.push([0, 2, , 3]);
|
228
|
-
return [4 /*yield*/, axios_1.default.put(url, data, {
|
229
|
-
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 })),
|
230
|
-
signal: options === null || options === void 0 ? void 0 : options.signal
|
231
|
-
})];
|
232
|
-
case 1:
|
233
|
-
response = _j.sent();
|
234
|
-
filteredResponse = removeNullError(response.data);
|
235
|
-
if (debug) {
|
236
|
-
console.log("PUT_ResponseData", url, filteredResponse);
|
237
|
-
}
|
238
|
-
resolve(filteredResponse);
|
239
|
-
return [3 /*break*/, 3];
|
240
|
-
case 2:
|
241
|
-
error_3 = _j.sent();
|
242
|
-
if (axios_1.default.isCancel(error_3)) {
|
243
|
-
// Log cancellation
|
244
|
-
if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST)
|
245
|
-
console.log("PUT_RequestCanceled", url);
|
246
|
-
// Resolve with empty object
|
247
|
-
resolve({});
|
248
|
-
}
|
249
|
-
else if (axios_1.default.isAxiosError(error_3)) {
|
250
|
-
message = ((_b = (_a = error_3.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error)
|
251
|
-
? error_3.response.data.error.message
|
252
|
-
: (_d = (_c = error_3.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.message;
|
253
|
-
resError = {
|
254
|
-
httpStatus: ((_e = error_3.response) === null || _e === void 0 ? void 0 : _e.status) || 0,
|
255
|
-
mtsCode: ((_h = (_g = (_f = error_3.response) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.error) === null || _h === void 0 ? void 0 : _h.code) || 0,
|
256
|
-
message: message || "Unknown error"
|
257
|
-
};
|
258
|
-
if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
|
259
|
-
console.log("PUT_ResponseAxiosError", url, resError);
|
260
|
-
}
|
261
|
-
reject(resError);
|
262
|
-
}
|
263
|
-
else {
|
264
|
-
resError = __assign(__assign({}, error_3), { httpStatus: 0, mtsCode: 0, message: "Unknown error" });
|
265
|
-
if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
|
266
|
-
console.log("PUT_ResponseError", url, resError);
|
267
|
-
}
|
268
|
-
reject(resError);
|
269
|
-
}
|
270
|
-
return [3 /*break*/, 3];
|
271
|
-
case 3: return [2 /*return*/];
|
272
|
-
}
|
273
|
-
});
|
274
|
-
}); })];
|
275
|
-
});
|
276
|
-
}); };
|
161
|
+
var makePut = function (url, data, options) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
162
|
+
return [2 /*return*/, makeRequest("PUT", url, data, options)];
|
163
|
+
}); }); };
|
277
164
|
exports.makePut = makePut;
|
278
|
-
var makeDelete = function (url, options) { return __awaiter(void 0, void 0, void 0, function () {
|
279
|
-
|
280
|
-
|
281
|
-
debug = (0, config_1.getConfig)().DEBUG;
|
282
|
-
if (debug) {
|
283
|
-
console.log("DELETE_RequestData", url);
|
284
|
-
}
|
285
|
-
subKey = (0, config_1.getConfig)().OCP_SUBSCRIPTION_KEY;
|
286
|
-
if ((0, utils_1.isNullOrWhiteSpace)(subKey)) {
|
287
|
-
errorReport = "Sub Key: ".concat(subKey, ", url: ").concat(url, ", access token: ").concat((0, config_1.getConfig)().ACCESS_TOKEN);
|
288
|
-
throw new Error("MTS Library Error! makeDelete: missing OCP SUBSCRIPTION KEY! ".concat(errorReport));
|
289
|
-
}
|
290
|
-
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
|
291
|
-
var response, filteredResponse, error_4, message, resError, resError;
|
292
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
293
|
-
return __generator(this, function (_j) {
|
294
|
-
switch (_j.label) {
|
295
|
-
case 0:
|
296
|
-
_j.trys.push([0, 2, , 3]);
|
297
|
-
return [4 /*yield*/, axios_1.default.delete(url, {
|
298
|
-
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 })),
|
299
|
-
signal: options === null || options === void 0 ? void 0 : options.signal
|
300
|
-
})];
|
301
|
-
case 1:
|
302
|
-
response = _j.sent();
|
303
|
-
filteredResponse = removeNullError(response.data);
|
304
|
-
if (debug) {
|
305
|
-
console.log("DELETE_ResponseData", url, filteredResponse);
|
306
|
-
}
|
307
|
-
resolve(filteredResponse);
|
308
|
-
return [3 /*break*/, 3];
|
309
|
-
case 2:
|
310
|
-
error_4 = _j.sent();
|
311
|
-
if (axios_1.default.isCancel(error_4)) {
|
312
|
-
// Log cancellation
|
313
|
-
if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST)
|
314
|
-
console.log("DELETE_RequestCanceled", url);
|
315
|
-
// Resolve with empty object
|
316
|
-
resolve({});
|
317
|
-
}
|
318
|
-
else if (axios_1.default.isAxiosError(error_4)) {
|
319
|
-
message = ((_b = (_a = error_4.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error)
|
320
|
-
? error_4.response.data.error.message
|
321
|
-
: (_d = (_c = error_4.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.message;
|
322
|
-
resError = {
|
323
|
-
httpStatus: ((_e = error_4.response) === null || _e === void 0 ? void 0 : _e.status) || 0,
|
324
|
-
mtsCode: ((_h = (_g = (_f = error_4.response) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.error) === null || _h === void 0 ? void 0 : _h.code) || 0,
|
325
|
-
message: message || "Unknown error"
|
326
|
-
};
|
327
|
-
if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
|
328
|
-
console.log("DELETE_ResponseAxiosError", url, resError);
|
329
|
-
}
|
330
|
-
reject(resError);
|
331
|
-
}
|
332
|
-
else {
|
333
|
-
resError = __assign(__assign({}, error_4), { httpStatus: 0, mtsCode: 0, message: "Unknown error" });
|
334
|
-
if (debug || (0, config_1.getConfig)().ENV === config_1.MTSEnvs.TEST) {
|
335
|
-
console.log("DELETE_ResponseError", url, resError);
|
336
|
-
}
|
337
|
-
reject(resError);
|
338
|
-
}
|
339
|
-
return [3 /*break*/, 3];
|
340
|
-
case 3: return [2 /*return*/];
|
341
|
-
}
|
342
|
-
});
|
343
|
-
}); })];
|
344
|
-
});
|
345
|
-
}); };
|
165
|
+
var makeDelete = function (url, options) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
166
|
+
return [2 /*return*/, makeRequest("DELETE", url, undefined, options)];
|
167
|
+
}); }); };
|
346
168
|
exports.makeDelete = makeDelete;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
/**
|
2
|
+
* This method return the ISO string of the date without GMT. An ISO string looks like this: YYYY-MM-DDThh:mm:ss.mmmZ
|
3
|
+
* @param {Date | string} date the date to convert
|
4
|
+
* @param {boolean} [removeTimezone=true] if true, the timezone will be removed from the ISO string, meaning
|
5
|
+
* that the string will look like this: YYYY-MM-DDThh:mm:ss.mmm
|
6
|
+
* @returns {string} the ISO string
|
7
|
+
*/
|
8
|
+
export declare const getISOStringWithoutGMT: (date: Date | string | null | undefined, removeTimezone?: boolean) => string | null;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getISOStringWithoutGMT = void 0;
|
4
|
+
/**
|
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
|
+
* @param {Date | string} date the date to convert
|
7
|
+
* @param {boolean} [removeTimezone=true] if true, the timezone will be removed from the ISO string, meaning
|
8
|
+
* that the string will look like this: YYYY-MM-DDThh:mm:ss.mmm
|
9
|
+
* @returns {string} the ISO string
|
10
|
+
*/
|
11
|
+
var getISOStringWithoutGMT = function (date, removeTimezone) {
|
12
|
+
if (removeTimezone === void 0) { removeTimezone = true; }
|
13
|
+
if (!date)
|
14
|
+
return null;
|
15
|
+
var newDate = new Date(date);
|
16
|
+
var isoString = new Date(newDate.valueOf() - newDate.getTimezoneOffset() * 60000).toISOString();
|
17
|
+
return removeTimezone ? isoString.slice(0, -1) : isoString;
|
18
|
+
};
|
19
|
+
exports.getISOStringWithoutGMT = getISOStringWithoutGMT;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "mts-booking-library",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.3.0",
|
4
4
|
"description": "Library for using MyTicketSolution Booking API",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"types": "lib/index.d.ts",
|
@@ -16,8 +16,10 @@
|
|
16
16
|
},
|
17
17
|
"license": "ISC",
|
18
18
|
"devDependencies": {
|
19
|
-
"@types/jest": "^29.5.
|
19
|
+
"@types/jest": "^29.5.14",
|
20
|
+
"dotenv": "^16.4.5",
|
20
21
|
"jest": "^29.7.0",
|
22
|
+
"node-localstorage": "^3.0.5",
|
21
23
|
"prettier": "^3.3.3",
|
22
24
|
"ts-jest": "^29.2.5",
|
23
25
|
"typescript": "^5.6.3"
|
@@ -33,8 +35,6 @@
|
|
33
35
|
"dependencies": {
|
34
36
|
"@react-native-async-storage/async-storage": "^2.0.0",
|
35
37
|
"axios": "^1.7.7",
|
36
|
-
"dotenv": "^16.4.5",
|
37
|
-
"node-localstorage": "^3.0.5",
|
38
38
|
"zustand": "^4.5.5"
|
39
39
|
}
|
40
40
|
}
|