Skip to content

Commit a298ae7

Browse files
authored
Merge pull request #110 from amadeus4dev/location-score
Add support for location score
2 parents 6c581c3 + 2851fb9 commit a298ae7

File tree

6 files changed

+114
-0
lines changed

6 files changed

+114
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,12 @@ amadeus.referenceData.locations.pointsOfInterest.bySquare.get({
386386
// Extract the information about point of interest with ID '9CB40CB5D0'
387387
amadeus.referenceData.locations.pointOfInterest('9CB40CB5D0').get()
388388

389+
// Location Score
390+
amadeus.location.analytics.categoryRatedAreas.get({
391+
latitude : 41.397158,
392+
longitude : 2.160873
393+
})
394+
389395
// Safe Place
390396
// How safe is Barcelona? (based a geo location and a radius)
391397
amadeus.safety.safetyRatedLocations.get({

spec/amadeus/namespaces.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ describe('Namespaces', () => {
8787
expect(amadeus.safety.safetyRatedLocations).toBeDefined();
8888
expect(amadeus.safety.safetyRatedLocations.bySquare).toBeDefined();
8989
expect(amadeus.safety.safetyRatedLocation).toBeDefined();
90+
91+
expect(amadeus.location).toBeDefined();
92+
expect(amadeus.location.analytics).toBeDefined();
93+
expect(amadeus.location.analytics.categoryRatedAreas).toBeDefined();
9094
});
9195

9296
it('should define all expected .get methods', () => {
@@ -135,6 +139,9 @@ describe('Namespaces', () => {
135139
expect(amadeus.safety.safetyRatedLocations.get).toBeDefined();
136140
expect(amadeus.safety.safetyRatedLocations.bySquare.get).toBeDefined();
137141
expect(amadeus.safety.safetyRatedLocation('XXX').get).toBeDefined();
142+
143+
expect(amadeus.location.analytics.categoryRatedAreas.get).toBeDefined();
144+
138145
});
139146

140147
it('should define all expected .post methods', () => {
@@ -207,6 +214,13 @@ describe('Namespaces', () => {
207214
.toHaveBeenCalledWith('/v1/reference-data/locations/pois/by-square', {});
208215
});
209216

217+
it('.amadeus.location.analytics.categoryRatedAreas.get', () => {
218+
amadeus.client.get = jest.fn();
219+
amadeus.location.analytics.categoryRatedAreas.get();
220+
expect(amadeus.client.get)
221+
.toHaveBeenCalledWith('/v1/location/analytics/category-rated-areas', {});
222+
});
223+
210224
it('.amadeus.referenceData.airlines.get', () => {
211225
amadeus.client.get = jest.fn();
212226
amadeus.referenceData.airlines.get();

src/amadeus.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Airport from './amadeus/namespaces/airport';
1111
import Safety from './amadeus/namespaces/safety';
1212
import Schedule from './amadeus/namespaces/schedule';
1313
import Analytics from './amadeus/namespaces/analytics';
14+
import Location from './amadeus/namespaces/location';
1415

1516

1617
/**
@@ -74,6 +75,7 @@ class Amadeus {
7475
this.safety = new Safety(this.client);
7576
this.schedule = new Schedule(this.client);
7677
this.analytics = new Analytics(this.client);
78+
this.location = new Location(this.client);
7779
}
7880

7981
/**

src/amadeus/namespaces/location.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import Analytics from './location/analytics';
2+
3+
/**
4+
* A namespaced client for the
5+
* `/v1/location` endpoints
6+
*
7+
* Access via the {@link Amadeus} object
8+
*
9+
* ```js
10+
* let amadeus = new Amadeus();
11+
* amadeus.location;
12+
* ```
13+
*
14+
* @param {Client} client
15+
* @property {analytics} analytics
16+
*/
17+
class Location {
18+
constructor(client) {
19+
this.client = client;
20+
this.analytics = new Analytics(client);
21+
}
22+
}
23+
24+
export default Location;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import CategoryRatedAreas from './analytics/category_rated_areas';
2+
3+
/**
4+
* A namespaced client for the
5+
* `/v1/location/analytics` endpoints
6+
*
7+
* Access via the {@link Amadeus} object
8+
*
9+
* ```js
10+
* let amadeus = new Amadeus();
11+
* amadeus.location;
12+
* ```
13+
*
14+
* @param {Client} client
15+
* @property {analytics} CategoryRatedAreas
16+
*/
17+
class Analytics {
18+
constructor(client) {
19+
this.client = client;
20+
this.categoryRatedAreas = new CategoryRatedAreas(client);
21+
}
22+
}
23+
24+
export default Analytics;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* A namespaced client for the
3+
* `/v1/location/analytics/category-rated-areas` endpoints
4+
*
5+
* Access via the {@link Amadeus} object
6+
*
7+
* ```js
8+
* let amadeus = new Amadeus();
9+
* amadeus.location.analytics.categoryRatedAreas;
10+
* ```
11+
*
12+
* @param {Client} client
13+
*/
14+
class CategoryRatedAreas {
15+
constructor(client) {
16+
this.client = client;
17+
}
18+
19+
/**
20+
* Gets popularity score for location categories
21+
*
22+
* @param {Object} params
23+
* @param {Double} params.latitude latitude location to be at the center of
24+
* the search circle - required
25+
* @param {Double} params.longitude longitude location to be at the center of
26+
* the search circle - required
27+
* @param {Double} params.radius radius of the search in Kilometer - optional
28+
* @return {Promise.<Response,ResponseError>} a Promise
29+
*
30+
* Gets popularity score for location categories in Barcelona
31+
*
32+
* ```js
33+
* amadeus.location.analytics.categoryRatedAreas.get({
34+
* longitude: 2.160873,
35+
* latitude: 41.397158
36+
* });
37+
* ```
38+
*/
39+
get(params = {}) {
40+
return this.client.get('/v1/location/analytics/category-rated-areas', params);
41+
}
42+
}
43+
44+
export default CategoryRatedAreas;

0 commit comments

Comments
 (0)