Skip to content

Commit 158d1cc

Browse files
committed
add support for retrieve pois
1 parent 31afed7 commit 158d1cc

File tree

6 files changed

+60
-3
lines changed

6 files changed

+60
-3
lines changed

README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ List of supported endpoints
290290
amadeus.reference_data.locations.points_of_interest.get(latitude=41.397158, longitude=2.160873)
291291
# What are the popular places in Barcelona? (based on a square)
292292
amadeus.reference_data.locations.points_of_interest.by_square.get(north=41.397158, west=2.160873, south=41.394582, east=2.177181)
293+
# Returns a single Point of Interest from a given id
294+
amadeus.reference_data.locations.point_of_interest('9CB40CB5D0').get()
293295
294296
# Trip Purpose Prediction
295297
amadeus.travel.predictions.trip_purpose.get(originLocationCode='ATH', destinationLocationCode='MAD', departureDate='2020-08-01', returnDate='2020-08-12', searchDate='2020-06-11')

amadeus/reference_data/_locations.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from amadeus.client.decorator import Decorator
22
from amadeus.reference_data.locations._airports import Airports
33
from amadeus.reference_data.locations._points_of_interest import PointsOfInterest
4+
from amadeus.reference_data.locations._point_of_interest import PointOfInterest
45

56

67
class Locations(Decorator, object):
@@ -9,6 +10,9 @@ def __init__(self, client):
910
self.airports = Airports(client)
1011
self.points_of_interest = PointsOfInterest(client)
1112

13+
def point_of_interest(self, poi_id):
14+
return PointOfInterest(self.client, poi_id)
15+
1216
def get(self, **params):
1317
'''
1418
Returns details for a specific airport.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from amadeus.client.decorator import Decorator
2+
3+
4+
class PointOfInterest(Decorator, object):
5+
def __init__(self, client, poi_id):
6+
Decorator.__init__(self, client)
7+
self.poi_id = poi_id
8+
9+
def get(self, **params):
10+
'''
11+
Returns a single Point of Interest from a given id.
12+
13+
.. code-block:: python
14+
15+
amadeus.reference_data.locations.point_of_interest('9CB40CB5D0').get()
16+
17+
:rtype: amadeus.Response
18+
:raises amadeus.ResponseError: if the request could not be completed
19+
'''
20+
return self.client.get('/v1/reference-data/locations/pois/{0}'
21+
.format(self.poi_id), **params)

docs/index.rst

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Shopping/Hotels
6565
.. autoclass:: amadeus.shopping.hotel.Offer
6666
:members: get
6767

68-
Shopping/Flight Offers
68+
Shopping/FlightOffers
6969
===============
7070

7171
.. autoclass:: amadeus.shopping.FlightOffersPrice
@@ -89,7 +89,7 @@ Travel/Predictions
8989
.. autoclass:: amadeus.travel.predictions.FlightDelay
9090
:members: get
9191

92-
Travel/Trip Parser
92+
Travel/TripParser
9393
================
9494

9595
.. autoclass:: amadeus.travel.TripParser
@@ -116,6 +116,18 @@ ReferenceData/Locations
116116
.. autoclass:: amadeus.reference_data.Airlines
117117
:members: get
118118

119+
ReferenceData/Locations/PointsOfInterest
120+
=======================
121+
122+
.. autoclass:: amadeus.reference_data.locations.PointsOfInterest
123+
:members: get
124+
125+
.. autoclass:: amadeus.reference_data.locations.points_of_interest.BySquare
126+
:members: get
127+
128+
.. autoclass:: amadeus.reference_data.locations.PointOfInterest
129+
:members: get
130+
119131
ReferenceData/Urls
120132
==================
121133

examples/points_of_interest/points_of_interest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,12 @@
2121
# print(response.data)
2222
except ResponseError as error:
2323
raise error
24+
25+
try:
26+
'''
27+
Give me information about a place based on it's ID
28+
'''
29+
response = amadeus.reference_data.locations.point_of_interest('9CB40CB5D0').get()
30+
# print(response.data)
31+
except ResponseError as error:
32+
raise error

specs/namespaces/namespaces_spec.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
expect(
2525
client.reference_data.locations.points_of_interest.by_square).not_to(
2626
be_none)
27-
27+
expect(client.reference_data.locations.point_of_interest).not_to(be_none)
2828
expect(client.travel).not_to(be_none)
2929
expect(client.travel.analytics).not_to(be_none)
3030
expect(client.travel.analytics.air_traffic.traveled).not_to(be_none)
@@ -80,6 +80,8 @@
8080
expect(
8181
client.reference_data.locations.points_of_interest.by_square.get
8282
).not_to(be_none)
83+
expect(client.reference_data.locations.point_of_interest(
84+
'9CB40CB5D0').get).not_to(be_none)
8385

8486
expect(client.travel.analytics.air_traffic.traveled.get).not_to(be_none)
8587
expect(client.travel.analytics.air_traffic.booked.get).not_to(be_none)
@@ -170,6 +172,13 @@
170172
'/v1/reference-data/locations/pois/by-square', a='b'
171173
))
172174

175+
with it('.reference_data.locations.point_of_interest().get'):
176+
self.client.reference_data.locations.point_of_interest(
177+
'XXX').get(a='b')
178+
expect(self.client.get).to(have_been_called_with(
179+
'/v1/reference-data/locations/pois/XXX', a='b'
180+
))
181+
173182
with it('.travel.analytics.air_traffic.traveled.get'):
174183
self.client.travel.analytics.air_traffic.traveled.get(a='b')
175184
expect(self.client.get).to(have_been_called_with(

0 commit comments

Comments
 (0)