diff --git a/README.rst b/README.rst index 17172457..65476d8f 100644 --- a/README.rst +++ b/README.rst @@ -219,6 +219,12 @@ List of supported endpoints # Flight SeatMap Display POST amadeus.shopping.seatmaps.post(body) + # Flight Availabilities POST + amadeus.shopping.availability.flight_availabilities.post(body) + + # Branded Fares Upsell + amadeus.shopping.flight_offers.upselling.post(body) + # Flight Choice Prediction body = amadeus.shopping.flight_offers_search.get( originLocationCode='MAD', diff --git a/amadeus/namespaces/_shopping.py b/amadeus/namespaces/_shopping.py index bdb4e2a0..1f92a7b6 100644 --- a/amadeus/namespaces/_shopping.py +++ b/amadeus/namespaces/_shopping.py @@ -9,6 +9,7 @@ from amadeus.shopping._seatmaps import Seatmaps from amadeus.shopping._activities import Activities from amadeus.shopping._activity import Activity +from amadeus.shopping._availability import Availability class Shopping(Decorator, object): @@ -22,6 +23,7 @@ def __init__(self, client): self.flight_offers_search = FlightOffersSearch(client) self.seatmaps = Seatmaps(client) self.activities = Activities(client) + self.availability = Availability(client) def hotel_offer(self, offer_id): return HotelOffer(self.client, offer_id) @@ -31,4 +33,4 @@ def activity(self, activity_id): __all__ = ['FlightDates', 'FlightDestinations', 'FlightOffers', - 'FlightOffersSearch'] + 'FlightOffersSearch', 'Availability'] diff --git a/amadeus/shopping/_availability.py b/amadeus/shopping/_availability.py new file mode 100644 index 00000000..ab042dfb --- /dev/null +++ b/amadeus/shopping/_availability.py @@ -0,0 +1,8 @@ +from amadeus.client.decorator import Decorator +from .availability import FlightAvailabilities + + +class Availability(Decorator, object): + def __init__(self, client): + Decorator.__init__(self, client) + self.flight_availabilities = FlightAvailabilities(client) diff --git a/amadeus/shopping/_flight_offers.py b/amadeus/shopping/_flight_offers.py index 6331722d..11ecfdef 100644 --- a/amadeus/shopping/_flight_offers.py +++ b/amadeus/shopping/_flight_offers.py @@ -1,6 +1,7 @@ from amadeus.client.decorator import Decorator from amadeus.shopping.flight_offers._prediction import FlightChoicePrediction from amadeus.shopping.flight_offers._pricing import FlightOffersPrice +from amadeus.shopping.flight_offers._upselling import Upselling class FlightOffers(Decorator, object): @@ -8,3 +9,4 @@ def __init__(self, client): Decorator.__init__(self, client) self.prediction = FlightChoicePrediction(client) self.pricing = FlightOffersPrice(client) + self.upselling = Upselling(client) diff --git a/amadeus/shopping/availability/__init__.py b/amadeus/shopping/availability/__init__.py new file mode 100644 index 00000000..7ef2ed29 --- /dev/null +++ b/amadeus/shopping/availability/__init__.py @@ -0,0 +1,3 @@ +from ._flight_availabilities import FlightAvailabilities + +__all__ = ['FlightAvailabilities'] diff --git a/amadeus/shopping/availability/_flight_availabilities.py b/amadeus/shopping/availability/_flight_availabilities.py new file mode 100644 index 00000000..e7fb7686 --- /dev/null +++ b/amadeus/shopping/availability/_flight_availabilities.py @@ -0,0 +1,19 @@ +from amadeus.client.decorator import Decorator + + +class FlightAvailabilities(Decorator, object): + def post(self, body): + ''' + Get available seats in different fare classes + + .. code-block:: python + + amadeus.shopping.availability.flight_availabilities.post(body) + + :param body: the parameters to send to the API + + :rtype: amadeus.Response + :raises amadeus.ResponseError: if the request could not be completed + ''' + return self.client.post( + '/v1/shopping/availability/flight-availabilities', body) diff --git a/amadeus/shopping/flight_offers/__init__.py b/amadeus/shopping/flight_offers/__init__.py index 86811622..5144ccda 100644 --- a/amadeus/shopping/flight_offers/__init__.py +++ b/amadeus/shopping/flight_offers/__init__.py @@ -1,4 +1,6 @@ from ._prediction import FlightChoicePrediction from ._pricing import FlightOffersPrice +from ._upselling import Upselling -__all__ = ['FlightChoicePrediction', 'FlightOffersPrice'] +__all__ = ['FlightChoicePrediction', 'FlightOffersPrice', + 'Upselling'] diff --git a/amadeus/shopping/flight_offers/_upselling.py b/amadeus/shopping/flight_offers/_upselling.py new file mode 100644 index 00000000..917ca870 --- /dev/null +++ b/amadeus/shopping/flight_offers/_upselling.py @@ -0,0 +1,19 @@ +from amadeus.client.decorator import Decorator + + +class Upselling(Decorator, object): + def post(self, body): + ''' + Get flight offers with branded fares + + .. code-block:: python + + amadeus.shopping.flight_offers.upselling.post(body) + + :param body: the parameters to send to the API + + :rtype: amadeus.Response + :raises amadeus.ResponseError: if the request could not be completed + ''' + return self.client.post( + '/v1/shopping/flight-offers/upselling', body) diff --git a/docs/index.rst b/docs/index.rst index a9cdb7cc..83d55c45 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -65,7 +65,13 @@ Shopping/Hotels Shopping/FlightOffers =============== -.. autoclass:: amadeus.shopping.FlightOffersPrice +.. autoclass:: amadeus.shopping.flight_offers.FlightChoicePrediction + :members: post + +.. autoclass:: amadeus.shopping.flight_offers.FlightChoicePrice + :members: post + +.. autoclass:: amadeus.shopping.flight_offers.Upselling :members: post Shopping/Activities @@ -80,6 +86,12 @@ Shopping/Activities .. autoclass:: amadeus.shopping.Activity :members: get +Shopping/Availability +=============== + +.. autoclass:: amadeus.shopping.availability.FlightAvailabilities + :members: post + Travel/Analytics ================ diff --git a/specs/namespaces/namespaces_spec.py b/specs/namespaces/namespaces_spec.py index 6688e24b..e7ea4faf 100644 --- a/specs/namespaces/namespaces_spec.py +++ b/specs/namespaces/namespaces_spec.py @@ -41,6 +41,7 @@ expect(client.shopping.flight_offers).not_to(be_none) expect(client.shopping.flight_offers_search).not_to(be_none) expect(client.shopping.flight_offers.pricing).not_to(be_none) + expect(client.shopping.flight_offers.upselling).not_to(be_none) expect(client.shopping.seatmaps).not_to(be_none) @@ -50,6 +51,9 @@ expect(client.shopping.activities).not_to(be_none) + expect(client.shopping.availability).not_to(be_none) + expect(client.shopping.availability.flight_availabilities).not_to(be_none) + expect(client.e_reputation.hotel_sentiments).not_to(be_none) expect(client.airport).not_to(be_none) @@ -386,6 +390,20 @@ }} )) + with it('.shopping.availability.flight_availabilities.post'): + self.client.shopping.availability.flight_availabilities.post( + {'foo': 'bar'}) + expect(self.client.post).to(have_been_called_with( + '/v1/shopping/availability/flight-availabilities', {'foo': 'bar'} + )) + + with it('.shopping.flight_offers.upselling.post'): + self.client.shopping.flight_offers.upselling.post( + {'foo': 'bar'}) + expect(self.client.post).to(have_been_called_with( + '/v1/shopping/flight-offers/upselling', {'foo': 'bar'} + )) + with it('.booking.flight_order().get'): self.client.booking.flight_order('123').get(a='b') expect(self.client.get).to(have_been_called_with(