Skip to content

Commit

Permalink
Merge pull request #641 from Travelport-Ukraine/master
Browse files Browse the repository at this point in the history
Release 1.16.1
  • Loading branch information
dchertousov committed Oct 26, 2023
2 parents 3ba750a + f8f6f2c commit bff8ec6
Show file tree
Hide file tree
Showing 38 changed files with 3,732 additions and 2,062 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://registry.npmjs.org/
4,740 changes: 3,141 additions & 1,599 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uapi-json",
"version": "1.16.0",
"version": "1.16.1",
"description": "Travelport Universal API",
"main": "src/",
"files": [
Expand Down Expand Up @@ -49,14 +49,14 @@
},
"devDependencies": {
"chai": "^4.3.7",
"eslint": "^8.29.0",
"eslint-config-airbnb-base": "^13.2.0",
"eslint-plugin-import": "^2.25.3",
"eslint": "^8.39.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.29.0",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"proxyquire": "^2.1.3",
"readline2": "^1.0.1",
"sinon": "^15.0.1",
"sinon": "^16.1.1",
"sinon-chai": "^3.7.0"
}
}
1 change: 0 additions & 1 deletion src/Request/default-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ module.exports = function defaultConfig(ver) {
// air:AirSegment
// universal:ProviderReservationInfo


// Some single-object arrays with one key can be safely collapsed into an object or a scalar,
// because they would never have a second item or any more fields in objects
// NOTE: if such array name ends in list, e.g. FlightOptionsList (with FlightOption item),
Expand Down
16 changes: 8 additions & 8 deletions src/Request/uapi-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const {
RequestRuntimeError,
} = require('./RequestErrors');

const parseString = xml => new Promise((resolve, reject) => {
const parseString = (xml) => new Promise((resolve, reject) => {
xml2js.parseString(xml, (err, json) => {
if (err) {
reject(err);
Expand All @@ -33,7 +33,7 @@ function mergeLeaf(item) {
delete (item.$);
// item.renameProperty('_', 'text'); //TODO decide if _ is the best name

return Object.assign({}, item, leaf);
return { ...item, ...leaf };
}

function Parser(root, uapiVersion, env, debug, config, provider) {
Expand Down Expand Up @@ -71,7 +71,7 @@ Parser.prototype.mapArrayKeys = function mapArrayKeys(array, name) {
}

if (!hasAllKeys) {
return array.map(value => self.mergeLeafRecursive(value, name /* + ':' + key */));
return array.map((value) => self.mergeLeafRecursive(value, name /* + ':' + key */));
}

const object = array
Expand Down Expand Up @@ -155,18 +155,18 @@ Parser.prototype.parseVersion = function (obj) {
const detail = obj['SOAP:Fault'][0].detail[0];
const parsedVersions = Object.keys(detail)
.filter(
key => key.match(/ErrorInfo$/i)
(key) => key.match(/ErrorInfo$/i)
)
.reduce(
(acc, key) => acc.concat(
Object.keys(detail[key][0].$)
.filter(detailKey => detailKey.match(/^xmlns/i))
.map(detailKey => detail[key][0].$[detailKey])
.filter((detailKey) => detailKey.match(/^xmlns/i))
.map((detailKey) => detail[key][0].$[detailKey])
),
[]
)
.map(xmlns => xmlns.match(/_(v\d+_\d+)$/))
.filter(version => version !== null);
.map((xmlns) => xmlns.match(/_(v\d+_\d+)$/))
.filter((version) => version !== null);
return parsedVersions[0][1];
};

Expand Down
5 changes: 2 additions & 3 deletions src/Request/uapi-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,13 @@ module.exports = function uapiRequest(
return result;
};


return validateInput()
.then(handlebars.compile)
.then(template => prepareRequest(template, auth, params))
.then((template) => prepareRequest(template, auth, params))
.then(sendRequest)
.then(parseResponse)
.then(validateSOAP)
.then(res => parseFunction.call(uParser, res, params))
.then((res) => parseFunction.call(uParser, res, params))
.then(handleSuccess);
};
};
40 changes: 21 additions & 19 deletions src/Services/Air/Air.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ module.exports = (settings) => {
),
};

return service.addSegments(Object.assign({}, options, missedOptions));
return service.addSegments({ ...options, ...missedOptions });
});
}

Expand All @@ -74,10 +74,12 @@ module.exports = (settings) => {
return service.airPricePricingSolutionXML(options).then((data) => {
const tauDate = moment(options.tau || null);
const tau = tauDate.isValid() ? tauDate.format() : moment().add(3, 'hours').format();
const bookingParams = Object.assign({}, {
const bookingParams = {
ticketDate: tau,
ActionStatusType: 'TAU',
}, data, options);
...data,
...options
};
return service.createReservation(bookingParams).catch((err) => {
if (err instanceof AirRuntimeError.SegmentBookingFailed
|| err instanceof AirRuntimeError.NoValidFare) {
Expand All @@ -97,7 +99,7 @@ module.exports = (settings) => {
getBooking(options) {
return this.getUniversalRecordByPNR(options)
.then(
ur => getBookingFromUr(ur, options.pnr)
(ur) => getBookingFromUr(ur, options.pnr)
|| Promise.reject(new AirRuntimeError.NoPNRFoundInUR(ur))
)
.then((data) => {
Expand Down Expand Up @@ -186,7 +188,7 @@ module.exports = (settings) => {
.catch((err) => {
if (err instanceof AirRuntimeError.TicketingFoidRequired) {
return this.getBooking(options)
.then(updatedBooking => service.foid(updatedBooking))
.then((updatedBooking) => service.foid(updatedBooking))
.then(() => again(err));
}
if (err instanceof AirRuntimeError.TicketingPNRBusy) {
Expand All @@ -206,7 +208,7 @@ module.exports = (settings) => {

async getTicketFromTicketsList(pnr, ticketNumber) {
const tickets = await this.getTickets({ pnr });
return tickets.find(t => t.ticketNumber === ticketNumber);
return tickets.find((t) => t.ticketNumber === ticketNumber);
},

retryableTicketErrorHandlers: {
Expand Down Expand Up @@ -250,7 +252,7 @@ module.exports = (settings) => {
}
}));

const [ticket = null] = results.filter(result => result);
const [ticket = null] = results.filter((result) => result);
return ticket;
}
},
Expand Down Expand Up @@ -331,7 +333,7 @@ module.exports = (settings) => {
.then(() => ({ ...line, pnr }));
});
}))
.then(data => ({ type: 'list', data }));
.then((data) => ({ type: 'list', data }));
}

const pnr = parsers.bookingPnr(firstScreen);
Expand All @@ -346,21 +348,21 @@ module.exports = (settings) => {
new AirRuntimeError.MissingPaxListAndBooking(firstScreen)
);
})
.then(results => terminal.closeSession()
.then((results) => terminal.closeSession()
.then(() => results)
.catch(() => results));
},

cancelTicket(options) {
return this.getTicket(options)
.then(
ticketData => service.cancelTicket({
(ticketData) => service.cancelTicket({
pnr: ticketData.pnr,
ticketNumber: options.ticketNumber,
})
)
.catch(
err => Promise.reject(new AirRuntimeError.FailedToCancelTicket(options, err))
(err) => Promise.reject(new AirRuntimeError.FailedToCancelTicket(options, err))
);
},

Expand All @@ -371,12 +373,12 @@ module.exports = (settings) => {
pnr,
} = options;

const checkTickets = tickets => Promise.all(tickets.map(
const checkTickets = (tickets) => Promise.all(tickets.map(
(ticketData) => {
// Check for VOID or REFUND
const allTicketsVoidOrRefund = ticketData.tickets.every(
ticket => ticket.coupons.every(
coupon => coupon.status === 'V' || coupon.status === 'R'
(ticket) => ticket.coupons.every(
(coupon) => coupon.status === 'V' || coupon.status === 'R'
)
);

Expand All @@ -389,8 +391,8 @@ module.exports = (settings) => {
}
// Check for not OPEN/VOID segments
const hasNotOpenSegment = ticketData.tickets.some(
ticket => ticket.coupons.some(
coupon => 'OV'.indexOf(coupon.status) === -1
(ticket) => ticket.coupons.some(
(coupon) => 'OV'.indexOf(coupon.status) === -1
)
);

Expand All @@ -400,7 +402,7 @@ module.exports = (settings) => {

return Promise.all(
ticketData.tickets.map(
ticket => (
(ticket) => (
ticket.coupons[0].status !== 'V'
? service.cancelTicket({ pnr, ticketNumber: ticket.ticketNumber })
: Promise.resolve(true)
Expand Down Expand Up @@ -431,15 +433,15 @@ module.exports = (settings) => {

getExchangeInformation(options) {
return this.getBooking(options)
.then(booking => service.exchangeQuote({
.then((booking) => service.exchangeQuote({
...options,
bookingDate: moment(booking.createdAt).format('YYYY-MM-DD'),
}));
},

exchangeBooking(options) {
return this.getBooking(options)
.then(booking => service.exchangeBooking({
.then((booking) => service.exchangeBooking({
...options,
uapi_reservation_locator: booking.uapi_reservation_locator,
}));
Expand Down
1 change: 1 addition & 0 deletions src/Services/Air/AirErrors.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ Object.assign(AirParsingError, createErrorsList({
CancelResponseNotFound: 'Cancel response not found',
InvalidServiceSegmentFormat: 'Service segment format is invalid',
NoProviderSegmentOrder: 'Segment is missing ProviderSegmentOrder field',
NoTravelOrder: 'Segment is missing TravelOrder field',
}, AirParsingError));

// Runtime errors
Expand Down
Loading

0 comments on commit bff8ec6

Please sign in to comment.