Skip to content

Commit 7794223

Browse files
authored
Merge pull request #149 from amadeus4dev/hotel-list-api
Add support for hotel list endpoints
2 parents a084921 + 5b7ff33 commit 7794223

File tree

9 files changed

+140
-2
lines changed

9 files changed

+140
-2
lines changed

README.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,14 @@ List of supported endpoints
263263
# Confirm the availability of a specific offer
264264
offerId = amadeus.shopping.hotel_offer('8123DD9DE5102DADF5DA3B55C8C575F54114336EE718578753888747FE0652FC').get()
265265
266+
# Hotel List
267+
# Get list of hotels by hotel id
268+
amadeus.reference_data.locations.hotels.by_hotels.get(hotelIds='ADPAR001')
269+
# Get list of hotels by city code
270+
amadeus.reference_data.locations.hotels.by_city.get(cityCode='PAR')
271+
# Get list of hotels by a geocode
272+
amadeus.reference_data.locations.hotels.by_geocode.get(longitude=2.160873,latitude=41.397158)
273+
266274
# Hotel Booking
267275
# The offerId comes from the hotel_offer above
268276
amadeus.booking.hotel_bookings.post(offerId, guests, payments)

amadeus/reference_data/_locations.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
from amadeus.reference_data.locations._airports import Airports
33
from amadeus.reference_data.locations._points_of_interest import PointsOfInterest
44
from amadeus.reference_data.locations._point_of_interest import PointOfInterest
5+
from amadeus.reference_data.locations._hotels import Hotels
56

67

78
class Locations(Decorator, object):
89
def __init__(self, client):
910
Decorator.__init__(self, client)
1011
self.airports = Airports(client)
1112
self.points_of_interest = PointsOfInterest(client)
13+
self.hotels = Hotels(client)
1214

1315
def point_of_interest(self, poi_id):
1416
return PointOfInterest(self.client, poi_id)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from amadeus.client.decorator import Decorator
2+
from amadeus.reference_data.locations.hotels import ByCity
3+
from amadeus.reference_data.locations.hotels import ByGeocode
4+
from amadeus.reference_data.locations.hotels import ByHotels
5+
6+
7+
class Hotels(Decorator, object):
8+
def __init__(self, client):
9+
Decorator.__init__(self, client)
10+
self.by_hotels = ByHotels(client)
11+
self.by_geocode = ByGeocode(client)
12+
self.by_city = ByCity(client)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from ._by_city import ByCity
2+
from ._by_geocode import ByGeocode
3+
from ._by_hotels import ByHotels
4+
5+
__all__ = ['ByCity', 'ByGeocode', 'ByHotels']
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from amadeus.client.decorator import Decorator
2+
3+
4+
class ByCity(Decorator, object):
5+
def get(self, **params):
6+
'''
7+
Searches for hotel in a given city.
8+
9+
.. code-block:: python
10+
11+
12+
amadeus.reference_data.locations.hotels.by_city.get(
13+
cityCode='PAR')
14+
15+
:param cityCode: the City IATA code for which to find a hotel, for
16+
example ``"PAR"`` for Paris.
17+
18+
:rtype: amadeus.Response
19+
:raises amadeus.ResponseError: if the request could not be completed
20+
'''
21+
return self.client.get(
22+
'/v1/reference-data/locations/hotels/by-city', **params)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from amadeus.client.decorator import Decorator
2+
3+
4+
class ByGeocode(Decorator, object):
5+
def get(self, **params):
6+
'''
7+
Searches for hotel using a geocode.
8+
9+
.. code-block:: python
10+
11+
12+
amadeus.reference_data.locations.hotels.by_geocode.get(
13+
longitude=2.160873,
14+
latitude=41.397158
15+
)
16+
17+
:param latitude: latitude of geographic location to search around.
18+
For example: ``41.397158``
19+
:param longitude: longitude of geographic location to search around.
20+
For example: ``2.160873``
21+
22+
:rtype: amadeus.Response
23+
:raises amadeus.ResponseError: if the request could not be completed
24+
'''
25+
return self.client.get(
26+
'/v1/reference-data/locations/hotels/by-geocode', **params)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from amadeus.client.decorator import Decorator
2+
3+
4+
class ByHotels(Decorator, object):
5+
def get(self, **params):
6+
'''
7+
Searches for hotel using it's unique id.
8+
9+
.. code-block:: python
10+
11+
12+
amadeus.reference_data.locations.hotels.by_hotels.get(
13+
hotelIds=["ADPAR001"])
14+
15+
:param hotelIds: Amadeus Property Codes (8 chars)
16+
For example: ``["ADPAR001"]``
17+
18+
:rtype: amadeus.Response
19+
:raises amadeus.ResponseError: if the request could not be completed
20+
'''
21+
return self.client.get(
22+
'/v1/reference-data/locations/hotels/by-hotels', **params)

