Skip to content

Commit

Permalink
Merge pull request #215 from Travelport-Ukraine/issue/213
Browse files Browse the repository at this point in the history
Issue/213
  • Loading branch information
shmuga authored Jun 26, 2017
2 parents e2bc449 + 90e6e56 commit 792d521
Show file tree
Hide file tree
Showing 4 changed files with 262 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/Request/uapi-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ function defaultConfig(ver) {
'hotel:AggregatorHotelDetails',
'common_' + ver + ':MediaItem',
'util:CurrencyConversion',
'common_' + ver + ':TaxDetail',
'common_' + ver + ':SupplierLocator',
];

// Non-single field objects don't get collapsed
Expand Down
8 changes: 6 additions & 2 deletions src/Services/Air/AirParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ function extractBookings(obj) {
}
);

const supplierLocator = booking[`common_${this.uapi_version}:SupplierLocator`] || {};
const supplierLocator = booking[`common_${this.uapi_version}:SupplierLocator`] || [];
const trips = booking['air:AirSegment']
? Object.keys(booking['air:AirSegment']).map(
(key) => {
Expand Down Expand Up @@ -605,7 +605,11 @@ function extractBookings(obj) {
version: record.Version,
uapi_ur_locator: record.LocatorCode,
uapi_reservation_locator: booking.LocatorCode,
uapi_airline_locator: supplierLocator.SupplierLocatorCode || null,
airlineLocatorInfo: supplierLocator.map(info => ({
createDate: info.CreateDateTime,
supplierCode: info.SupplierCode,
locatorCode: info.SupplierLocatorCode,
})),
pnrList: [providerInfo.LocatorCode],
createdAt: providerInfo.CreateDate,
hostCreatedAt: providerInfo.HostCreateDate,
Expand Down
24 changes: 22 additions & 2 deletions test/Air/AirParser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -633,13 +633,23 @@ describe('#AirParser', () => {
// Checking object keys
expect(result).to.have.all.keys([
'version', 'uapi_ur_locator', 'uapi_reservation_locator',
'uapi_airline_locator', 'bookingPCC', 'passengers', 'pnr', 'pnrList',
'airlineLocatorInfo', 'bookingPCC', 'passengers', 'pnr', 'pnrList',
'reservations', 'trips', 'hostCreatedAt', 'createdAt', 'modifiedAt', 'type', 'tickets',
]);
expect(result.version).to.be.at.least(0);
expect(result.uapi_ur_locator).to.match(/^[A-Z0-9]{6}$/);
expect(result.uapi_reservation_locator).to.match(/^[A-Z0-9]{6}$/);
expect(result.uapi_airline_locator).to.match(/^[A-Z0-9]{6}$/);
expect(result.airlineLocatorInfo).to.be.an('array');
result.airlineLocatorInfo.forEach((info) => {
expect(info).have.all.keys([
'createDate',
'supplierCode',
'locatorCode',
]);
expect(new Date(info.createDate)).to.be.instanceof(Date);
expect(info.supplierCode).to.match(/^[A-Z0-9]{2}$/);
expect(info.locatorCode).to.match(/^[A-Z0-9]{6}$/);
});
expect(result.bookingPCC).to.match(/^[A-Z0-9]{3,4}$/);
expect(result.pnr).to.match(/^[A-Z0-9]{6}$/);
expect(new Date(result.hostCreatedAt)).to.be.an.instanceof(Date);
Expand Down Expand Up @@ -925,6 +935,16 @@ describe('#AirParser', () => {
});
});

it('should test parsing of universal record import request 2', () => {
const uParser = new ParserUapi('universal:UniversalRecordImportRsp', 'v36_0', { });
const parseFunction = airParser.AIR_IMPORT_REQUEST;
const xml = fs.readFileSync(`${xmlFolder}/UniversalRecordImport2.xml`).toString();
return uParser.parse(xml).then((json) => {
const jsonResult = parseFunction.call(uParser, json);
testBooking(jsonResult, false);
});
});

it('should parse pnr without segments', () => {
const uParser = new ParserUapi('universal:UniversalRecordImportRsp', 'v36_0', {});
const parseFunction = airParser.AIR_IMPORT_REQUEST;
Expand Down
Loading

0 comments on commit 792d521

Please sign in to comment.