Skip to content

Commit

Permalink
Merge pull request #21 from Travelport-Ukraine/booking-fixes
Browse files Browse the repository at this point in the history
Booking fixes
  • Loading branch information
shmuga committed Oct 17, 2016
2 parents 7de1489 + 8e97d9a commit 5b0cb18
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 30 deletions.
11 changes: 1 addition & 10 deletions docs/Air.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,9 @@ So under `Directions[0][1]` you will find `Segments` array. This segments are us
"arrival": "2016-11-10T21:45:00.000+01:00",
"airline": "KL",
"flightNumber": "3098",
"baggage": [
{
"units": "piece",
"amount": 0
}
],
"serviceClass": "Economy",
"plane": "E90",
"duration": "185",
"fareBasisCode": "GSRUA",
"seatsAvailable": "9",
"uapi_SegmentRef": "o/+6FXFrSPaEMv+uAyD5kQ=="
}
```

Expand All @@ -113,7 +104,7 @@ So under `Directions[0][1]` you will find `Segments` array. This segments are us
| --- | --- | --- |
| lastName | <code>String</code> | Passenger last name. |
| firstName | <code>String</code> | Passenger first name. |
| birthDate | <code>String</code> | Birth date in format `DDMMMYY`. |
| birthDate | <code>String</code> | Birth date in format `YYYYMMDD`. |
| gender | <code>String</code> | One of `['M', 'F']`. |
| ageCategory | <code>String</code> | One of `['ADT', 'CNN', 'INF']`. Or [other types](https://support.travelport.com/webhelp/uapi/uAPI.htm#Air/Shared_Air_Topics/Passenger_Type_Codes.htm) |
| passNumber| <code>String</code> | Pass number. |
Expand Down
6 changes: 3 additions & 3 deletions examples/Air/book.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ AirService.shop(params).then(results => {
firstName: 'SKYWALKER',
passCountry: 'UA',
passNumber: 'ES221731',
birthDate: '25JUL68',
birthDate: '19680725',
gender: 'M',
ageCategory: 'ADT',
}, {
lastName: 'DARTH',
firstName: 'VAIDER',
passCountry: 'UA',
passNumber: 'ES221731',
birthDate: '25JUL66',
birthDate: '19660725',
gender: 'M',
ageCategory: 'ADT',
}, {
lastName: 'ANAKINJR',
firstName: 'SKYWALKER',
passCountry: 'UA',
passNumber: 'ES221731',
birthDate: '25JUL05',
birthDate: '20050725',
gender: 'M',
ageCategory: 'CNN',
}],
Expand Down
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.3.1",
"version": "0.3.2",
"description": "Travelport Universal API",
"main": "build/",
"files": [
Expand Down
1 change: 1 addition & 0 deletions src/Air/AirParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ function airPriceRspPricingSolutionXML(obj) {
$: {
BookingTravelerRef: 'P_' + index,
Code: passenger.ageCategory,
Age: passenger.Age,
},
});
});
Expand Down
26 changes: 18 additions & 8 deletions src/Air/AirValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ Validator.prototype.pcc = function () {

Validator.prototype.bookedPassengers = function () {
// TODO check passengers list
this.params.business = (this.params.segments[0].serviceClass === 'Business');
this.params.passengers = this.params.passengers.map(passenger => {
if (passenger.ageCategory === 'CNN') {
passenger.child = true;
}
const birth = moment(passenger.birthDate.toUpperCase(), 'YYYYMMDD');
passenger.Age = moment().diff(birth, 'years');
return passenger;
});
return this;
Expand Down Expand Up @@ -135,24 +135,34 @@ Validator.prototype.pricingSolutionXML = function () {
// convert all passenger birth dates from DDmmmYY into YYYY-MM-DD
Validator.prototype.passengerBirthDates = function () {
this.params.passengers.forEach((item) => {
const a = moment(item.birthDate.toUpperCase(), 'DDMMMYY');
const birthSSR = moment(item.birthDate.toUpperCase(), 'YYYYMMDD');

if (!a.isValid()) {
if (!birthSSR.isValid()) {
throw new Error('Invalid birth date');
}
const { passCountry: country,
passNumber: num,
birthDate: birth,
firstName: first,
lastName: last,
gender } = item;
const due = moment().add(10, 'month').format('DDMMMYY');
const due = moment().add(12, 'month').format('DDMMMYY');
const birth = birthSSR.format('DDMMMYY');
item.age = parseInt(moment().diff(birthSSR, 'years'), 10);

if (item.ageCategory === 'CNN') {
item.isChild = true;
if (item.Age < 10) {
item.ageCategory = `C0${item.Age}`;
} else {
item.ageCategory = `C${item.Age}`;
}
}

item.ssr = {
type: 'DOCS',
text: `P/${country}/${num}/${country}/${birth}/${gender}/${due}/${first}/${last}`,
};
item.DOB = a.format('YYYY-MM-DD');
item.DOB = birthSSR.format('YYYY-MM-DD');
});

return this;
Expand Down
10 changes: 8 additions & 2 deletions src/XMLtemplates/104-02_1G_AirPrice_Rq.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@
</air:AirSegment>
{{/segments}}
</air:AirItinerary>
{{#if business}}
<air:AirPricingModifiers>
<air:PermittedCabins>
<com:CabinClass Type="Business" xmlns:com="http://www.travelport.com/schema/common_v36_0" />
</air:PermittedCabins>
</air:AirPricingModifiers>
{{/if}}
{{#passengers}}
<com:SearchPassenger Key="P_{{@index}}" Code="{{ageCategory}}"
{{#if child}} Age="9"{{/if}} xmlns:com="http://www.travelport.com/schema/common_v36_0"/>
<com:SearchPassenger Key="P_{{@index}}" Code="{{ageCategory}}" Age="{{Age}}" xmlns:com="http://www.travelport.com/schema/common_v36_0"/>
{{/passengers}}
{{#if hasFareBasis}}
<air:AirPricingCommand>
Expand Down
7 changes: 6 additions & 1 deletion src/XMLtemplates/104-03_1G_AirBook_Rq_pricingSolutionXML.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<univ:AirCreateReservationReq AuthorizedBy="user" {{#if rule}}RuleName="{{rule}}"{{/if}} RetainReservation="Both" TargetBranch="{{TargetBranch}}" TraceId="{{requestId}}" xmlns:univ="http://www.travelport.com/schema/universal_v36_0" {{#if UniversalRecordLocatorCode}} UniversalRecordLocatorCode="{{UniversalRecordLocatorCode}}" {{/if}} xmlns:com="http://www.travelport.com/schema/common_v36_0" xmlns:air="http://www.travelport.com/schema/air_v36_0" xmlns:common_v36_0="http://www.travelport.com/schema/common_v36_0">
<com:BillingPointOfSaleInfo OriginApplication="uAPI" />
{{#passengers}}
<com:BookingTraveler Key="P_{{@index}}" DOB="{{DOB}}" Gender="{{gender}}" TravelerType="{{ageCategory}}">
<com:BookingTraveler Key="P_{{@index}}" Age="{{Age}}" DOB="{{DOB}}" Gender="{{gender}}" TravelerType="{{ageCategory}}">
<com:BookingTravelerName First="{{firstName}}" Last="{{lastName}}" {{#if Prefix}}Prefix="{{title}}"{{/if}}/>
<com:DeliveryInfo>
<com:ShippingAddress>
Expand All @@ -27,6 +27,11 @@
<!--<com:SSR Carrier="F9" FreeText="P/IN/F1234567/IN/05Jan85/M/13Dec14/Jones/Stephen"-->
<!--SegmentRef="IVaa0tGWQ+2grqSIL81xPQ==" Status="HK" Type="DOCS"/>-->
{{/ssr}}
{{#if isChild}}
<com:NameRemark Key="P_{{@index}}">
<com:RemarkData>P-{{ageCategory}}</com:RemarkData>
</com:NameRemark>
{{/if}}
</com:BookingTraveler>
{{/passengers}}

Expand Down
9 changes: 6 additions & 3 deletions test/Air/AirParser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ describe('#AirParser', function () {
firstName: 'SKYWALKER',
passCountry: 'UA',
passNumber: 'ES221731',
birthDate: '25JUL68',
birthDate: '19680725',
Age: 30,
gender: 'M',
ageCategory: 'ADT',
}];
Expand All @@ -109,7 +110,8 @@ describe('#AirParser', function () {
firstName: 'SKYWALKER',
passCountry: 'UA',
passNumber: 'ES221731',
birthDate: '25JUL68',
birthDate: '19680725',
Age: 30,
gender: 'M',
ageCategory: 'ADT',
}];
Expand All @@ -131,7 +133,8 @@ describe('#AirParser', function () {
firstName: 'SKYWALKER',
passCountry: 'UA',
passNumber: 'ES221731',
birthDate: '25JUL68',
birthDate: '19680725',
Age: 30,
gender: 'M',
ageCategory: 'ADT',
}];
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion test/FakeResponses/Air/AirPricingSolution.IEVPAR.json

Large diffs are not rendered by default.

0 comments on commit 5b0cb18

Please sign in to comment.