Skip to content

Commit

Permalink
Merge pull request #22 from Travelport-Ukraine/ticketing-foid-fixes
Browse files Browse the repository at this point in the history
Ticketing foid fixes
  • Loading branch information
shmuga committed Oct 19, 2016
2 parents 5b0cb18 + 7ba117e commit 86cb588
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 4 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.3.2",
"version": "0.3.3",
"description": "Travelport Universal API",
"main": "build/",
"files": [
Expand Down
13 changes: 12 additions & 1 deletion src/Air/AirParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ const ticketParse = (obj) => {
let checkResponseMessage = false;
let checkTickets = false;

if (obj['air:TicketFailureInfo']) {
const msg = obj['air:TicketFailureInfo'].Message;
if (/VALID\sFORM\sOF\sID\s\sFOID\s\sREQUIRED/.exec(msg)) {
throw new UError('TICKETING_FOID_REQUIRED');
}
throw new UError('TICKETING_ERROR', obj);
}

if (obj['common_v33_0:ResponseMessage']) {
const responseMessage = obj['common_v33_0:ResponseMessage'];
responseMessage.forEach(msg => {
Expand Down Expand Up @@ -452,7 +460,9 @@ function extractBookings(obj) {
type: 'uAPI',
pnr: providerInfo.LocatorCode,
// pcc: this.env.pcc, //TODO remove search PCC from format?
uapi_pnr_locator: booking.LocatorCode,
version: record.Version,
uapi_ur_locator: record.LocatorCode,
uapi_reservation_locator: booking.LocatorCode,
uapi_airline_locator: supplierLocator.SupplierLocatorCode || null,
pnrList: [providerInfo.LocatorCode],
platingCarrier: platingCarriers,
Expand Down Expand Up @@ -550,5 +560,6 @@ module.exports = {
FARE_RULES_RESPONSE: FareRules,
GDS_QUEUE_PLACE_RESPONSE: gdsQueue,
AIR_CANCEL_UR: nullParsing,
UNIVERSAL_RECORD_FOID: nullParsing,
AIR_ERRORS: AirErrorHandler, // errors handling
};
12 changes: 10 additions & 2 deletions src/Air/AirService.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,17 @@ module.exports = (settings) => {
const AirService = airServiceInternal(auth, debug, production);
return AirService.importPNR(options).then(data => {
const ticketParams = Object.assign({}, options, {
ReservationLocator: data[0].uapi_pnr_locator,
ReservationLocator: data[0].uapi_reservation_locator,
});
return AirService.ticket(ticketParams);
return AirService.ticket(ticketParams)
.then(result => result, error => {
if (error.errno === 1503) {
return AirService.importPNR(options)
.then(booking => AirService.foid(booking[0]))
.then(() => AirService.ticket(ticketParams));
}
return Promise.reject(error);
});
});
},
};
Expand Down
11 changes: 11 additions & 0 deletions src/Air/AirServiceInternal.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,17 @@ module.exports = function (auth, debug, production) {
debug
),

foid: uApiRequest(
config(auth.region, production).UniversalRecord.url,
auth,
requests.UniversalRecord.UNIVERSAL_RECORD_FOID,
'universal:UniversalRecordModifyRsp',
AirValidator.UNIVERSAL_RECORD_FOID,
AirParser.AIR_ERRORS,
AirParser.UNIVERSAL_RECORD_FOID,
debug
),

cancelUR: uApiRequest(
config(auth.region, production).UniversalRecord.url,
auth,
Expand Down
5 changes: 5 additions & 0 deletions src/Air/AirValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,9 @@ module.exports = {
return new Validator(params)
.end();
},

UNIVERSAL_RECORD_FOID(params) {
return new Validator(params)
.end();
},
};
16 changes: 16 additions & 0 deletions src/XMLtemplates/UniversalRecordModifyReq.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:air="http://www.travelport.com/schema/air_v36_0" xmlns:com="http://www.travelport.com/schema/common_v36_0" xmlns:univ="http://www.travelport.com/schema/universal_v36_0">
<soapenv:Header/>
<soapenv:Body>
<univ:UniversalRecordModifyReq AuthorizedBy="user" TargetBranch="{{TargetBranch}}" Version="{{version}}">
<com:BillingPointOfSaleInfo OriginApplication="UAPI"/>
<univ:RecordIdentifier ProviderCode="1G" ProviderLocatorCode="{{pnr}}" UniversalLocatorCode="{{uapi_ur_locator}}"/>
{{#each passengers}}
<univ:UniversalModifyCmd Key="P_{{@index}}_CHANGE_FOID">
<univ:AirAdd ReservationLocatorCode="{{../uapi_reservation_locator}}" BookingTravelerRef="{{{uapi_ref_key}}}">
<com:SSR Key="P_{{@index}}" Type="FOID" Status="HK" Carrier="YY" FreeText="PP{{passNumber}}"/>
</univ:AirAdd>
</univ:UniversalModifyCmd>
{{/each}}
</univ:UniversalRecordModifyReq>
</soapenv:Body>
</soapenv:Envelope>
2 changes: 2 additions & 0 deletions src/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ const allErrors = {
},
GDS_PLACE_QUEUE_ERROR: { errno: 1500, msg: 'Error during place queue request' },
AIR_SEGMENT_FAILURE: { errno: 1501, msg: 'Booking of some segments failure. PNR cancelled.' },
TICKETING_ERROR: { errno: 1502, msg: 'Ticketing error during request.' },
TICKETING_FOID_REQUIRED: { errno: 1503, msg: 'FOID required for current PC.' },
};


Expand Down
1 change: 1 addition & 0 deletions src/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module.exports = {

UniversalRecord: {
UNIVERSAL_RECORD_IMPORT_SIMPLE_REQUEST: xmlDir + '/UniversalRecordImportReq.xml',
UNIVERSAL_RECORD_FOID: xmlDir + '/UniversalRecordModifyReq.xml',
},

UtilsService: {
Expand Down
4 changes: 4 additions & 0 deletions test/Air/AirParser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ describe('#AirParser', function () {
function testBooking(jsonResult, platingCarrier = true, tickets = false) {
assert(_.isArray(jsonResult), 'result not array');
jsonResult.forEach(result => {
assert(result.version, 'no version');
assert(result.uapi_ur_locator, 'no ur locator');
assert(result.uapi_reservation_locator, 'no reservation locator');
assert(result.uapi_airline_locator, 'no airline locator');
assert(result.bookingPCC, 'no booking pcc');
assert(result.platingCarrier, 'no PC');
assert(_.isArray(result.passengers), 'passengers is not array');
Expand Down

0 comments on commit 86cb588

Please sign in to comment.