Skip to content

Commit 84439ef

Browse files
authored
Merge pull request #20 from alnacle/feature/points-of-interest
Add Points of Interest API
2 parents d3f4b28 + 9f0e4ed commit 84439ef

File tree

5 files changed

+127
-0
lines changed

5 files changed

+127
-0
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,21 @@ amadeus.shopping.hotelOffersByHotel.get({
275275
})
276276
// Confirm the availability of a specific offer id
277277
amadeus.shopping.hotelOffer('XXX').get()
278+
279+
// Points of Interest
280+
// What are the popular places in Barcelona (based a geo location and a radius)
281+
amadeus.referenceData.locations.pointsOfInterest.get({
282+
latitude : 41.397158,
283+
longitude : 2.160873
284+
})
285+
286+
// What are the popular places in Barcelona? (based on a square)
287+
amadeus.referenceData.locations.pointsOfInterest.bySquare.get({
288+
north: 41.397158,
289+
west: 2.160873,
290+
south: 41.394582,
291+
east: 2.177181
292+
})
278293
```
279294

280295
## Development & Contributing

spec/amadeus/namespaces.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ describe('Namespaces', () => {
2222
expect(amadeus.referenceData.location).toBeDefined();
2323
expect(amadeus.referenceData.locations).toBeDefined();
2424
expect(amadeus.referenceData.locations.airports).toBeDefined();
25+
expect(amadeus.referenceData.locations.pointsOfInterest).toBeDefined();
26+
expect(amadeus.referenceData.locations.pointsOfInterest.bySquare).toBeDefined();
2527
expect(amadeus.referenceData.airlines).toBeDefined();
2628

2729
expect(amadeus.travel).toBeDefined();
@@ -49,6 +51,8 @@ describe('Namespaces', () => {
4951
expect(amadeus.referenceData.location('ALHR').get).toBeDefined();
5052
expect(amadeus.referenceData.locations.get).toBeDefined();
5153
expect(amadeus.referenceData.locations.airports.get).toBeDefined();
54+
expect(amadeus.referenceData.locations.pointsOfInterest.get).toBeDefined();
55+
expect(amadeus.referenceData.locations.pointsOfInterest.bySquare.get).toBeDefined();
5256
expect(amadeus.referenceData.airlines.get).toBeDefined();
5357

5458
expect(amadeus.travel.analytics.airTraffic.searched.get).toBeDefined();
@@ -94,6 +98,20 @@ describe('Namespaces', () => {
9498
.toHaveBeenCalledWith('/v1/reference-data/locations/airports', {});
9599
});
96100

101+
it('.amadeus.referenceData.locations.pointsOfInterest.get', () => {
102+
amadeus.client.get = jest.fn();
103+
amadeus.referenceData.locations.pointsOfInterest.get();
104+
expect(amadeus.client.get)
105+
.toHaveBeenCalledWith('/v1/reference-data/locations/pois', {});
106+
});
107+
108+
it('.amadeus.referenceData.locations.pointsOfInterest.bySquare.get', () => {
109+
amadeus.client.get = jest.fn();
110+
amadeus.referenceData.locations.pointsOfInterest.bySquare.get();
111+
expect(amadeus.client.get)
112+
.toHaveBeenCalledWith('/v1/reference-data/locations/pois/by-square', {});
113+
});
114+
97115
it('.amadeus.referenceData.airlines.get', () => {
98116
amadeus.client.get = jest.fn();
99117
amadeus.referenceData.airlines.get();

src/amadeus/namespaces/reference_data/locations.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Airports from './locations/airports';
2+
import PointsOfInterest from './locations/pois';
23

34
/**
45
* A namespaced client for the
@@ -18,6 +19,7 @@ class Locations {
1819
constructor(client) {
1920
this.client = client;
2021
this.airports = new Airports(client);
22+
this.pointsOfInterest = new PointsOfInterest(client);
2123
}
2224

2325
/**
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* A namespaced client for the
3+
* `/v1/reference-data/locations/pois/by-square` endpoints
4+
*
5+
* Access via the {@link Amadeus} object
6+
*
7+
* ```js
8+
* let amadeus = new Amadeus();
9+
* amadeus.referenceData.locations.pointsOfInterest.bySquare;
10+
* ```
11+
*
12+
* @param {Client} client
13+
*/
14+
class bySquare {
15+
constructor(client) {
16+
this.client = client;
17+
}
18+
19+
/**
20+
* Returns a list of relevant points of interest for a given area.
21+
*
22+
* @param {Object} params
23+
* @param {Double} params.north latitude north of bounding box - required
24+
* @param {Double} params.west longitude west of bounding box - required
25+
* @param {Double} params.south latitude south of bounding box - required
26+
* @param {Double} params.east longitude east of bounding box - required
27+
* @return {Promise.<Response,ResponseError>} a Promise
28+
*
29+
* Find relevant points of interest within an area in Barcelona
30+
*
31+
* ```js
32+
* amadeus.referenceData.locations.pointsOfInterest.bySquare.get({
33+
* north: 41.397158,
34+
* west: 2.160873,
35+
* south: 41.394582,
36+
* east: 2.177181
37+
* });
38+
* ```
39+
*/
40+
get(params = {}) {
41+
return this.client.get('/v1/reference-data/locations/pois/by-square', params);
42+
}
43+
}
44+
45+
export default bySquare;
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import BySquare from './points_of_interest/by-square';
2+
3+
/**
4+
* A namespaced client for the
5+
* `/v1/reference-data/locations/pois` endpoints
6+
*
7+
* Access via the {@link Amadeus} object
8+
*
9+
* ```js
10+
* let amadeus = new Amadeus();
11+
* amadeus.referenceData.locations.pointsOfInterest;
12+
* ```
13+
*
14+
* @param {Client} client
15+
*/
16+
class pointsOfInterest {
17+
constructor(client) {
18+
this.client = client;
19+
this.bySquare = new BySquare(client);
20+
}
21+
22+
/**
23+
* Returns a list of relevant points of interest near to a given point.
24+
*
25+
* @param {Object} params
26+
* @param {Double} params.latitude latitude location to be at the center of
27+
* the search circle - required
28+
* @param {Double} params.longitude longitude location to be at the center of
29+
* the search circle - required
30+
* @param {Double} params.radius radius of the search in Kilometer - optional
31+
* @return {Promise.<Response,ResponseError>} a Promise
32+
*
33+
* Find relevant points of interest close to Barcelona
34+
*
35+
* ```js
36+
* amadeus.referenceData.locations.pointsOfInterest.get({
37+
* longitude: 2.160873,
38+
* latitude: 41.397158
39+
* });
40+
* ```
41+
*/
42+
get(params = {}) {
43+
return this.client.get('/v1/reference-data/locations/pois', params);
44+
}
45+
}
46+
47+
export default pointsOfInterest;

0 commit comments

Comments
 (0)