Skip to content

Commit

Permalink
Merge branch 'master' into stable
Browse files Browse the repository at this point in the history
# Conflicts:
#	package.json => version change
  • Loading branch information
dchertousov committed May 31, 2017
2 parents 224b27e + 0bb8e81 commit 775435c
Show file tree
Hide file tree
Showing 5 changed files with 361 additions and 10 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.9.3",
"version": "0.9.4",
"description": "Travelport Universal API",
"main": "build/",
"files": [
Expand Down
41 changes: 33 additions & 8 deletions src/Services/Air/AirParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,22 @@ const airGetTicket = function (obj) {

const taxes = (airPricingInfo && airPricingInfo['air:TaxInfo'])
? Object.keys(airPricingInfo['air:TaxInfo']).map(
taxKey => ({
type: airPricingInfo['air:TaxInfo'][taxKey].Category,
value: airPricingInfo['air:TaxInfo'][taxKey].Amount,
})
taxKey => Object.assign(
{
type: airPricingInfo['air:TaxInfo'][taxKey].Category,
value: airPricingInfo['air:TaxInfo'][taxKey].Amount,
},
airPricingInfo['air:TaxInfo'][taxKey][`common_${this.uapi_version}:TaxDetail`]
? {
details: airPricingInfo['air:TaxInfo'][taxKey][`common_${this.uapi_version}:TaxDetail`].map(
taxDetail => ({
airport: taxDetail.OriginAirport,
value: taxDetail.Amount,
})
),
}
: null,
)
)
: [];
const priceInfo = {
Expand Down Expand Up @@ -518,12 +530,25 @@ function extractBookings(obj) {
);
const taxesInfo = reservation['air:TaxInfo']
? Object.keys(reservation['air:TaxInfo']).map(
taxKey => ({
value: reservation['air:TaxInfo'][taxKey].Amount,
type: reservation['air:TaxInfo'][taxKey].Category,
})
taxKey => Object.assign(
{
value: reservation['air:TaxInfo'][taxKey].Amount,
type: reservation['air:TaxInfo'][taxKey].Category,
},
reservation['air:TaxInfo'][taxKey][`common_${this.uapi_version}:TaxDetail`]
? {
details: reservation['air:TaxInfo'][taxKey][`common_${this.uapi_version}:TaxDetail`].map(
taxDetail => ({
airport: taxDetail.OriginAirport,
value: taxDetail.Amount,
})
),
}
: null,
)
)
: [];

const modifierKey = reservation['air:TicketingModifiersRef']
? Object.keys(reservation['air:TicketingModifiersRef'])[0]
: null;
Expand Down
62 changes: 61 additions & 1 deletion test/Air/AirParser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ describe('#AirParser', () => {
});
});
describe('getTicket', () => {

function testGetTicket(result) {
expect(result).to.be.an('object');
expect(result).to.have.all.keys([
Expand Down Expand Up @@ -224,6 +223,13 @@ describe('#AirParser', () => {
expect(priceInfo.taxes).to.match(/[A-Z]{3}(?:\d+\.)?\d+/i);
expect(priceInfo.taxesInfo).to.be.an('array');
expect(priceInfo.taxesInfo).to.have.length.above(0);
priceInfo.taxesInfo.forEach(
(tax) => {
expect(tax).to.be.an('object');
expect(tax.value).to.match(/^[A-Z]{3}(\d+\.)?\d+$/);
expect(tax.type).to.match(/^[A-Z]{2}$/);
}
);
// Passengers
expect(result.passengers).to.be.an('array');
expect(result.passengers).to.have.length.above(0);
Expand Down Expand Up @@ -343,6 +349,33 @@ describe('#AirParser', () => {
});
});

it('should parse ticket with XF and ZP taxes', () => {
const uParser = new ParserUapi('air:AirRetrieveDocumentRsp', 'v39_0', {});
const parseFunction = airParser.AIR_GET_TICKET;
const xml = fs.readFileSync(`${xmlFolder}/getTicket_XF_ZP.xml`).toString();
return uParser.parse(xml)
.then(json => parseFunction.call(uParser, json))
.then((result) => {
testGetTicket(result);
const detialedTaxes = result.priceInfo.taxesInfo.filter(
tax => ['XF', 'ZP'].indexOf(tax.type) !== -1
);
expect(detialedTaxes).to.have.lengthOf(2);
detialedTaxes.forEach(
(tax) => {
expect(tax.details).to.be.an('array').and.to.have.length.above(0);
tax.details.forEach(
(detailInfo) => {
expect(detailInfo).to.have.all.keys(['airport', 'value']);
expect(detailInfo.airport).to.match(/^[A-Z]{3}$/);
expect(detailInfo.value).to.match(/^[A-Z]{3}(\d+\.)?\d+$/);
}
);
}
);
});
});

it('should parse incomplete data', () => {
const uParser = new ParserUapi('air:AirRetrieveDocumentRsp', 'v39_0', {});
const parseFunction = airParser.AIR_GET_TICKET;
Expand Down Expand Up @@ -742,6 +775,33 @@ describe('#AirParser', () => {
}

describe('AIR_CREATE_RESERVATION()', () => {
it('should parse booking with XF and ZP taxes in FQ', () => {
const uParser = new ParserUapi('universal:UniversalRecordImportRsp', 'v36_0', { });
const parseFunction = airParser.AIR_CREATE_RESERVATION_REQUEST;
const xml = fs.readFileSync(`${xmlFolder}/getPNR_XF_ZP.xml`).toString();
return uParser.parse(xml)
.then(json => parseFunction.call(uParser, json))
.then((result) => {
testBooking(result);
const detialedTaxes = result[0].reservations[0].priceInfo.taxesInfo.filter(
tax => ['XF', 'ZP'].indexOf(tax.type) !== -1
);
expect(detialedTaxes).to.have.lengthOf(2);
detialedTaxes.forEach(
(tax) => {
expect(tax.details).to.be.an('array').and.to.have.length.above(0);
tax.details.forEach(
(detailInfo) => {
expect(detailInfo).to.have.all.keys(['airport', 'value']);
expect(detailInfo.airport).to.match(/^[A-Z]{3}$/);
expect(detailInfo.value).to.match(/^[A-Z]{3}(\d+\.)?\d+$/);
}
);
}
);
});
});

it('should test parsing of create reservation 2ADT1CNN', () => {
const uParser = new ParserUapi('universal:AirCreateReservationRsp', 'v36_0', { });
const parseFunction = airParser.AIR_CREATE_RESERVATION_REQUEST;
Expand Down
106 changes: 106 additions & 0 deletions test/FakeResponses/Air/getPNR_XF_ZP.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<SOAP:Envelope
xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP:Body>
<universal:UniversalRecordImportRsp TraceId="" TransactionId="5EF93A610A0759BC70CF85D144C2C735" ResponseTime="1247"
xmlns:universal="http://www.travelport.com/schema/universal_v36_0"
xmlns:common_v36_0="http://www.travelport.com/schema/common_v36_0"
xmlns:air="http://www.travelport.com/schema/air_v36_0">
<common_v36_0:ResponseMessage Code="0" Type="Warning" ProviderCode="1G">PNR already exists in Universal Record HAB2JQ</common_v36_0:ResponseMessage>
<universal:UniversalRecord LocatorCode="HAB2JQ" Version="1" Status="Active">
<common_v36_0:BookingTraveler Key="4EwW8wBAAA/B6krOEKAAAA==">
<common_v36_0:BookingTravelerName First="FEDIRMR" Last="IVANOV"/>
<common_v36_0:PhoneNumber Key="8FBT8wBAAA/BxUY0XKAAAA==" Type="Mobile" Location="IEV" Number="3805085763213">
<common_v36_0:ProviderReservationInfoRef Key="4EwW8wBAAA/BGRiOEKAAAA=="/>
</common_v36_0:PhoneNumber>
<common_v36_0:SSR Key="4EwW8wBAAA/B7krOEKAAAA==" Status="HK" Type="DOCS" FreeText="P/AA/S12345678/GB/12JUL76/M/23OCT26/IVANOV/FEDIRMR -1IVANOV/FEDIRMR" Carrier="DL" ProviderReservationInfoRef="4EwW8wBAAA/BGRiOEKAAAA=="/>
<common_v36_0:SSR Key="4EwW8wBAAA/B8krOEKAAAA==" Status="HK" Type="DOCS" FreeText="P/AA/S12345678/GB/12JUL76/M/23OCT26/IVANOV/FEDIRMR -1IVANOV/FEDIRMR" Carrier="AA" ProviderReservationInfoRef="4EwW8wBAAA/BGRiOEKAAAA=="/>
<common_v36_0:SSR Key="4EwW8wBAAA/B9krOEKAAAA==" SegmentRef="4EwW8wBAAA/B/krOEKAAAA==" Status="HK" Type="TKNE" FreeText="0579902896660C1" Carrier="AA" ProviderReservationInfoRef="4EwW8wBAAA/BGRiOEKAAAA=="/>
<common_v36_0:SSR Key="4EwW8wBAAA/B+krOEKAAAA==" SegmentRef="4EwW8wBAAA/BBlrOEKAAAA==" Status="HK" Type="TKNE" FreeText="0579902896660C2" Carrier="AA" ProviderReservationInfoRef="4EwW8wBAAA/BGRiOEKAAAA=="/>
</common_v36_0:BookingTraveler>
<common_v36_0:ActionStatus Key="4EwW8wBAAA/BokrOEKAAAA==" Type="ACTIVE" ProviderReservationInfoRef="4EwW8wBAAA/BGRiOEKAAAA==" ProviderCode="1G">
<common_v36_0:Remark>IEV 25MAY1444Z 34 AG</common_v36_0:Remark>
</common_v36_0:ActionStatus>
<universal:ProviderReservationInfo Key="4EwW8wBAAA/BGRiOEKAAAA==" ProviderCode="1G" LocatorCode="X6631S" CreateDate="2017-05-31T11:28:40.578+00:00" ModifiedDate="2017-05-31T14:46:51.575+00:00" HostCreateDate="2017-05-25" Imported="true" OwningPCC="7J8J">
<universal:ProviderReservationDetails ProviderReservationDetail="false" CustomCheck="true" ProviderProfile="false" DivideDetails="false" EnhancedItinModifiers="false" IntegratedContent="false" Cruise="false" RailSegment="false"/>
</universal:ProviderReservationInfo>
<air:AirReservation LocatorCode="4HN6N9" CreateDate="2017-05-31T11:28:38.822+00:00" ModifiedDate="2017-05-31T14:43:19.098+00:00">
<common_v36_0:SupplierLocator SupplierCode="AA" SupplierLocatorCode="VLGZLM" ProviderReservationInfoRef="4EwW8wBAAA/BGRiOEKAAAA==" CreateDateTime="2017-05-25T14:41:00.000+00:00"/>
<air:DocumentInfo>
<air:TicketInfo Number="0579902896659" Status="X" BookingTravelerRef="4EwW8wBAAA/B6krOEKAAAA==" AirPricingInfoRef="4EwW8wBAAA/BskrOEKAAAA==">
<common_v36_0:Name First="FEDIRMR" Last="IVANOV"/>
</air:TicketInfo>
<air:TicketInfo Number="0579902896660" Status="N" BookingTravelerRef="4EwW8wBAAA/B6krOEKAAAA==" AirPricingInfoRef="4EwW8wBAAA/BskrOEKAAAA==">
<common_v36_0:Name First="FEDIRMR" Last="IVANOV"/>
<air:ExchangedTicketInfo Number="0579902896659"/>
</air:TicketInfo>
</air:DocumentInfo>
<common_v36_0:BookingTravelerRef Key="4EwW8wBAAA/B6krOEKAAAA=="/>
<common_v36_0:ProviderReservationInfoRef Key="4EwW8wBAAA/BGRiOEKAAAA=="/>
<air:AirSegment Key="4EwW8wBAAA/B/krOEKAAAA==" Group="0" Carrier="AA" CabinClass="Economy" FlightNumber="2115" ProviderCode="1G" Origin="LGA" Destination="DCA" DepartureTime="2018-04-02T06:00:00.000-04:00" ArrivalTime="2018-04-02T07:02:00.000-04:00" TravelTime="62" ClassOfService="V" ETicketability="No" Status="HK" ChangeOfPlane="false" GuaranteedPaymentCarrier="No" ProviderReservationInfoRef="4EwW8wBAAA/BGRiOEKAAAA==" TravelOrder="1" OptionalServicesIndicator="false">
<air:FlightDetails Key="4EwW8wBAAA/BAlrOEKAAAA==" Origin="LGA" Destination="DCA" DepartureTime="2018-04-02T06:00:00.000-04:00" ArrivalTime="2018-04-02T07:02:00.000-04:00" FlightTime="62" TravelTime="62" Equipment="319" OriginTerminal="C" DestinationTerminal="C"/>
</air:AirSegment>
<air:AirSegment Key="4EwW8wBAAA/BBlrOEKAAAA==" Group="1" Carrier="AA" CabinClass="Economy" FlightNumber="4100" ProviderCode="1G" Origin="DCA" Destination="DTW" DepartureTime="2018-04-10T10:07:00.000-04:00" ArrivalTime="2018-04-10T11:55:00.000-04:00" TravelTime="108" ClassOfService="N" ETicketability="No" Status="HK" ChangeOfPlane="false" GuaranteedPaymentCarrier="No" ProviderReservationInfoRef="4EwW8wBAAA/BGRiOEKAAAA==" TravelOrder="2" OptionalServicesIndicator="false">
<common_v36_0:SegmentRemark Key="4EwW8wBAAA/BDlrOEKAAAA==">AIR WISCONSIN AS AMERICAN EAGLE</common_v36_0:SegmentRemark>
<air:FlightDetails Key="4EwW8wBAAA/BClrOEKAAAA==" Origin="DCA" Destination="DTW" DepartureTime="2018-04-10T10:07:00.000-04:00" ArrivalTime="2018-04-10T11:55:00.000-04:00" FlightTime="108" TravelTime="108" Equipment="CRJ" OriginTerminal="C" DestinationTerminal="N"/>
</air:AirSegment>
<air:AirPricingInfo Key="4EwW8wBAAA/BskrOEKAAAA==" TotalPrice="UAH9944" BasePrice="USD325.16" EquivalentBasePrice="UAH8552" Taxes="UAH1392" TrueLastDateToTicket="2017-05-26T23:59:00.000+02:00" PricingMethod="Guaranteed" ETicketability="Yes" ProviderCode="1G" ProviderReservationInfoRef="4EwW8wBAAA/BGRiOEKAAAA==" AirPricingInfoGroup="1" Ticketed="true" PricingType="StoredFare" FareCalculationInd="G">
<air:FareInfo Key="4EwW8wBAAA/BukrOEKAAAA==" FareBasis="VUAHZNN1" PassengerTypeCode="ADT" Origin="LGA" Destination="DCA" EffectiveDate="2017-05-25T00:00:00.000+02:00" NotValidBefore="2018-04-02" NotValidAfter="2018-04-02" PseudoCityCode="7J8J">
<common_v36_0:Endorsement Value="NONREF/SVCCHGPLUSFAREDIF/"/>
<common_v36_0:Endorsement Value="CXL BY FLT TIME OR NOVALUE"/>
<air:BaggageAllowance>
<air:NumberOfPieces>0</air:NumberOfPieces>
</air:BaggageAllowance>
</air:FareInfo>
<air:FareInfo Key="4EwW8wBAAA/BykrOEKAAAA==" FareBasis="NVAIZNN3" PassengerTypeCode="ADT" Origin="DCA" Destination="DTW" EffectiveDate="2017-05-25T00:00:00.000+02:00" NotValidBefore="2018-04-10" NotValidAfter="2018-04-10" PseudoCityCode="7J8J">
<common_v36_0:Endorsement Value="NONREF/SVCCHGPLUSFAREDIF/"/>
<common_v36_0:Endorsement Value="CXL BY FLT TIME OR NOVALUE"/>
<air:BaggageAllowance>
<air:NumberOfPieces>0</air:NumberOfPieces>
</air:BaggageAllowance>
</air:FareInfo>
<air:BookingInfo BookingCode="V" CabinClass="Economy" FareInfoRef="4EwW8wBAAA/BukrOEKAAAA==" SegmentRef="4EwW8wBAAA/B/krOEKAAAA=="/>
<air:BookingInfo BookingCode="N" CabinClass="Economy" FareInfoRef="4EwW8wBAAA/BykrOEKAAAA==" SegmentRef="4EwW8wBAAA/BBlrOEKAAAA=="/>
<air:TaxInfo Category="AY" Amount="UAH296" Key="4EwW8wBAAA/B2krOEKAAAA=="/>
<air:TaxInfo Category="US" Amount="UAH642" Key="4EwW8wBAAA/B3krOEKAAAA=="/>
<air:TaxInfo Category="XF" Amount="UAH238" Key="4EwW8wBAAA/B4krOEKAAAA==">
<common_v36_0:TaxDetail Amount="USD5" OriginAirport="LGA"/>
<common_v36_0:TaxDetail Amount="USD5" OriginAirport="DCA"/>
</air:TaxInfo>
<air:TaxInfo Category="ZP" Amount="UAH216" Key="4EwW8wBAAA/B5krOEKAAAA==">
<common_v36_0:TaxDetail Amount="USD4.10" OriginAirport="LGA"/>
<common_v36_0:TaxDetail Amount="USD4.10" OriginAirport="DCA"/>
</air:TaxInfo>
<air:FareCalc>NYC AA WAS 242.79VUAHZNN1 AA DTT Q10.74 71.63NVAIZNN3 USD325.16END</air:FareCalc>
<air:PassengerType Code="ADT" BookingTravelerRef="4EwW8wBAAA/B6krOEKAAAA==">
<air:FareGuaranteeInfo GuaranteeType="Guaranteed"/>
</air:PassengerType>
<common_v36_0:BookingTravelerRef Key="4EwW8wBAAA/B6krOEKAAAA=="/>
<air:PaymentRef Key="4EwW8wBAAA/BgnrOEKAAAA=="/>
<air:TicketingModifiersRef Key="4EwW8wBAAA/BtkrOEKAAAA=="/>
</air:AirPricingInfo>
<common_v36_0:Payment Key="4EwW8wBAAA/BgnrOEKAAAA==" Type="Itinerary" Amount="UAH9944" ApproximateAmount="CZK8956" FormOfPaymentRef="4EwW8wBAAA/BfnrOEKAAAA=="/>
<air:TicketingModifiers PlatingCarrier="AF" Key="4EwW8wBAAA/BtkrOEKAAAA==">
<common_v36_0:Commission Level="Fare" Type="PercentBase" Percentage="0.0"/>
<air:DocumentSelect IssueElectronicTicket="true"/>
</air:TicketingModifiers>
</air:AirReservation>
<common_v36_0:GeneralRemark Key="4EwW8wBAAA/BenrOEKAAAA==" TypeInGds="Basic" ProviderReservationInfoRef="4EwW8wBAAA/BGRiOEKAAAA==" CreateDate="2017-05-24T11:58:00.000+00:00">
<common_v36_0:RemarkData>VIEWTRIPITIN</common_v36_0:RemarkData>
</common_v36_0:GeneralRemark>
<common_v36_0:AgencyInfo>
<common_v36_0:AgentAction ActionType="Created" AgentCode="UAPI7980742859-07362D4F" BranchCode="257f/VZmSaKqfMsUWfwY6Q==" AgencyCode="TVPORTDYNASKLTONWABAGENCY" EventTime="2017-05-31T11:28:38.393+00:00"/>
<common_v36_0:AgentAction ActionType="Modified" AgentCode="UAPI7980742859-07362D4F" BranchCode="P2731609" AgencyCode="S1473516" EventTime="2017-05-31T14:43:19.098+00:00"/>
<common_v36_0:AgentAction ActionType="Ticketed" AgentCode="UAPI7980742859-07362D4F" BranchCode="P2731609" AgencyCode="S1473516" EventTime="2017-05-31T11:28:40.567+00:00"/>
</common_v36_0:AgencyInfo>
<common_v36_0:AgencyContactInfo>
<common_v36_0:PhoneNumber Key="4EwW8wBAAA/BqkrOEKAAAA==" Type="Agency" Location="IEV" Number="380 44 9999999">
<common_v36_0:ProviderReservationInfoRef Key="4EwW8wBAAA/BGRiOEKAAAA=="/>
</common_v36_0:PhoneNumber>
</common_v36_0:AgencyContactInfo>
<common_v36_0:FormOfPayment Key="4EwW8wBAAA/BfnrOEKAAAA==" Type="MiscFormOfPayment" Reusable="false" ProfileKey="/jTyIB9dR7u2wklYQUPRSw==">
<common_v36_0:MiscFormOfPayment Text="0579902896659" Category="Exchange"/>
</common_v36_0:FormOfPayment>
</universal:UniversalRecord>
</universal:UniversalRecordImportRsp>
</SOAP:Body>
</SOAP:Envelope>
Loading

0 comments on commit 775435c

Please sign in to comment.