Skip to content

Commit

Permalink
Add support for Tours and Activities API
Browse files Browse the repository at this point in the history
  • Loading branch information
alnacle committed Oct 1, 2020
1 parent 90fc644 commit d9f5380
Show file tree
Hide file tree
Showing 6 changed files with 213 additions and 24 deletions.
69 changes: 45 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,15 @@ amadeus.booking.hotelBookings.post(
)
)

// On-Demand Flight Status
// What's the current status of my flight?
amadeus.schedule.flights.get({
carrierCode: 'AZ',
flightNumber: '319',
scheduledDepartureDate: '2021-03-13'
})


// Points of Interest
// What are the popular places in Barcelona (based a geo location and a radius)
amadeus.referenceData.locations.pointsOfInterest.get({
Expand All @@ -378,10 +387,45 @@ amadeus.referenceData.locations.pointsOfInterest.bySquare.get({
east: 2.177181
})

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

// Safe Place
// How safe is Barcelona? (based a geo location and a radius)
amadeus.safety.safetyRatedLocations.get({
latitude: 41.397158,
longitude: 2.160873
})

// How safe is Barcelona? (based on a square)
amadeus.safety.safetyRatedLocations.bySquare.get({
north: 41.397158,
west: 2.160873,
south: 41.394582,
east: 2.177181
})

// What is the safety information of a location based on its Id?
amadeus.safety.safetyRatedLocation('Q930400801').get()

// Tours and Activities
// What are the best tours and activities in Barcelona?
amadeus.shopping.activities.get({
latitude: 41.397158,
longitude: 2.160873
})

// What are the best tours and activities in Barcelona? (based on a Square)
amadeus.shopping.activities.bySquare.get({
north: 41.397158,
west: 2.160873,
south: 41.394582,
east: 2.177181
})

// Extract the information about an activity with ID '56777'
amadeus.shopping.activity('56777').get()

// Hotel Ratings
// Get Sentiment Analysis of reviews about Holiday Inn Paris Notre Dame.
amadeus.eReputation.hotelSentiments.get({
Expand Down Expand Up @@ -432,29 +476,6 @@ amadeus.referenceData.recommendedLocations.get({
travelerCountryCode: 'FR'
})

// Safe Place
// How safe is Barcelona? (based a geo location and a radius)
amadeus.safety.safetyRatedLocations.get({
latitude: 41.397158,
longitude: 2.160873
})
// How safe is Barcelona? (based on a square)
amadeus.safety.safetyRatedLocations.bySquare.get({
north: 41.397158,
west: 2.160873,
south: 41.394582,
east: 2.177181
})
// What is the safety information of a location based on it's Id?
amadeus.safety.safetyRatedLocation('Q930400801').get()

// On-Demand Flight Status
// What's the current status of my flight?
amadeus.schedule.flights.get({
carrierCode: 'AZ',
flightNumber: '319',
scheduledDepartureDate: '2021-03-13'
})
```
## Development & Contributing
Expand Down
29 changes: 29 additions & 0 deletions spec/amadeus/namespaces.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ describe('Namespaces', () => {
expect(amadeus.shopping.flightOffers.pricing).toBeDefined();
expect(amadeus.shopping.seatmaps).toBeDefined();

expect(amadeus.shopping.activities).toBeDefined();
expect(amadeus.shopping.activities.bySquare).toBeDefined();
expect(amadeus.shopping.activity).toBeDefined();

expect(amadeus.booking).toBeDefined();
expect(amadeus.booking.flightOrders).toBeDefined();

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

expect(amadeus.shopping.activities.get).toBeDefined();
expect(amadeus.shopping.activities.bySquare.get).toBeDefined();
expect(amadeus.shopping.activity('XXX').get).toBeDefined();

expect(amadeus.booking.flightOrder('XXX').get).toBeDefined();

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

it('.amadeus.shopping.activities.get', () => {
amadeus.client.get = jest.fn();
amadeus.shopping.activities.get();
expect(amadeus.client.get)
.toHaveBeenCalledWith('/v1/shopping/activities', {});
});

it('.amadeus.shopping.activities.bySquare.get', () => {
amadeus.client.get = jest.fn();
amadeus.shopping.activities.bySquare.get();
expect(amadeus.client.get)
.toHaveBeenCalledWith('/v1/shopping/activities/by-square', {});
});

it('.amadeus.shopping.activity().get', () => {
amadeus.client.get = jest.fn();
amadeus.shopping.activity('XXX').get();
expect(amadeus.client.get)
.toHaveBeenCalledWith('/v1/shopping/activities/XXX');
});

it('.amadeus.booking.flightOrder().get', () => {
amadeus.client.get = jest.fn();
amadeus.booking.flightOrder('XXX').get();
Expand Down
14 changes: 14 additions & 0 deletions src/amadeus/namespaces/shopping.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import Seatmaps from './shopping/seatmaps';
import HotelOffers from './shopping/hotel_offers';
import HotelOffersByHotel from './shopping/hotel_offers_by_hotel';
import HotelOffer from './shopping/hotel_offer';
import Activities from './shopping/activities';
import Activity from './shopping/activity';


/**
Expand Down Expand Up @@ -39,6 +41,7 @@ class Shopping {
this.seatmaps = new Seatmaps(client);
this.hotelOffers = new HotelOffers(client);
this.hotelOffersByHotel = new HotelOffersByHotel(client);
this.activities = new Activities(client);
}


Expand All @@ -51,6 +54,17 @@ class Shopping {
hotelOffer(offerId) {
return new HotelOffer(this.client, offerId);
}

/**
* Loads a namespaced path for a specific activity ID
*
* @param {string} [activityId] The ID of the activity for a dedicated tour or activity
* @return {Activity}
**/
activity(activityId) {
return new Activity(this.client, activityId);
}

}

export default Shopping;
47 changes: 47 additions & 0 deletions src/amadeus/namespaces/shopping/activities.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import BySquare from './activities/by_square';

/**
* A namespaced client for the
* `/v1/shopping/activities` endpoints
*
* Access via the {@link Amadeus} object
*
* ```js
* let amadeus = new Amadeus();
* amadeus.shopping.activities
* ```
*
* @param {Client} client
*/
class Activities {
constructor(client) {
this.client = client;
this.bySquare = new BySquare(client);
}

/**
* /shopping/activities
*
* @param {Object} params
* @param {Double} params.latitude latitude location to be at the center of
* the search circle - required
* @param {Double} params.longitude longitude location to be at the center of
* the search circle - required
* @param {Double} params.radius radius of the search in Kilometer - optional
* @return {Promise.<Response,ResponseError>} a Promise
*
* What are the best tours and activities in Barcelona? (based a geo location and a radius)
*
* ```js
* amadeus.shopping.activities.get({
* longitude: 2.160873,
* latitude: 41.397158
* });
* ```
*/
get(params = {}) {
return this.client.get('/v1/shopping/activities', params);
}
}

export default Activities;
45 changes: 45 additions & 0 deletions src/amadeus/namespaces/shopping/activities/by_square.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* A namespaced client for the
* `/v1/shopping/activities/by-square` endpoints
*
* Access via the {@link Amadeus} object
*
* ```js
* let amadeus = new Amadeus();
* amadeus.shopping.activities.bySquare;
* ```
*
* @param {Client} client
*/
class bySquare {
constructor(client) {
this.client = client;
}

/**
* Returns a list of tours and activities a given area.
*
* @param {Object} params
* @param {Double} params.north latitude north of bounding box - required
* @param {Double} params.west longitude west of bounding box - required
* @param {Double} params.south latitude south of bounding box - required
* @param {Double} params.east longitude east of bounding box - required
* @return {Promise.<Response,ResponseError>} a Promise
*
* Find relevant tours and activities within an area in Barcelona
*
* ```js
* amadeus.shopping.activities.bySquare.get({
* north: 41.397158,
* west: 2.160873,
* south: 41.394582,
* east: 2.177181
* });
* ```
*/
get(params = {}) {
return this.client.get('/v1/shopping/activities/by-square', params);
}
}

export default bySquare;
33 changes: 33 additions & 0 deletions src/amadeus/namespaces/shopping/activity.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* A namespaced client for the
* `/v1/shopping/activities/{activityId}` endpoints
*
* Access via the {@link Amadeus} object
*
* ```js
* let amadeus = new Amadeus();
* amadeus.shopping.activity
* ```
*
* @param {Client} client
*/
class Activity {
constructor(client, activityId) {
this.client = client;
this.activityId = activityId;
}

/**
* Retieve information of an activity by its Id.
*
* What is the activity information with Id 3216547684?
* ```js
* amadeus.shopping.activity('3216547684').get();
* ```
*/
get() {
return this.client.get(`/v1/shopping/activities/${this.activityId}`);
}
}

export default Activity;

0 comments on commit d9f5380

Please sign in to comment.