From ffa765073905e04beb7c25097787459e4318dd5a Mon Sep 17 00:00:00 2001 From: Mark Orel Date: Mon, 26 Jun 2017 13:51:16 +0300 Subject: [PATCH 1/2] Fixed error with taxes parsing. --- src/Request/uapi-parser.js | 1 + test/Air/AirParser.test.js | 10 + .../Air/UniversalRecordImport2.xml | 232 ++++++++++++++++++ 3 files changed, 243 insertions(+) create mode 100644 test/FakeResponses/Air/UniversalRecordImport2.xml diff --git a/src/Request/uapi-parser.js b/src/Request/uapi-parser.js index 90a91737..9e773bb7 100644 --- a/src/Request/uapi-parser.js +++ b/src/Request/uapi-parser.js @@ -64,6 +64,7 @@ function defaultConfig(ver) { 'hotel:AggregatorHotelDetails', 'common_' + ver + ':MediaItem', 'util:CurrencyConversion', + 'common_' + ver + ':TaxDetail', ]; // Non-single field objects don't get collapsed diff --git a/test/Air/AirParser.test.js b/test/Air/AirParser.test.js index 4c1ed131..45627e7e 100644 --- a/test/Air/AirParser.test.js +++ b/test/Air/AirParser.test.js @@ -925,6 +925,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; diff --git a/test/FakeResponses/Air/UniversalRecordImport2.xml b/test/FakeResponses/Air/UniversalRecordImport2.xml new file mode 100644 index 00000000..f66ab24f --- /dev/null +++ b/test/FakeResponses/Air/UniversalRecordImport2.xml @@ -0,0 +1,232 @@ + + + + PNR already exists in Universal Record UKF7AJ + Continuity Check - Validate departure/arrival cities for segments Air CHI-YTO UA476 2018-02-02T06:45:00.000-06:00 in 1G and Air IEV-FRA UA9149 2018-02-08T06:00:00.000+02:00 in 1G + Continuity Check - Validate departure/arrival cities for segments Air FRA-IEV AC9207 2018-03-02T09:30:00.000+01:00 in 1G and Air YTO-FRA AC9104 2018-03-10T18:05:00.000-05:00 in 1G + + + + + + + + + + + + + IEV 22JUN1513Z 12 AG + + + + + + + + + + + + + + + + + DEUTSCHE LUFTHANSA AG + + + + + DEUTSCHE LUFTHANSA AG + + + + + + + + DEUTSCHE LUFTHANSA AG + + + + + + DEUTSCHE LUFTHANSA AG + + + + + + + + + + + + LUFTHANSA OR LH CITYLINE + + + + + LUFTHANSA OR LH CITYLINE + + + + + + LUFTHANSA OR LH CITYLINE + + + + + + + + + 1 + + + + + + + 1 + + + + + + + 1 + + + + + + + 1 + + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + IEV UA X/MUC UA X/CHI UA YTO Q IEVYTO320.00 115.00KLNCE37W AC X/FRA AC IEV Q YTOIEV285.00 145.00LLNCUAW NUC865.00END ROE1.0 + + + + + + + + + + + 1 + + + + + + 1 + + + + + + 1 + + + + + + 1 + + + + + + 1 + + + + + + + + + + + + + + + + + + + + + + + + IEV UA X/FRA UA X/E/CHI UA YTO Q IEVYTO320.00M2604.50Y77RT AC X/FRA AC IEV Q YTOIEV285.00M2604.50Y77RT NUC5814.00END ROE1.0 + + + + + + + + + + + + + + + VIEWTRIPITIN + + + + + + + + + + + + + + + From 90e6e56ef2829f984adb2ca91511ea651a645fd3 Mon Sep 17 00:00:00 2001 From: Mark Orel Date: Mon, 26 Jun 2017 13:51:46 +0300 Subject: [PATCH 2/2] Changed airline locator to be array of locator information. Renamed field --- src/Request/uapi-parser.js | 1 + src/Services/Air/AirParser.js | 8 ++++++-- test/Air/AirParser.test.js | 14 ++++++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/Request/uapi-parser.js b/src/Request/uapi-parser.js index 9e773bb7..0f3e4936 100644 --- a/src/Request/uapi-parser.js +++ b/src/Request/uapi-parser.js @@ -65,6 +65,7 @@ function defaultConfig(ver) { 'common_' + ver + ':MediaItem', 'util:CurrencyConversion', 'common_' + ver + ':TaxDetail', + 'common_' + ver + ':SupplierLocator', ]; // Non-single field objects don't get collapsed diff --git a/src/Services/Air/AirParser.js b/src/Services/Air/AirParser.js index 8f048296..c1888e43 100644 --- a/src/Services/Air/AirParser.js +++ b/src/Services/Air/AirParser.js @@ -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) => { @@ -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, diff --git a/test/Air/AirParser.test.js b/test/Air/AirParser.test.js index 45627e7e..b7aac249 100644 --- a/test/Air/AirParser.test.js +++ b/test/Air/AirParser.test.js @@ -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);