Skip to content

Commit

Permalink
Adding support for POI API's retrieve endpoint
Browse files Browse the repository at this point in the history
Adding support for POI API's retrieve endpoint
  • Loading branch information
akshitsingla authored May 21, 2020
2 parents f22c3f4 + cb76102 commit bbb4fe1
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 8 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ amadeus.shopping.flightOffersSearch.get({


// Flight Create Orders
// To book the flight-offer(s) suggested by flightOffersSearch API
// To book the flight-offer(s) suggested by flightOffersSearch API
// and create a flight-order with travelers' information
amadeus.shopping.flightOffersSearch.get({
originLocationCode: 'SYD',
Expand Down Expand Up @@ -248,7 +248,7 @@ amadeus.shopping.flightOffersSearch.get({
});

// Flight SeatMap Display
// To retrieve the seat map of each flight included
// To retrieve the seat map of each flight included
// in flight offers for MAD-NYC flight on 2020-08-01
amadeus.shopping.flightOffersSearch.get({
originLocationCode: 'SYD',
Expand Down Expand Up @@ -341,11 +341,11 @@ amadeus.shopping.hotelOffersByHotel.get({
// Confirm the availability of a specific offer id
amadeus.shopping.hotelOffer('XXX').get()

// Retrieve flight order with ID 'XXX'. This ID comes from the
// Retrieve flight order with ID 'XXX'. This ID comes from the
// Flight Create Orders API, which is a temporary ID in test environment.
amadeus.booking.flightOrder('XXX').get()

// Cancel flight order with ID 'XXX'. This ID comes from the
// Cancel flight order with ID 'XXX'. This ID comes from the
// Flight Create Orders API, which is a temporary ID in test environment.
amadeus.booking.flightOrder('XXX').delete()

Expand Down Expand Up @@ -374,6 +374,10 @@ 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()

// Hotel Ratings
// Get Sentiment Analysis of reviews about Holiday Inn Paris Notre Dame.
amadeus.eReputation.hotelSentiments.get({
Expand All @@ -396,7 +400,7 @@ amadeus.media.files.generatedPhotos.get({
})

// Flight Delay Prediction
// This machine learning API is based on a prediction model that takes the input of the user - time, carrier, airport and aircraft information;
// This machine learning API is based on a prediction model that takes the input of the user - time, carrier, airport and aircraft information;
// and predict the segment where the flight is likely to lay.
amadeus.travel.predictions.flightDelay.get({
originLocationCode: 'BRU',
Expand Down
9 changes: 9 additions & 0 deletions spec/amadeus/namespaces.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe('Namespaces', () => {
expect(amadeus.referenceData.location).toBeDefined();
expect(amadeus.referenceData.locations).toBeDefined();
expect(amadeus.referenceData.locations.airports).toBeDefined();
expect(amadeus.referenceData.locations.pointOfInterest).toBeDefined();
expect(amadeus.referenceData.locations.pointsOfInterest).toBeDefined();
expect(amadeus.referenceData.locations.pointsOfInterest.bySquare).toBeDefined();
expect(amadeus.referenceData.airlines).toBeDefined();
Expand Down Expand Up @@ -74,6 +75,7 @@ describe('Namespaces', () => {
expect(amadeus.referenceData.location('ALHR').get).toBeDefined();
expect(amadeus.referenceData.locations.get).toBeDefined();
expect(amadeus.referenceData.locations.airports.get).toBeDefined();
expect(amadeus.referenceData.locations.pointOfInterest('XXX').get).toBeDefined();
expect(amadeus.referenceData.locations.pointsOfInterest.get).toBeDefined();
expect(amadeus.referenceData.locations.pointsOfInterest.bySquare.get).toBeDefined();
expect(amadeus.referenceData.airlines.get).toBeDefined();
Expand Down Expand Up @@ -152,6 +154,13 @@ describe('Namespaces', () => {
.toHaveBeenCalledWith('/v1/reference-data/locations/pois', {});
});

it('.amadeus.referenceData.locations.pointOfInterest("XXX").get', () => {
amadeus.client.get = jest.fn();
amadeus.referenceData.locations.pointOfInterest('XXX').get();
expect(amadeus.client.get)
.toHaveBeenCalledWith('/v1/reference-data/locations/pois/XXX');
});

it('.amadeus.referenceData.locations.pointsOfInterest.bySquare.get', () => {
amadeus.client.get = jest.fn();
amadeus.referenceData.locations.pointsOfInterest.bySquare.get();
Expand Down
6 changes: 6 additions & 0 deletions src/amadeus/namespaces/reference_data/locations.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Airports from './locations/airports';
import PointOfInterest from './locations/poi';
import PointsOfInterest from './locations/pois';

/**
Expand Down Expand Up @@ -43,6 +44,11 @@ class Locations {
get(params = {}) {
return this.client.get('/v1/reference-data/locations', params);
}

pointOfInterest(poiId) {
return new PointOfInterest(this.client, poiId);
}

}

export default Locations;
33 changes: 33 additions & 0 deletions src/amadeus/namespaces/reference_data/locations/poi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* A namespaced client for the
* `/v1/reference-data/locations/pois` endpoints
*
* Access via the {@link Amadeus} object
*
* ```js
* let amadeus = new Amadeus();
* amadeus.referenceData.locations.pointOfInterest;
* ```
*
* @param {Client} client
*/
class PointOfInterest {
constructor(client, poiId) {
this.client = client;
this._poiId = poiId;
}

/**
* Extracts the information about point of interest with given ID
*
* Extract the information about point of interest with ID '9CB40CB5D0'
* ```js
* amadeus.referenceData.locations.pointOfInterest('9CB40CB5D0').get();
* ```
*/
get() {
return this.client.get(`/v1/reference-data/locations/pois/${this._poiId}`);
}
}

export default PointOfInterest;
6 changes: 3 additions & 3 deletions src/amadeus/namespaces/reference_data/locations/pois.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import BySquare from './points_of_interest/by-square';
*
* @param {Client} client
*/
class pointsOfInterest {
class PointsOfInterest {
constructor(client) {
this.client = client;
this.bySquare = new BySquare(client);
}

/**
* Returns a list of relevant points of interest near to a given point.
* Returns a list of relevant points of interest near to a given point
*
* @param {Object} params
* @param {Double} params.latitude latitude location to be at the center of
Expand All @@ -44,4 +44,4 @@ class pointsOfInterest {
}
}

export default pointsOfInterest;
export default PointsOfInterest;

0 comments on commit bbb4fe1

Please sign in to comment.