From 7e60cf5cb68acba28574ae9e9048a41cba7a9e8a Mon Sep 17 00:00:00 2001 From: Anna Tsolakou Date: Mon, 10 May 2021 18:12:15 +0200 Subject: [PATCH 1/3] add support for flight availability --- README.rst | 3 +++ amadeus/namespaces/_shopping.py | 4 +++- amadeus/shopping/_availability.py | 8 ++++++++ amadeus/shopping/availability/__init__.py | 3 +++ .../availability/_flight_availabilities.py | 19 +++++++++++++++++++ docs/index.rst | 6 ++++++ specs/namespaces/namespaces_spec.py | 10 ++++++++++ 7 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 amadeus/shopping/_availability.py create mode 100644 amadeus/shopping/availability/__init__.py create mode 100644 amadeus/shopping/availability/_flight_availabilities.py diff --git a/README.rst b/README.rst index 17172457..bf920810 100644 --- a/README.rst +++ b/README.rst @@ -219,6 +219,9 @@ List of supported endpoints # Flight SeatMap Display POST amadeus.shopping.seatmaps.post(body) + # Flight Availabilities POST + amadeus.shopping.availability​.flight_availabilities.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/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..9171b70e --- /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/docs/index.rst b/docs/index.rst index a9cdb7cc..3c38c639 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -80,6 +80,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..7f10b300 100644 --- a/specs/namespaces/namespaces_spec.py +++ b/specs/namespaces/namespaces_spec.py @@ -50,6 +50,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 +389,13 @@ }} )) + 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('.booking.flight_order().get'): self.client.booking.flight_order('123').get(a='b') expect(self.client.get).to(have_been_called_with( From f03f76854213434d0701751d3e636ef11b75103d Mon Sep 17 00:00:00 2001 From: Anna Tsolakou Date: Tue, 11 May 2021 09:57:58 +0200 Subject: [PATCH 2/3] fix bad characters --- README.rst | 2 +- amadeus/shopping/availability/_flight_availabilities.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index bf920810..d852940a 100644 --- a/README.rst +++ b/README.rst @@ -220,7 +220,7 @@ List of supported endpoints amadeus.shopping.seatmaps.post(body) # Flight Availabilities POST - amadeus.shopping.availability​.flight_availabilities.post(body) + amadeus.shopping.availability.flight_availabilities.post(body) # Flight Choice Prediction body = amadeus.shopping.flight_offers_search.get( diff --git a/amadeus/shopping/availability/_flight_availabilities.py b/amadeus/shopping/availability/_flight_availabilities.py index 9171b70e..e7fb7686 100644 --- a/amadeus/shopping/availability/_flight_availabilities.py +++ b/amadeus/shopping/availability/_flight_availabilities.py @@ -8,7 +8,7 @@ def post(self, body): .. code-block:: python - amadeus.shopping.availability​.flight_availabilities.post(body) + amadeus.shopping.availability.flight_availabilities.post(body) :param body: the parameters to send to the API From 52681b2f25831bc0b328302c866c5752048d84eb Mon Sep 17 00:00:00 2001 From: Anna Tsolakou Date: Tue, 11 May 2021 10:57:59 +0200 Subject: [PATCH 3/3] branded fares upsell support --- README.rst | 3 +++ amadeus/shopping/_flight_offers.py | 2 ++ amadeus/shopping/flight_offers/__init__.py | 4 +++- amadeus/shopping/flight_offers/_upselling.py | 19 +++++++++++++++++++ docs/index.rst | 8 +++++++- specs/namespaces/namespaces_spec.py | 8 ++++++++ 6 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 amadeus/shopping/flight_offers/_upselling.py diff --git a/README.rst b/README.rst index d852940a..65476d8f 100644 --- a/README.rst +++ b/README.rst @@ -222,6 +222,9 @@ List of supported endpoints # 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/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/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 3c38c639..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 diff --git a/specs/namespaces/namespaces_spec.py b/specs/namespaces/namespaces_spec.py index 7f10b300..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) @@ -396,6 +397,13 @@ '/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(