Skip to content

Commit 80e4367

Browse files
authored
Merge pull request #150 from amadeus4dev/hotel-search-v3
Add hotel search v3
2 parents 7794223 + 7867c0b commit 80e4367

File tree

6 files changed

+83
-2
lines changed

6 files changed

+83
-2
lines changed

README.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,18 @@ List of supported endpoints
257257
258258
# Hotel Search
259259
# Get list of Hotels by city code
260-
amadeus.shopping.hotel_offers.get(cityCode = 'LON')
260+
amadeus.shopping.hotel_offers.get(cityCode='LON')
261261
# Get list of offers for a specific hotel
262-
amadeus.shopping.hotel_offers_by_hotel.get(hotelId = 'BGLONBGB')
262+
amadeus.shopping.hotel_offers_by_hotel.get(hotelId='BGLONBGB')
263263
# Confirm the availability of a specific offer
264264
offerId = amadeus.shopping.hotel_offer('8123DD9DE5102DADF5DA3B55C8C575F54114336EE718578753888747FE0652FC').get()
265265
266+
# Hotel Search v3
267+
# Get list of available offers by hotel ids
268+
amadeus.shopping.hotel_offers_search.get(hotelIds='RTPAR001', adults='2')
269+
# Check conditions of a specific offer
270+
amadeus.shopping.hotel_offer_search('XXX').get()
271+
266272
# Hotel List
267273
# Get list of hotels by hotel id
268274
amadeus.reference_data.locations.hotels.by_hotels.get(hotelIds='ADPAR001')

amadeus/namespaces/_shopping.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
from amadeus.shopping._activities import Activities
1111
from amadeus.shopping._activity import Activity
1212
from amadeus.shopping._availability import Availability
13+
from amadeus.shopping._hotel_offer_search import HotelOfferSearch
14+
from amadeus.shopping._hotel_offers_search import HotelOffersSearch
1315

1416

1517
class Shopping(Decorator, object):
@@ -24,10 +26,14 @@ def __init__(self, client):
2426
self.seatmaps = Seatmaps(client)
2527
self.activities = Activities(client)
2628
self.availability = Availability(client)
29+
self.hotel_offers_search = HotelOffersSearch(client)
2730

2831
def hotel_offer(self, offer_id):
2932
return HotelOffer(self.client, offer_id)
3033

34+
def hotel_offer_search(self, offer_id):
35+
return HotelOfferSearch(self.client, offer_id)
36+
3137
def activity(self, activity_id):
3238
return Activity(self.client, activity_id)
3339

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 HotelOfferSearch(Decorator, object):
5+
def __init__(self, client, offer_id):
6+
Decorator.__init__(self, client)
7+
self.offer_id = offer_id
8+
9+
def get(self, **params):
10+
'''
11+
Returns details for a specific offer
12+
13+
.. code-block:: python
14+
15+
amadeus.shopping.hotel_offer_search('XXX').get
16+
17+
:rtype: amadeus.Response
18+
:raises amadeus.ResponseError: if the request could not be completed
19+
'''
20+
return self.client.get('/v3/shopping/hotel-offers/{0}'
21+
.format(self.offer_id), **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 HotelOffersSearch(Decorator, object):
5+
def get(self, **params):
6+
'''
7+
Get all offers given hotels
8+
9+
.. code-block:: python
10+
11+
amadeus.shopping.hotel_offers_search.get(hotelIds=RTPAR001',
12+
adults='2')
13+
14+
:param hotelId: Amadeus Property Code (8 chars), for
15+
example ``RTPAR001``.
16+
17+
:param adults: the number of adult passengers with age 12 or older
18+
19+
:rtype: amadeus.Response
20+
:raises amadeus.ResponseError: if the request could not be completed
21+
'''
22+
return self.client.get('/v3/shopping/hotel-offers', **params)

docs/index.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ Shopping/Hotels
6262
.. autoclass:: amadeus.shopping.hotel.Offer
6363
:members: get
6464

65+
.. autoclass:: amadeus.shopping.hotel.HotelOffersSearch
66+
:members: get
67+
68+
.. autoclass:: amadeus.shopping.hotel.HotelOfferSearch
69+
:members: get
70+
6571
Shopping/FlightOffers
6672
===============
6773

specs/namespaces/namespaces_spec.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
expect(client.shopping.hotel_offer).not_to(be_none)
5353
expect(client.shopping.hotel_offers_by_hotel).not_to(be_none)
5454

55+
expect(client.shopping.hotel_offers_search).not_to(be_none)
56+
expect(client.shopping.hotel_offer_search).not_to(be_none)
57+
5558
expect(client.shopping.activities).not_to(be_none)
5659

5760
expect(client.shopping.availability).not_to(be_none)
@@ -133,6 +136,9 @@
133136
expect(client.shopping.hotel_offers_by_hotel.get).not_to(be_none)
134137
expect(client.shopping.hotel_offer('123').get).not_to(be_none)
135138

139+
expect(client.shopping.hotel_offers_search.get).not_to(be_none)
140+
expect(client.shopping.hotel_offer_search('123').get).not_to(be_none)
141+
136142
expect(client.e_reputation.hotel_sentiments.get).not_to(be_none)
137143

138144
expect(client.airport.predictions.on_time.get).not_to(be_none)
@@ -299,6 +305,20 @@
299305
'/v2/shopping/hotel-offers/XXX', a='b'
300306
))
301307

308+
with it('.shopping.hotel_offers_search.get'):
309+
self.client.shopping.hotel_offers_search.get(
310+
hotelIds='RTPAR001', adults=2)
311+
expect(self.client.get).to(have_been_called_with(
312+
'/v3/shopping/hotel-offers', hotelIds='RTPAR001',
313+
adults=2
314+
))
315+
316+
with it('.shopping.hotel_offer_search().get'):
317+
self.client.shopping.hotel_offer_search('XXX').get(a='b')
318+
expect(self.client.get).to(have_been_called_with(
319+
'/v3/shopping/hotel-offers/XXX', a='b'
320+
))
321+
302322
with it('.shopping.seatmaps.get'):
303323
self.client.shopping.seatmaps.get(**{'a': 'b'})
304324
expect(self.client.get).to(have_been_called_with(

0 commit comments

Comments
 (0)