Skip to content

Commit

Permalink
Merge pull request #628 from Travelport-Ukraine/TC-3472
Browse files Browse the repository at this point in the history
TC-3472 / New option added for availabilty request
  • Loading branch information
dchertousov authored May 4, 2023
2 parents b69cefe + ef4e139 commit 78362cf
Show file tree
Hide file tree
Showing 9 changed files with 571 additions and 368 deletions.
3 changes: 2 additions & 1 deletion docs/Air.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ Low Fare Shop functionality combines air availability and a fare quote request t
| maxSolutions | `number` | Maximum number of solutions. <i>Optional.</i> |.
| permittedCarriers | `Array<String>` | Array of carriers' codes. <i>Optional. Can not be used when `preferredCarriers` is set</i> |
| preferredCarriers | `Array<String>` | Array of carriers' codes. <i>Optional. Can not be used when `permittedCarriers` is set</i> |
| allowDirectAccess | `Boolean` | When passed, first carrier is taken from the carriers list and the search is done in carrier specific display.
| allowDirectAccess | `Boolean` | When passed, first carrier is taken from the carriers list and the search is done in carrier specific display. <i>Optional.</i> |
| returnFirstAvailableOnly | `Boolean` | When passed, next days availability is returned if available. <i>Optional.</i> |
| preferredConnectionPoints | `Array<String>` | Array of IATA codes. <i>Optional.</i> |
| prohibitedConnectionPoints | `Array<String>` | Array of IATA codes. <i>Optional.</i> |
| permittedConnectionPoints | `Array<String>` | Array of IATA codes. <i>Optional.</i> |
Expand Down
888 changes: 524 additions & 364 deletions package-lock.json

Large diffs are not rendered by default.

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.14.11",
"version": "1.15.0",
"description": "Travelport Universal API",
"main": "src/",
"files": [
Expand Down
1 change: 1 addition & 0 deletions src/Services/Air/AirErrors.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Object.assign(AirValidationError, createErrorsList({
PlatingCarrierInvalid: 'Plating Carrier Invalid',
SearchIdMissing: 'SearchId is missing',
VersionMissing: 'Version is missing in request',
ReturnFirstAvailableOnlyInvalid: 'Invalid value provided for returnFirstAvailableOnly',
AllowDirectAccessInvalid: 'Invalid value provided for allowDirectAccess',
AllowDirectAccessCarriersNotSpecified: 'Carriers not specified for carrier specific display',
EMDItemNumberMissing: 'Missing EMD number. See data.',
Expand Down
3 changes: 2 additions & 1 deletion src/Services/Air/AirValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ module.exports = {
validators.passengers,
validators.legs,
validators.carriers,
validators.allowDirectAccess
validators.allowDirectAccess,
validators.returnFirstAvailableOnly
),
transform(
transformers.convertPassengersObjectToArray
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ module.exports = `
<com:CityOrAirport Code="{{to}}" PreferCity="true"/>
</air:SearchDestination>
<air:SearchDepTime PreferredTime="{{departureDate}}"/>
<air:AirLegModifiers {{#if ../allowDirectAccess}}AllowDirectAccess="true"{{/if}}>
<air:AirLegModifiers
{{#if ../allowDirectAccess}}AllowDirectAccess="true"{{/if}}
{{#if ../returnFirstAvailableOnly}}ReturnFirstAvailableOnly="true"{{/if}}
>
{{#*inline "connectionPoint"}}
<com:ConnectionPoint>
<com:CityOrAirport Code="{{connection}}" />
Expand Down
2 changes: 2 additions & 0 deletions src/Services/Air/validators/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const platingCarrier = require('./platingCarrier');
const searchId = require('./search-id');
const version = require('./version');
const allowDirectAccess = require('./allow-direct-access');
const returnFirstAvailableOnly = require('./return-first-available-only');
const emdNumber = require('./emd-number');
const carriers = require('./carriers');

Expand All @@ -29,6 +30,7 @@ module.exports = {
pricingSolutionXml,
paramsIsObject,
allowDirectAccess,
returnFirstAvailableOnly,
fop,
fopCreditCard,
pnr,
Expand Down
8 changes: 8 additions & 0 deletions src/Services/Air/validators/return-first-available-only.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const { AirValidationError } = require('../AirErrors');

module.exports = (params) => {
const { returnFirstAvailableOnly } = params;
if (returnFirstAvailableOnly !== undefined && (typeof returnFirstAvailableOnly) !== 'boolean') {
throw new AirValidationError.ReturnFirstAvailableOnlyInvalid(params);
}
};
27 changes: 27 additions & 0 deletions test/Air/validators/return-first-available-only.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const { expect } = require('chai');
const { AirValidationError } = require('../../../src/Services/Air/AirErrors');
const validate = require('../../../src/Services/Air/validators/return-first-available-only');

describe('#Air#validators#return-first-available-only', () => {
it('should throw when returnFirstAvailableOnly invalid type', () => {
const params = { returnFirstAvailableOnly: 'NOT_BOOLEAN' };
try {
validate(params);
throw new Error('PASSED');
} catch (err) {
expect(err).to.be.an.instanceOf(AirValidationError.ReturnFirstAvailableOnlyInvalid);
}
});
it('should not throw when no returnFirstAvailableOnly provided', () => {
const params = {};
validate(params);
});
it('should not throw when returnFirstAvailableOnly is false', () => {
const params = { returnFirstAvailableOnly: false };
validate(params);
});
it('should not throw when returnFirstAvailableOnly is true', () => {
const params = { returnFirstAvailableOnly: true };
validate(params);
});
});

0 comments on commit 78362cf

Please sign in to comment.