Skip to content

Commit 8fac665

Browse files
authored
Merge pull request #115 from amadeus4dev/flight-availability-and-branded-fares
Add support for flight availability and Branded Fares
2 parents 8db982f + 52681b2 commit 8fac665

10 files changed

Lines changed: 94 additions & 3 deletions

File tree

README.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,12 @@ List of supported endpoints
219219
# Flight SeatMap Display POST
220220
amadeus.shopping.seatmaps.post(body)
221221
222+
# Flight Availabilities POST
223+
amadeus.shopping.availability.flight_availabilities.post(body)
224+
225+
# Branded Fares Upsell
226+
amadeus.shopping.flight_offers.upselling.post(body)
227+
222228
# Flight Choice Prediction
223229
body = amadeus.shopping.flight_offers_search.get(
224230
originLocationCode='MAD',

amadeus/namespaces/_shopping.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from amadeus.shopping._seatmaps import Seatmaps
1010
from amadeus.shopping._activities import Activities
1111
from amadeus.shopping._activity import Activity
12+
from amadeus.shopping._availability import Availability
1213

1314

1415
class Shopping(Decorator, object):
@@ -22,6 +23,7 @@ def __init__(self, client):
2223
self.flight_offers_search = FlightOffersSearch(client)
2324
self.seatmaps = Seatmaps(client)
2425
self.activities = Activities(client)
26+
self.availability = Availability(client)
2527

2628
def hotel_offer(self, offer_id):
2729
return HotelOffer(self.client, offer_id)
@@ -31,4 +33,4 @@ def activity(self, activity_id):
3133

3234

3335
__all__ = ['FlightDates', 'FlightDestinations', 'FlightOffers',
34-
'FlightOffersSearch']
36+
'FlightOffersSearch', 'Availability']

amadeus/shopping/_availability.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from amadeus.client.decorator import Decorator
2+
from .availability import FlightAvailabilities
3+
4+
5+
class Availability(Decorator, object):
6+
def __init__(self, client):
7+
Decorator.__init__(self, client)
8+
self.flight_availabilities = FlightAvailabilities(client)

amadeus/shopping/_flight_offers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
from amadeus.client.decorator import Decorator
22
from amadeus.shopping.flight_offers._prediction import FlightChoicePrediction
33
from amadeus.shopping.flight_offers._pricing import FlightOffersPrice
4+
from amadeus.shopping.flight_offers._upselling import Upselling
45

56

67
class FlightOffers(Decorator, object):
78
def __init__(self, client):
89
Decorator.__init__(self, client)
910
self.prediction = FlightChoicePrediction(client)
1011
self.pricing = FlightOffersPrice(client)
12+
self.upselling = Upselling(client)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from ._flight_availabilities import FlightAvailabilities
2+
3+
__all__ = ['FlightAvailabilities']
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 FlightAvailabilities(Decorator, object):
5+
def post(self, body):
6+
'''
7+
Get available seats in different fare classes
8+
9+
.. code-block:: python
10+
11+
amadeus.shopping.availability.flight_availabilities.post(body)
12+
13+
:param body: the parameters to send to the API
14+
15+
:rtype: amadeus.Response
16+
:raises amadeus.ResponseError: if the request could not be completed
17+
'''
18+
return self.client.post(
19+
'/v1/shopping/availability/flight-availabilities', body)
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from ._prediction import FlightChoicePrediction
22
from ._pricing import FlightOffersPrice
3+
from ._upselling import Upselling
34

4-
__all__ = ['FlightChoicePrediction', 'FlightOffersPrice']
5+
__all__ = ['FlightChoicePrediction', 'FlightOffersPrice',
6+
'Upselling']
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 Upselling(Decorator, object):
5+
def post(self, body):
6+
'''
7+
Get flight offers with branded fares
8+
9+
.. code-block:: python
10+
11+
amadeus.shopping.flight_offers.upselling.post(body)
12+
13+
:param body: the parameters to send to the API
14+
15+
:rtype: amadeus.Response
16+
:raises amadeus.ResponseError: if the request could not be completed
17+
'''
18+
return self.client.post(
19+
'/v1/shopping/flight-offers/upselling', body)

docs/index.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,13 @@ Shopping/Hotels
6565
Shopping/FlightOffers
6666
===============
6767

68-
.. autoclass:: amadeus.shopping.FlightOffersPrice
68+
.. autoclass:: amadeus.shopping.flight_offers.FlightChoicePrediction
69+
:members: post
70+
71+
.. autoclass:: amadeus.shopping.flight_offers.FlightChoicePrice
72+
:members: post
73+
74+
.. autoclass:: amadeus.shopping.flight_offers.Upselling
6975
:members: post
7076

7177
Shopping/Activities
@@ -80,6 +86,12 @@ Shopping/Activities
8086
.. autoclass:: amadeus.shopping.Activity
8187
:members: get
8288

89+
Shopping/Availability
90+
===============
91+
92+
.. autoclass:: amadeus.shopping.availability.FlightAvailabilities
93+
:members: post
94+
8395
Travel/Analytics
8496
================
8597

specs/namespaces/namespaces_spec.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
expect(client.shopping.flight_offers).not_to(be_none)
4242
expect(client.shopping.flight_offers_search).not_to(be_none)
4343
expect(client.shopping.flight_offers.pricing).not_to(be_none)
44+
expect(client.shopping.flight_offers.upselling).not_to(be_none)
4445

4546
expect(client.shopping.seatmaps).not_to(be_none)
4647

@@ -50,6 +51,9 @@
5051

5152
expect(client.shopping.activities).not_to(be_none)
5253

54+
expect(client.shopping.availability).not_to(be_none)
55+
expect(client.shopping.availability.flight_availabilities).not_to(be_none)
56+
5357
expect(client.e_reputation.hotel_sentiments).not_to(be_none)
5458

5559
expect(client.airport).not_to(be_none)
@@ -386,6 +390,20 @@
386390
}}
387391
))
388392

393+
with it('.shopping.availability.flight_availabilities.post'):
394+
self.client.shopping.availability.flight_availabilities.post(
395+
{'foo': 'bar'})
396+
expect(self.client.post).to(have_been_called_with(
397+
'/v1/shopping/availability/flight-availabilities', {'foo': 'bar'}
398+
))
399+
400+
with it('.shopping.flight_offers.upselling.post'):
401+
self.client.shopping.flight_offers.upselling.post(
402+
{'foo': 'bar'})
403+
expect(self.client.post).to(have_been_called_with(
404+
'/v1/shopping/flight-offers/upselling', {'foo': 'bar'}
405+
))
406+
389407
with it('.booking.flight_order().get'):
390408
self.client.booking.flight_order('123').get(a='b')
391409
expect(self.client.get).to(have_been_called_with(

0 commit comments

Comments
 (0)