Skip to content

Commit 30ba034

Browse files
authored
Merge pull request #146 from amadeus4dev/Add-Airport-Route-API
Add airport routes api
2 parents e6032b2 + befb63a commit 30ba034

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ var amadeus = new Amadeus({
172172
## List of supported endpoints
173173

174174
```js
175+
//Airport Routes
176+
amadeus.airport.directDestinations.get({
177+
departureAirportCode: 'CDG',
178+
})
179+
175180
// Flight Inspiration Search
176181
amadeus.shopping.flightDestinations.get({
177182
origin : 'MAD'

spec/amadeus/namespaces.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ describe('Namespaces', () => {
8282
expect(amadeus.media.files).toBeDefined();
8383

8484
expect(amadeus.airport).toBeDefined();
85+
expect(amadeus.airport.directDestinations).toBeDefined();
8586
expect(amadeus.airport.predictions).toBeDefined();
8687
expect(amadeus.airport.predictions.onTime).toBeDefined();
8788

@@ -461,6 +462,13 @@ describe('Namespaces', () => {
461462
.toHaveBeenCalledWith('/v1/travel/predictions/flight-delay', {});
462463
});
463464

465+
it('.amadeus.airport.directDestinations.get', () => {
466+
amadeus.client.get = jest.fn();
467+
amadeus.airport.directDestinations.get();
468+
expect(amadeus.client.get)
469+
.toHaveBeenCalledWith('/v1/airport/direct-destinations', {});
470+
});
471+
464472
it('.amadeus.airport.predictions.onTime.get', () => {
465473
amadeus.client.get = jest.fn();
466474
amadeus.airport.predictions.onTime.get();

src/amadeus/namespaces/airport.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import DirectDestinations from './airport/direct-destinations';
12
import Predictions from './airport/predictions';
23

34
/**
@@ -17,6 +18,7 @@ import Predictions from './airport/predictions';
1718
class Airport {
1819
constructor(client) {
1920
this.client = client;
21+
this.directDestinations = new DirectDestinations(client);
2022
this.predictions = new Predictions(client);
2123
}
2224
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* A namespaced client for the
3+
* `/v1/airport/direct-destinations` endpoints
4+
*
5+
* Access via the {@link Amadeus} object
6+
*
7+
* ```js
8+
* let amadeus = new Amadeus();
9+
* amadeus.airport.directDestinations;
10+
* ```
11+
*
12+
* @param {Client} client
13+
*/
14+
class DirectDestinations {
15+
constructor(client) {
16+
this.client = client;
17+
}
18+
19+
/**
20+
* Get the percentage of on-time flight departures from a given airport
21+
*
22+
* @param {Object} params
23+
* @param {string} params.departureAirportCode airport IATA code, e.g. BOS for Boston
24+
* @return {Promise.<Response,ResponseError>} a Promise
25+
*
26+
* What destinations are served by this airport?
27+
* ```js
28+
* amadeus.airport.directDestinations.get({
29+
* departureAirportCode: 'JFK',
30+
* })
31+
* ```
32+
*/
33+
get(params = {}) {
34+
return this.client.get('/v1/airport/direct-destinations', params);
35+
}
36+
}
37+
38+
export default DirectDestinations;

0 commit comments

Comments
 (0)