docs/index.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,18 @@ ReferenceData/RecommendedLocations
161161
.. autoclass:: amadeus.reference_data.RecommendedLocations
162162
:members: get
163163

164+
ReferenceData/Locations/Hotels
165+
=======================
166+
167+
.. autoclass:: amadeus.reference_data.hotels.ByHotels
168+
:members: get
169+
170+
.. autoclass:: amadeus.reference_data.hotels.ByCity
171+
:members: get
172+
173+
.. autoclass:: amadeus.reference_data.hotels.ByGeocode
174+
:members: get
175+
164176
Helper/Location
165177
==================
166178

specs/namespaces/namespaces_spec.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424
expect(
2525
client.reference_data.locations.points_of_interest.by_square).not_to(
2626
be_none)
27-
expect(client.reference_data.locations.point_of_interest).not_to(be_none)
27+
expect(client.reference_data.locations.hotels).not_to(be_none)
28+
expect(client.reference_data.locations.hotels.by_hotels).not_to(be_none)
29+
expect(client.reference_data.locations.hotels.by_city).not_to(be_none)
30+
expect(client.reference_data.locations.hotels.by_geocode).not_to(be_none)
2831
expect(client.travel).not_to(be_none)
2932
expect(client.travel.analytics).not_to(be_none)
3033
expect(client.travel.analytics.air_traffic.traveled).not_to(be_none)
@@ -105,7 +108,12 @@
105108
expect(client.reference_data.locations.point_of_interest(
106109
'9CB40CB5D0').get).not_to(be_none)
107110
expect(client.reference_data.recommended_locations.get).not_to(be_none)
108-
111+
expect(
112+
client.reference_data.locations.hotels.by_city.get).not_to(be_none)
113+
expect(
114+
client.reference_data.locations.hotels.by_hotels.get).not_to(be_none)
115+
expect(
116+
client.reference_data.locations.hotels.by_geocode.get).not_to(be_none)
109117
expect(client.travel.analytics.air_traffic.traveled.get).not_to(be_none)
110118
expect(client.travel.analytics.air_traffic.booked.get).not_to(be_none)
111119
expect(
@@ -509,3 +517,24 @@
509517
expect(self.client.get).to(have_been_called_with(
510518
'/v1/duty-of-care/diseases/covid19-area-report', a='b'
511519
))
520+
521+
with it('.reference_data.locations.hotels.by_hotels.get'):
522+
self.client.reference_data.locations.hotels.by_hotels.get(
523+
a='b')
524+
expect(self.client.get).to(have_been_called_with(
525+
'/v1/reference-data/locations/hotels/by-hotels', a='b'
526+
))
527+
528+
with it('.reference_data.locations.hotels.by_city.get'):
529+
self.client.reference_data.locations.hotels.by_city.get(
530+
a='b')
531+
expect(self.client.get).to(have_been_called_with(
532+
'/v1/reference-data/locations/hotels/by-city', a='b'
533+
))
534+
535+
with it('.reference_data.locations.hotels.by_geocode.get'):
536+
self.client.reference_data.locations.hotels.by_geocode.get(
537+
a='b')
538+
expect(self.client.get).to(have_been_called_with(
539+
'/v1/reference-data/locations/hotels/by-geocode', a='b'
540+
))

0 commit comments

Comments
 (0)