Skip to content

Commit

Permalink
Merge branch 'master' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
dchertousov committed Mar 22, 2022
2 parents a42ebbb + 079d903 commit ca0521e
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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": "1.12.2",
"version": "1.12.3",
"description": "Travelport Universal API",
"main": "src/",
"files": [
Expand Down
2 changes: 2 additions & 0 deletions src/Services/Air/AirErrors.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ Object.assign(AirRuntimeError, createErrorsList({
NoValidFare: 'No valid fare for input criteria.',
TravelersListError: 'Not all BookingTravelers present in list or wrong lookup keys provided',
ParseTicketPNRError: ['Failed to parse PNR from ticket information', errorCodes.Validation],
HostErrorDuringTicketRetrieve: 'Host error during ticket retrieve',
AccessedByAnotherTransaction: 'Accessed by another transaction. Retry later',
UnableToRetrieveTickets: ['Unable to retrieve tickets list', errorCodes.NotFound],
TicketInfoIncomplete: 'Ticket information is incomplete',
RequestInconsistency: 'Request faced race condition. Please retry again',
Expand Down
31 changes: 19 additions & 12 deletions src/Services/Air/AirParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const fareCalculationPattern = /^([\s\S]+)END($|\s)/;
const firstOriginPattern = /^(?:s-)?(?:\d{2}[a-z]{3}\d{2}\s+)?([a-z]{3})/i;
const noAgreementPattern = /NO AGENCY AGREEMENT/i;
const unableToRetreivePattern = /UNABLE TO RETRIEVE/i;
const ticketRetrieveErrorPattern = /HOST ERROR DURING TICKET RETRIEVE/i;
const accessedByAnotherTransactionPattern = /ACCESSED BY ANOTHER TRANSACTION/i;

const parseFareCalculation = (str) => {
const fareCalculation = str.match(fareCalculationPattern)[1];
Expand Down Expand Up @@ -464,19 +466,24 @@ function processUAPIError(source) {
throw new RequestRuntimeError.UnhandledError(null, new AirRuntimeError(source));
}

if (noAgreementPattern.test(uapiErrorMessage)) {
const pcc = utils.getErrorPcc(uapiErrorMessage);
throw new AirRuntimeError.NoAgreement({ pcc });
}

if (unableToRetreivePattern.test(uapiErrorMessage)) {
throw new AirRuntimeError.UnableToRetrieve(source);
const pcc = utils.getErrorPcc(uapiErrorMessage);

switch (true) {
case noAgreementPattern.test(uapiErrorMessage):
utils.getErrorPcc(uapiErrorMessage);
throw new AirRuntimeError.NoAgreement({ pcc });
case unableToRetreivePattern.test(uapiErrorMessage):
throw new AirRuntimeError.UnableToRetrieve(source);
case ticketRetrieveErrorPattern.test(uapiErrorMessage):
throw new AirRuntimeError.UnableToRetrieve(source);
case accessedByAnotherTransactionPattern.test(uapiErrorMessage):
throw new AirRuntimeError.AccessedByAnotherTransaction(source);
default:
throw new RequestRuntimeError.UAPIServiceError({
...source,
faultstring: uapiErrorMessage.toUpperCase()
});
}

throw new RequestRuntimeError.UAPIServiceError({
...source,
faultstring: uapiErrorMessage.toUpperCase()
});
}

const AirErrorHandler = function (rsp) {
Expand Down
18 changes: 9 additions & 9 deletions test/Air/AirParser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,17 +568,17 @@ describe('#AirParser', () => {
});
});

it('should return error when not available to return ticket', (done) => {
it('should return error when not available to return ticket', async () => {
const uParser = new Parser('air:AirRetrieveDocumentRsp', 'v47_0', {});
const parseFunction = airParser.AIR_GET_TICKET;
const xml = fs.readFileSync(`${xmlFolder}/getTicket_FAILED.xml`).toString();
uParser.parse(xml)
.then(json => parseFunction.call(uParser, json))
.then(() => done(new Error('Error has not occurred')))
.catch((err) => {
expect(err).to.be.an.instanceof(RequestRuntimeError.UAPIServiceError);
done();
});
try {
const xml = fs.readFileSync(`${xmlFolder}/getTicket_FAILED.xml`).toString();
const json = await uParser.parse(xml);
parseFunction.call(uParser, json);
throw new Error('Error has not occurred');
} catch (err) {
expect(err).to.be.an.instanceof(AirRuntimeError.UnableToRetrieve);
}
});

it('should parse imported ticket', () => {
Expand Down

0 comments on commit ca0521e

Please sign in to comment.