Skip to content

Commit 8b7350c

Browse files
authored
Merge pull request #157 from amadeus4dev/city-search
Add support for City Search API
2 parents 56a9522 + 98884c0 commit 8b7350c

File tree

6 files changed

+43
-1
lines changed

6 files changed

+43
-1
lines changed

README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ List of supported endpoints
243243
# Get a specific city or airport based on its id
244244
amadeus.reference_data.location('ALHR').get()
245245
246+
# City Search
247+
amadeus.reference_data.locations.cities.get(keyword='PAR')
248+
246249
# Airport Nearest Relevant Airport (for London)
247250
amadeus.reference_data.locations.airports.get(longitude=0.1278, latitude=51.5074)
248251

amadeus/reference_data/_locations.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from amadeus.reference_data.locations._point_of_interest import PointOfInterest
55
from amadeus.reference_data.locations._hotels import Hotels
66
from amadeus.reference_data.locations._hotel import Hotel
7+
from amadeus.reference_data.locations._cities import Cities
78

89

910
class Locations(Decorator, object):
@@ -13,6 +14,7 @@ def __init__(self, client):
1314
self.points_of_interest = PointsOfInterest(client)
1415
self.hotels = Hotels(client)
1516
self.hotel = Hotel(client)
17+
self.cities = Cities(client)
1618

1719
def point_of_interest(self, poi_id):
1820
return PointOfInterest(self.client, poi_id)
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from ._airports import Airports
22
from ._points_of_interest import PointsOfInterest
33
from ._hotel import Hotel
4+
from ._cities import Cities
45

5-
__all__ = ['Airports', 'PointsOfInterest', 'Hotel']
6+
__all__ = ['Airports', 'PointsOfInterest', 'Hotel', 'Cities']
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from amadeus.client.decorator import Decorator
2+
3+
4+
class Cities(Decorator, object):
5+
def get(self, **params):
6+
'''
7+
Returns cities that match a specific word or letters.
8+
9+
.. code-block:: python
10+
11+
12+
amadeus.reference_data.locations.cities.get(
13+
keyword='PARI'
14+
)
15+
16+
:param keyword: location query keyword.
17+
For example: ``PARI``
18+
19+
:rtype: amadeus.Response
20+
:raises amadeus.ResponseError: if the request could not be completed
21+
'''
22+
return self.client.get(
23+
'/v1/reference-data/locations/cities', **params)

docs/index.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ ReferenceData/Locations/Hotel
185185
.. autoclass:: amadeus.reference_data.locations.Hotel
186186
:members: get
187187

188+
ReferenceData/Locations/Cities
189+
=======================
190+
191+
.. autoclass:: amadeus.reference_data.locations.Cities
192+
:members: get
193+
188194
Helper/Location
189195
==================
190196

specs/namespaces/namespaces_spec.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
expect(client.reference_data.locations.hotels.by_city).not_to(be_none)
3030
expect(client.reference_data.locations.hotels.by_geocode).not_to(be_none)
3131
expect(client.reference_data.locations.hotel).not_to(be_none)
32+
expect(client.reference_data.locations.cities).not_to(be_none)
3233
expect(client.travel).not_to(be_none)
3334
expect(client.travel.analytics).not_to(be_none)
3435
expect(client.travel.analytics.air_traffic.traveled).not_to(be_none)
@@ -563,3 +564,9 @@
563564
expect(self.client.get).to(have_been_called_with(
564565
'/v1/reference-data/locations/hotel', a='b'
565566
))
567+
568+
with it('.reference_data.locations.cities.get'):
569+
self.client.reference_data.locations.cities.get(a='b')
570+
expect(self.client.get).to(have_been_called_with(
571+
'/v1/reference-data/locations/cities', a='b'
572+
))

0 commit comments

Comments
 (0)