Skip to content

Commit d9f5380

Browse files
committed
Add support for Tours and Activities API
1 parent 90fc644 commit d9f5380

File tree

6 files changed

+213
-24
lines changed

6 files changed

+213
-24
lines changed

README.md

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,15 @@ amadeus.booking.hotelBookings.post(
363363
)
364364
)
365365

366+
// On-Demand Flight Status
367+
// What's the current status of my flight?
368+
amadeus.schedule.flights.get({
369+
carrierCode: 'AZ',
370+
flightNumber: '319',
371+
scheduledDepartureDate: '2021-03-13'
372+
})
373+
374+
366375
// Points of Interest
367376
// What are the popular places in Barcelona (based a geo location and a radius)
368377
amadeus.referenceData.locations.pointsOfInterest.get({
@@ -378,10 +387,45 @@ amadeus.referenceData.locations.pointsOfInterest.bySquare.get({
378387
east: 2.177181
379388
})
380389

381-
// Points of Interest
382390
// Extract the information about point of interest with ID '9CB40CB5D0'
383391
amadeus.referenceData.locations.pointOfInterest('9CB40CB5D0').get()
384392

393+
// Safe Place
394+
// How safe is Barcelona? (based a geo location and a radius)
395+
amadeus.safety.safetyRatedLocations.get({
396+
latitude: 41.397158,
397+
longitude: 2.160873
398+
})
399+
400+
// How safe is Barcelona? (based on a square)
401+
amadeus.safety.safetyRatedLocations.bySquare.get({
402+
north: 41.397158,
403+
west: 2.160873,
404+
south: 41.394582,
405+
east: 2.177181
406+
})
407+
408+
// What is the safety information of a location based on its Id?
409+
amadeus.safety.safetyRatedLocation('Q930400801').get()
410+
411+
// Tours and Activities
412+
// What are the best tours and activities in Barcelona?
413+
amadeus.shopping.activities.get({
414+
latitude: 41.397158,
415+
longitude: 2.160873
416+
})
417+
418+
// What are the best tours and activities in Barcelona? (based on a Square)
419+
amadeus.shopping.activities.bySquare.get({
420+
north: 41.397158,
421+
west: 2.160873,
422+
south: 41.394582,
423+
east: 2.177181
424+
})
425+
426+
// Extract the information about an activity with ID '56777'
427+
amadeus.shopping.activity('56777').get()
428+
385429
// Hotel Ratings
386430
// Get Sentiment Analysis of reviews about Holiday Inn Paris Notre Dame.
387431
amadeus.eReputation.hotelSentiments.get({
@@ -432,29 +476,6 @@ amadeus.referenceData.recommendedLocations.get({
432476
travelerCountryCode: 'FR'
433477
})
434478

435-
// Safe Place
436-
// How safe is Barcelona? (based a geo location and a radius)
437-
amadeus.safety.safetyRatedLocations.get({
438-
latitude: 41.397158,
439-
longitude: 2.160873
440-
})
441-
// How safe is Barcelona? (based on a square)
442-
amadeus.safety.safetyRatedLocations.bySquare.get({
443-
north: 41.397158,
444-
west: 2.160873,
445-
south: 41.394582,
446-
east: 2.177181
447-
})
448-
// What is the safety information of a location based on it's Id?
449-
amadeus.safety.safetyRatedLocation('Q930400801').get()
450-
451-
// On-Demand Flight Status
452-
// What's the current status of my flight?
453-
amadeus.schedule.flights.get({
454-
carrierCode: 'AZ',
455-
flightNumber: '319',
456-
scheduledDepartureDate: '2021-03-13'
457-
})
458479
```
459480
460481
## Development & Contributing

spec/amadeus/namespaces.test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ describe('Namespaces', () => {
5252
expect(amadeus.shopping.flightOffers.pricing).toBeDefined();
5353
expect(amadeus.shopping.seatmaps).toBeDefined();
5454

55+
expect(amadeus.shopping.activities).toBeDefined();
56+
expect(amadeus.shopping.activities.bySquare).toBeDefined();
57+
expect(amadeus.shopping.activity).toBeDefined();
58+
5559
expect(amadeus.booking).toBeDefined();
5660
expect(amadeus.booking.flightOrders).toBeDefined();
5761

@@ -107,6 +111,10 @@ describe('Namespaces', () => {
107111
expect(amadeus.shopping.hotelOffersByHotel.get).toBeDefined();
108112
expect(amadeus.shopping.hotelOffer('XXX').get).toBeDefined();
109113

114+
expect(amadeus.shopping.activities.get).toBeDefined();
115+
expect(amadeus.shopping.activities.bySquare.get).toBeDefined();
116+
expect(amadeus.shopping.activity('XXX').get).toBeDefined();
117+
110118
expect(amadeus.booking.flightOrder('XXX').get).toBeDefined();
111119

112120
expect(amadeus.schedule.flights.get).toBeDefined();
@@ -331,6 +339,27 @@ describe('Namespaces', () => {
331339
.toHaveBeenCalledWith('/v2/shopping/hotel-offers/XXX', {});
332340
});
333341

342+
it('.amadeus.shopping.activities.get', () => {
343+
amadeus.client.get = jest.fn();
344+
amadeus.shopping.activities.get();
345+
expect(amadeus.client.get)
346+
.toHaveBeenCalledWith('/v1/shopping/activities', {});
347+
});
348+
349+
it('.amadeus.shopping.activities.bySquare.get', () => {
350+
amadeus.client.get = jest.fn();
351+
amadeus.shopping.activities.bySquare.get();
352+
expect(amadeus.client.get)
353+
.toHaveBeenCalledWith('/v1/shopping/activities/by-square', {});
354+
});
355+
356+
it('.amadeus.shopping.activity().get', () => {
357+
amadeus.client.get = jest.fn();
358+
amadeus.shopping.activity('XXX').get();
359+
expect(amadeus.client.get)
360+
.toHaveBeenCalledWith('/v1/shopping/activities/XXX');
361+
});
362+
334363
it('.amadeus.booking.flightOrder().get', () => {
335364
amadeus.client.get = jest.fn();
336365
amadeus.booking.flightOrder('XXX').get();

src/amadeus/namespaces/shopping.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import Seatmaps from './shopping/seatmaps';
66
import HotelOffers from './shopping/hotel_offers';
77
import HotelOffersByHotel from './shopping/hotel_offers_by_hotel';
88
import HotelOffer from './shopping/hotel_offer';
9+
import Activities from './shopping/activities';
10+
import Activity from './shopping/activity';
911

1012

1113
/**
@@ -39,6 +41,7 @@ class Shopping {
3941
this.seatmaps = new Seatmaps(client);
4042
this.hotelOffers = new HotelOffers(client);
4143
this.hotelOffersByHotel = new HotelOffersByHotel(client);
44+
this.activities = new Activities(client);
4245
}
4346

4447

@@ -51,6 +54,17 @@ class Shopping {
5154
hotelOffer(offerId) {
5255
return new HotelOffer(this.client, offerId);
5356
}
57+
58+
/**
59+
* Loads a namespaced path for a specific activity ID
60+
*
61+
* @param {string} [activityId] The ID of the activity for a dedicated tour or activity
62+
* @return {Activity}
63+
**/
64+
activity(activityId) {
65+
return new Activity(this.client, activityId);
66+
}
67+
5468
}
5569

5670
export default Shopping;
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import BySquare from './activities/by_square';
2+
3+
/**
4+
* A namespaced client for the
5+
* `/v1/shopping/activities` endpoints
6+
*
7+
* Access via the {@link Amadeus} object
8+
*
9+
* ```js
10+
* let amadeus = new Amadeus();
11+
* amadeus.shopping.activities
12+
* ```
13+
*
14+
* @param {Client} client
15+
*/
16+
class Activities {
17+
constructor(client) {
18+
this.client = client;
19+
this.bySquare = new BySquare(client);
20+
}
21+
22+
/**
23+
* /shopping/activities
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+
* What are the best tours and activities in Barcelona? (based a geo location and a radius)
34+
*
35+
* ```js
36+
* amadeus.shopping.activities.get({
37+
* longitude: 2.160873,
38+
* latitude: 41.397158
39+
* });
40+
* ```
41+
*/
42+
get(params = {}) {
43+
return this.client.get('/v1/shopping/activities', params);
44+
}
45+
}
46+
47+
export default Activities;
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/shopping/activities/by-square` endpoints
4+
*
5+
* Access via the {@link Amadeus} object
6+
*
7+
* ```js
8+
* let amadeus = new Amadeus();
9+
* amadeus.shopping.activities.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 tours and activities 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 tours and activities within an area in Barcelona
30+
*
31+
* ```js
32+
* amadeus.shopping.activities.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/shopping/activities/by-square', params);
42+
}
43+
}
44+
45+
export default bySquare;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* A namespaced client for the
3+
* `/v1/shopping/activities/{activityId}` endpoints
4+
*
5+
* Access via the {@link Amadeus} object
6+
*
7+
* ```js
8+
* let amadeus = new Amadeus();
9+
* amadeus.shopping.activity
10+
* ```
11+
*
12+
* @param {Client} client
13+
*/
14+
class Activity {
15+
constructor(client, activityId) {
16+
this.client = client;
17+
this.activityId = activityId;
18+
}
19+
20+
/**
21+
* Retieve information of an activity by its Id.
22+
*
23+
* What is the activity information with Id 3216547684?
24+
* ```js
25+
* amadeus.shopping.activity('3216547684').get();
26+
* ```
27+
*/
28+
get() {
29+
return this.client.get(`/v1/shopping/activities/${this.activityId}`);
30+
}
31+
}
32+
33+
export default Activity;

0 commit comments

Comments
 (0)