uapi-json 1.16.0 → 1.16.1
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/package.json +5 -5
- package/src/Request/default-config.js +0 -1
- package/src/Request/uapi-parser.js +8 -8
- package/src/Request/uapi-request.js +2 -3
- package/src/Services/Air/Air.js +21 -19
- package/src/Services/Air/AirErrors.js +1 -0
- package/src/Services/Air/AirFormat.js +71 -45
- package/src/Services/Air/AirParser.js +150 -175
- package/src/Services/Air/AirValidator.js +2 -2
- package/src/Services/Air/validators/carriers.js +1 -1
- package/src/Services/Air/validators/connections.js +2 -2
- package/src/Services/Hotels/HotelsParser.js +7 -9
- package/src/Services/Hotels/HotelsValidator.js +0 -2
- package/src/Services/Terminal/Terminal.js +6 -6
- package/src/Services/Utils/UtilsParser.js +1 -2
- package/src/utils/beautify-name.js +1 -1
- package/src/utils/clone.js +1 -1
- package/src/utils/compose.js +1 -1
- package/src/utils/deflate-promise.js +1 -1
- package/src/utils/first-in-obj.js +1 -1
- package/src/utils/get-booking-from-ur.js +1 -1
- package/src/utils/inflate-promise.js +1 -1
- package/src/utils/parsers/service-segment.js +10 -12
- package/src/utils/validate.js +1 -1
|
@@ -9,7 +9,6 @@ const {
|
|
|
9
9
|
const amenties = require('./amenties');
|
|
10
10
|
const Utils = require('../../utils');
|
|
11
11
|
|
|
12
|
-
|
|
13
12
|
const getNextResult = (version, obj) => {
|
|
14
13
|
const ref = obj[`common_${version}:NextResultReference`];
|
|
15
14
|
return (ref && ref._) || null;
|
|
@@ -22,7 +21,7 @@ const getHostToken = (version, obj) => {
|
|
|
22
21
|
|
|
23
22
|
const getAmenties = (property) => {
|
|
24
23
|
if (property && property['hotel:Amenities']) {
|
|
25
|
-
return property['hotel:Amenities']['hotel:Amenity'].map(e => ({
|
|
24
|
+
return property['hotel:Amenities']['hotel:Amenity'].map((e) => ({
|
|
26
25
|
[e.Code]: amenties[e.Code],
|
|
27
26
|
}));
|
|
28
27
|
}
|
|
@@ -39,8 +38,8 @@ const getIcon = (version, elem) => {
|
|
|
39
38
|
const getMedia = (version, rate) => {
|
|
40
39
|
if (rate[`common_${version}:MediaItem`]) {
|
|
41
40
|
return rate[`common_${version}:MediaItem`]
|
|
42
|
-
.filter(elem => elem.type !== 'Gallery')
|
|
43
|
-
.map(elem => elem);
|
|
41
|
+
.filter((elem) => elem.type !== 'Gallery')
|
|
42
|
+
.map((elem) => elem);
|
|
44
43
|
}
|
|
45
44
|
return [];
|
|
46
45
|
};
|
|
@@ -50,7 +49,7 @@ const getComments = (rsp) => {
|
|
|
50
49
|
&& rsp['hotel:GuestReviews'][0]
|
|
51
50
|
&& rsp['hotel:GuestReviews'][0]['hotel:Comments']
|
|
52
51
|
) {
|
|
53
|
-
return rsp['hotel:GuestReviews'][0]['hotel:Comments'].map(comment => ({
|
|
52
|
+
return rsp['hotel:GuestReviews'][0]['hotel:Comments'].map((comment) => ({
|
|
54
53
|
text: comment._,
|
|
55
54
|
id: comment.$.CommentId,
|
|
56
55
|
date: comment.$.Date,
|
|
@@ -80,13 +79,13 @@ const searchParse = function (rsp) {
|
|
|
80
79
|
hotel.Description = elem['hotel:PropertyDescription']._;
|
|
81
80
|
hotel.Icon = getIcon(self.uapi_version, elem);
|
|
82
81
|
hotel.HotelRating = property['hotel:HotelRating']['hotel:Rating'] * 1;
|
|
83
|
-
hotel.Rates = elem['hotel:RateInfo'].map(rate => ({
|
|
82
|
+
hotel.Rates = elem['hotel:RateInfo'].map((rate) => ({
|
|
84
83
|
RateSupplier: rate.RateSupplier,
|
|
85
84
|
RateSupplierLogo: rate.RateSupplierLogo,
|
|
86
85
|
PaymentType: rate.PaymentType,
|
|
87
86
|
ApproximateMinimumStayAmount: Utils.price(rate.ApproximateMinimumStayAmount),
|
|
88
87
|
}));
|
|
89
|
-
hotel.Suppliers = hotel.Rates.map(rate => rate.RateSupplier);
|
|
88
|
+
hotel.Suppliers = hotel.Rates.map((rate) => rate.RateSupplier);
|
|
90
89
|
hotel.Amenties = getAmenties(property);
|
|
91
90
|
hotel.Location = {
|
|
92
91
|
lat: property[`common_${self.uapi_version}:CoordinateLocation`].latitude,
|
|
@@ -107,7 +106,6 @@ const rateParse = function (rsp) {
|
|
|
107
106
|
result.HostToken = getHostToken(self.uapi_version, rsp);
|
|
108
107
|
result.Comments = getComments(self.uapi_version, rsp);
|
|
109
108
|
|
|
110
|
-
|
|
111
109
|
result.Agregators = rateobj['hotel:AggregatorHotelDetails'].map((rate) => {
|
|
112
110
|
const agregator = {
|
|
113
111
|
media: getMedia(self.uapi_version, rate),
|
|
@@ -193,7 +191,7 @@ const bookParse = function (rsp) {
|
|
|
193
191
|
|
|
194
192
|
const msg = rsp[`common_${self.uapi_version}:ResponseMessage`] || [];
|
|
195
193
|
|
|
196
|
-
result.ResponseMessages = msg.map(elem => ({
|
|
194
|
+
result.ResponseMessages = msg.map((elem) => ({
|
|
197
195
|
type: elem.Type,
|
|
198
196
|
text: elem._,
|
|
199
197
|
}));
|
|
@@ -34,7 +34,6 @@ Validator.prototype.rooms = function () {
|
|
|
34
34
|
return this;
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
|
|
38
37
|
Validator.prototype.code = function () {
|
|
39
38
|
if (this.params.location) {
|
|
40
39
|
return this;
|
|
@@ -93,7 +92,6 @@ Validator.prototype.hotelCode = function () {
|
|
|
93
92
|
return this;
|
|
94
93
|
};
|
|
95
94
|
|
|
96
|
-
|
|
97
95
|
Validator.prototype.people = function () {
|
|
98
96
|
if (!(this.params.people instanceof Array) || this.params.people.length < 1) {
|
|
99
97
|
throw new HotelsValidationError.TravellersMissing(this.params);
|
|
@@ -24,7 +24,7 @@ const UNEXPECTED_TERMINAL_ERRORS = [
|
|
|
24
24
|
'OPTIONS ERROR',
|
|
25
25
|
];
|
|
26
26
|
|
|
27
|
-
const isFinancialCommand = command => /^F.*/.test(command);
|
|
27
|
+
const isFinancialCommand = (command) => /^F.*/.test(command);
|
|
28
28
|
|
|
29
29
|
// Adding event handler on beforeExit and exit process events to process open terminals
|
|
30
30
|
process.on('beforeExit', () => {
|
|
@@ -132,7 +132,7 @@ module.exports = function (settings) {
|
|
|
132
132
|
? true
|
|
133
133
|
: settings.autoClose;
|
|
134
134
|
|
|
135
|
-
const defaultStopMD = screens => !screenFunctions.hasMore(screens);
|
|
135
|
+
const defaultStopMD = (screens) => !screenFunctions.hasMore(screens);
|
|
136
136
|
const token = settings.auth.token || null;
|
|
137
137
|
|
|
138
138
|
const state = {
|
|
@@ -156,7 +156,7 @@ module.exports = function (settings) {
|
|
|
156
156
|
sessionToken: state.sessionToken,
|
|
157
157
|
command: 'MD',
|
|
158
158
|
}).then(
|
|
159
|
-
mdResponse => (
|
|
159
|
+
(mdResponse) => (
|
|
160
160
|
mdResponse.join('\n') === response.join('\n')
|
|
161
161
|
? processedResponse
|
|
162
162
|
: processResponse(mdResponse, stopMD, processedResponse)
|
|
@@ -209,7 +209,7 @@ module.exports = function (settings) {
|
|
|
209
209
|
.catch(reject);
|
|
210
210
|
});
|
|
211
211
|
// Get terminal ID
|
|
212
|
-
const getTerminalId = sessionToken => getHashSubstr(sessionToken);
|
|
212
|
+
const getTerminalId = (sessionToken) => getHashSubstr(sessionToken);
|
|
213
213
|
|
|
214
214
|
const terminal = {
|
|
215
215
|
getToken: getSessionToken,
|
|
@@ -234,7 +234,7 @@ module.exports = function (settings) {
|
|
|
234
234
|
terminalState: TERMINAL_STATE_READY,
|
|
235
235
|
});
|
|
236
236
|
|
|
237
|
-
if (UNEXPECTED_TERMINAL_ERRORS.some(e => response.includes(e))) {
|
|
237
|
+
if (UNEXPECTED_TERMINAL_ERRORS.some((e) => response.includes(e))) {
|
|
238
238
|
const errorObject = isFinancialCommand(command)
|
|
239
239
|
? new TerminalRuntimeError.TerminalUnexpectedFinancialError({ screen: response })
|
|
240
240
|
: new TerminalRuntimeError.TerminalUnexpectedError({ screen: response });
|
|
@@ -252,7 +252,7 @@ module.exports = function (settings) {
|
|
|
252
252
|
},
|
|
253
253
|
closeSession: () => getSessionToken()
|
|
254
254
|
.then(
|
|
255
|
-
sessionToken => service.closeSession({
|
|
255
|
+
(sessionToken) => service.closeSession({
|
|
256
256
|
sessionToken,
|
|
257
257
|
})
|
|
258
258
|
).then(
|
|
@@ -6,10 +6,9 @@ const {
|
|
|
6
6
|
RequestRuntimeError,
|
|
7
7
|
} = require('../../Request/RequestErrors');
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
function currencyConvertParse(json) {
|
|
11
10
|
try {
|
|
12
|
-
json = json['util:CurrencyConversion'].map(curr => ({
|
|
11
|
+
json = json['util:CurrencyConversion'].map((curr) => ({
|
|
13
12
|
from: curr.From,
|
|
14
13
|
to: curr.To,
|
|
15
14
|
rate: parseFloat(curr.BankSellingRate),
|
|
@@ -2,7 +2,7 @@ module.exports = (string) => {
|
|
|
2
2
|
if (Object.prototype.toString.apply(string) !== '[object String]') {
|
|
3
3
|
return null;
|
|
4
4
|
}
|
|
5
|
-
return string.split(' ').map(name => (
|
|
5
|
+
return string.split(' ').map((name) => (
|
|
6
6
|
name[0].toUpperCase() + name.slice(1).toLowerCase()
|
|
7
7
|
)).join(' ');
|
|
8
8
|
};
|
package/src/utils/clone.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = obj => JSON.parse(JSON.stringify(obj));
|
|
1
|
+
module.exports = (obj) => JSON.parse(JSON.stringify(obj));
|
package/src/utils/compose.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = obj => obj && obj[Object.keys(obj)[0]];
|
|
1
|
+
module.exports = (obj) => obj && obj[Object.keys(obj)[0]];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const zlib = require('zlib');
|
|
2
2
|
|
|
3
|
-
module.exports = stringBuffer => new Promise((resolve, reject) => {
|
|
3
|
+
module.exports = (stringBuffer) => new Promise((resolve, reject) => {
|
|
4
4
|
const buf = Buffer.from(stringBuffer, 'base64');
|
|
5
5
|
zlib.inflate(buf, (err, result) => {
|
|
6
6
|
if (err) {
|
|
@@ -27,19 +27,17 @@ const parse = (string) => {
|
|
|
27
27
|
currency,
|
|
28
28
|
] = match;
|
|
29
29
|
|
|
30
|
-
return
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
},
|
|
39
|
-
documentNumber !== ''
|
|
30
|
+
return {
|
|
31
|
+
rfiCode,
|
|
32
|
+
rfiSubcode,
|
|
33
|
+
feeDescription,
|
|
34
|
+
name,
|
|
35
|
+
amount: Number(amount),
|
|
36
|
+
currency,
|
|
37
|
+
...(documentNumber !== ''
|
|
40
38
|
? { documentNumber: documentNumber.substr(0, 13) }
|
|
41
|
-
: null
|
|
42
|
-
|
|
39
|
+
: null)
|
|
40
|
+
};
|
|
43
41
|
};
|
|
44
42
|
|
|
45
43
|
module.exports = parse;
|