Skip to content

Commit e1d2830

Browse files
authored
Merge pull request #27 from anthonyroux/hotel_v2
Migration from the hotel v1 to hotel v2
2 parents 991a5b3 + 738cc8b commit e1d2830

File tree

12 files changed

+76
-97
lines changed

12 files changed

+76
-97
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ htmlcov
1111
_docs
1212
dist
1313
build
14+
.vscode
15+
env

README.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ would be:
109109
Similarly, to select a resource by ID, you can pass in the ID to the
110110
singular path.
111111

112-
For example, ``GET /v1/shopping/hotels/123/hotel-offers`` would be:
112+
For example, ``GET /v2/shopping/hotel-offers/XZY`` would be:
113113

114114
.. code:: py
115115
116-
amadeus.hotel(123).hotel_offers.get(...)
116+
amadeus.shopping.hotel_offer('4BA070CE929E135B3268A9F2D0C51E9D4A6CF318BA10485322FA2C7E78C7852E').get()
117117
118118
You can make any arbitrary API call as well directly with the ``.get``
119119
method:
@@ -227,7 +227,7 @@ List of supported endpoints
227227
# Which were the most searched flight destinations from Madrid in August 2017?
228228
amadeus.travel.analytics.air_traffic.searched.get(originCityCode='MAD', marketCountryCode='ES', searchPeriod='2017-08')
229229
# How many people in Spain searched for a trip from Madrid to New-York in September 2017?
230-
amadeus.travel.analytics.air_traffic.searched_by_destination.get(originCityCode='MAD', destinationCityCode='NYC', marketCountryCode='ES', searchPeriod='2017-08')
230+
amadeus.travel.analytics.air_traffic.searched_by_destination.get(originCityCode='MAD', destinationCityCode='NYC', marketCountryCode='ES', searchPeriod='2017-08')
231231
232232
# Flight Most Booked Destinations
233233
amadeus.travel.analytics.air_traffic.booked.get(originCityCode='MAD', period='2017-08')
@@ -240,13 +240,13 @@ List of supported endpoints
240240
241241
# Hotel Search
242242
# Get list of Hotels by city code
243-
amadeus.shopping.hotel_offers.get(cityCode = 'MAD')
244-
# Get list of offers for a specific Hotel
245-
amadeus.shopping.hotel('SMPARCOL').hotel_offers.get()
246-
# Confirm the availability of a specific offer for a specific Hotel
247-
amadeus.shopping.hotel('SMPARCOL').offer('4BA070BA10485322FA2C7E78C7852E').get()
243+
amadeus.shopping.hotel_offers.get(cityCode = 'LON')
244+
# Get list of offers for a specific hotel
245+
amadeus.shopping.hotel_offers_by_hotel.get(hotelId = 'IALONCHO')
246+
# Confirm the availability of a specific offer
247+
amadeus.shopping.hotel_offer('D5BEE9D0D08B6678C2F5FAD910DC110BCDA187D21D4FCE68ED423426D0A246BB').get()
248+
248249
249-
250250
Development & Contributing
251251
--------------------------
252252

amadeus/namespaces/_shopping.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
from amadeus.shopping._flight_destinations import FlightDestinations
44
from amadeus.shopping._flight_offers import FlightOffers
55
from amadeus.shopping._hotel_offers import HotelOffers
6-
from amadeus.shopping._hotel import Hotel
6+
from amadeus.shopping._hotel_offers_by_hotel import HotelOffersByHotel
7+
from amadeus.shopping._hotel_offer import HotelOffer
78

89

910
class Shopping(Decorator, object):
@@ -13,9 +14,10 @@ def __init__(self, client):
1314
self.flight_destinations = FlightDestinations(client)
1415
self.flight_offers = FlightOffers(client)
1516
self.hotel_offers = HotelOffers(client)
17+
self.hotel_offers_by_hotel = HotelOffersByHotel(client)
1618

17-
def hotel(self, hotel_id):
18-
return Hotel(self.client, hotel_id)
19+
def hotel_offer(self, offer_id):
20+
return HotelOffer(self.client, offer_id)
1921

2022

2123
__all__ = ['FlightDates', 'FlightDestinations', 'FlightOffers']

amadeus/shopping/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22
from ._flight_dates import FlightDates
33
from ._flight_destinations import FlightDestinations
44
from ._hotel_offers import HotelOffers
5+
from ._hotel_offers_by_hotel import HotelOffersByHotel
6+
from ._hotel_offer import HotelOffer
57

6-
__all__ = ['FlightOffers', 'FlightDates', 'FlightDestinations', 'HotelOffers']
8+
__all__ = ['FlightOffers', 'FlightDates', 'FlightDestinations',
9+
'HotelOffers', 'HotelOffersByHotel', 'HotelOffer']

amadeus/shopping/_hotel.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

amadeus/shopping/_hotel_offer.py

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 HotelOffer(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('XXX').get
16+
17+
:rtype: amadeus.Response
18+
:raises amadeus.ResponseError: if the request could not be completed
19+
'''
20+
return self.client.get('/v2/shopping/hotel-offers/{0}'
21+
.format(self.offer_id), **params)

amadeus/shopping/_hotel_offers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@ def get(self, **params):
66
'''
77
Search for hotels and retrieve availability and rates information.
88
9-
Use either `cityCode`, `longitude` and `latitude` or `hotels` to
9+
Use either `cityCode`, `longitude` and `latitude` or `hotelIds` to
1010
make a search.
1111
1212
.. code-block:: python
1313
1414
amadeus.shopping.hotel_offers.get(cityCode='PAR')
1515
amadeus.shopping.hotel_offers.get(longitude=49.0, latitude=2.0)
16-
amadeus.shopping.hotel_offers.get(hotels='RTPAR001, RTPAR002')
16+
amadeus.shopping.hotel_offers.get(hotelIds='RTPAR001, RTPAR002')
1717
1818
:param cityCode: the City IATA code for which to find a hotel, for
1919
example ``"BOS"`` for Boston.
2020
:param latitude: latitude of geographic location to search around.
2121
For example: ``52.5238``
2222
:param longitude: longitude of geographic location to search around.
2323
For example: ``13.3835``
24-
:param hotels: Comma separated list of Amadeus hotel codes to request.
24+
:param hotelIds: Comma separated list of Amadeus hotel codes to request.
2525
Example: ``RTPAR001``
2626
2727
:rtype: amadeus.Response
2828
:raises amadeus.ResponseError: if the request could not be completed
2929
'''
30-
return self.client.get('/v1/shopping/hotel-offers', **params)
30+
return self.client.get('/v2/shopping/hotel-offers', **params)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from amadeus.client.decorator import Decorator
2+
3+
4+
class HotelOffersByHotel(Decorator, object):
5+
def get(self, **params):
6+
'''
7+
Get all offers for Holiday Inn Paris Notre Dame.
8+
9+
.. code-block:: python
10+
11+
amadeus.shopping.hotel_offers_by_hotel.get(hotelId='XKPARC12')
12+
13+
:param hotelId: Amadeus Property Code (8 chars), for
14+
example ``XKPARC12``.
15+
16+
:rtype: amadeus.Response
17+
:raises amadeus.ResponseError: if the request could not be completed
18+
'''
19+
return self.client.get('/v2/shopping/hotel-offers/by-hotel', **params)

amadeus/shopping/hotel/__init__.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

amadeus/shopping/hotel/_hotel_offers.py

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)