Skip to content

Commit

Permalink
Merge pull request #14 from Travelport-Ukraine/fix-pc-import
Browse files Browse the repository at this point in the history
Fix pc import
  • Loading branch information
shmuga authored Sep 22, 2016
2 parents 269a325 + 4561f4c commit c3f90ab
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uapi-json",
"version": "0.2.1",
"version": "0.2.2",
"description": "Travelport Universal API",
"main": "build/",
"files": [
Expand Down
20 changes: 14 additions & 6 deletions src/Air/AirParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ const groupSegmentsByLegs = (segments) => {
return result;
};

const getPlatingCarrier = (booking) => {
let platingCarriers = _.pluck(booking['air:AirPricingInfo'], 'PlatingCarrier').filter(pc => pc);

if (platingCarriers.length === 0) {
// FIXME: use a smart collapse algorithm?
platingCarriers = _.pluck(booking['air:TicketingModifiers'], 'PlatingCarrier');
}

const singlePlatingCarrier = _.uniq(platingCarriers);

return singlePlatingCarrier[0];
};

const searchLowFaresValidate = (obj) => {
// +List, e.g. AirPricePointList, see below
const rootArrays = ['AirPricePoint', 'AirSegment', 'FareInfo', 'FlightDetails', 'Route'];
Expand Down Expand Up @@ -409,12 +422,7 @@ function extractBookings(obj) {
}

// we usually have one plating carrier across all per-passenger reservations
let platingCarriers = _.pluck(booking['air:AirPricingInfo'], 'PlatingCarrier');
const singlePlatingCarrier = _.uniq(platingCarriers);
if (singlePlatingCarrier.length === 1) {
// FIXME: use a smart collapse algorithm?
platingCarriers = singlePlatingCarrier[0];
}
const platingCarriers = getPlatingCarrier(booking);

const passengers = getPassengers.call(
this,
Expand Down
1 change: 1 addition & 0 deletions test/Air/AirParser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ describe('#AirParser', function () {
assert(_.isArray(jsonResult), 'result not array');
jsonResult.forEach(result => {
assert(result.bookingPCC, 'no booking pcc');
assert(result.platingCarrier, 'no PC');
assert(_.isArray(result.passengers), 'passengers is not array');
assert(result.passengers.length);
assert(result.pnr, 'no pnr');
Expand Down

0 comments on commit c3f90ab

Please sign in to comment.