Skip to content

Commit

Permalink
Merge pull request #115 from amadeus4dev/flight-availability-and-bran…
Browse files Browse the repository at this point in the history
…ded-fares

Add support for flight availability and Branded Fares
  • Loading branch information
tsolakoua authored May 11, 2021
2 parents 8db982f + 52681b2 commit 8fac665
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 3 deletions.
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 3 additions & 1 deletion amadeus/namespaces/_shopping.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)
Expand All @@ -31,4 +33,4 @@ def activity(self, activity_id):


__all__ = ['FlightDates', 'FlightDestinations', 'FlightOffers',
'FlightOffersSearch']
'FlightOffersSearch', 'Availability']
8 changes: 8 additions & 0 deletions amadeus/shopping/_availability.py
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 2 additions & 0 deletions amadeus/shopping/_flight_offers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
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):
def __init__(self, client):
Decorator.__init__(self, client)
self.prediction = FlightChoicePrediction(client)
self.pricing = FlightOffersPrice(client)
self.upselling = Upselling(client)
3 changes: 3 additions & 0 deletions amadeus/shopping/availability/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from ._flight_availabilities import FlightAvailabilities

__all__ = ['FlightAvailabilities']
19 changes: 19 additions & 0 deletions amadeus/shopping/availability/_flight_availabilities.py
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 3 additions & 1 deletion amadeus/shopping/flight_offers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from ._prediction import FlightChoicePrediction
from ._pricing import FlightOffersPrice
from ._upselling import Upselling

__all__ = ['FlightChoicePrediction', 'FlightOffersPrice']
__all__ = ['FlightChoicePrediction', 'FlightOffersPrice',
'Upselling']
19 changes: 19 additions & 0 deletions amadeus/shopping/flight_offers/_upselling.py
Original file line number Diff line number Diff line change
@@ -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)
14 changes: 13 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -80,6 +86,12 @@ Shopping/Activities
.. autoclass:: amadeus.shopping.Activity
:members: get

Shopping/Availability
===============

.. autoclass:: amadeus.shopping.availability.FlightAvailabilities
:members: post

Travel/Analytics
================

Expand Down
18 changes: 18 additions & 0 deletions specs/namespaces/namespaces_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 8fac665

Please sign in to comment.