Skip to content

Commit 7e60cf5

Browse files
committed
add support for flight availability
1 parent 8db982f commit 7e60cf5

7 files changed

Lines changed: 52 additions & 1 deletion

File tree

README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ 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+
222225
# Flight Choice Prediction
223226
body = amadeus.shopping.flight_offers_search.get(
224227
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)
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)

docs/index.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ Shopping/Activities
8080
.. autoclass:: amadeus.shopping.Activity
8181
:members: get
8282

83+
Shopping/Availability
84+
===============
85+
86+
.. autoclass:: amadeus.shopping.availability.FlightAvailabilities
87+
:members: post
88+
8389
Travel/Analytics
8490
================
8591

specs/namespaces/namespaces_spec.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050

5151
expect(client.shopping.activities).not_to(be_none)
5252

53+
expect(client.shopping.availability).not_to(be_none)
54+
expect(client.shopping.availability.flight_availabilities).not_to(be_none)
55+
5356
expect(client.e_reputation.hotel_sentiments).not_to(be_none)
5457

5558
expect(client.airport).not_to(be_none)
@@ -386,6 +389,13 @@
386389
}}
387390
))
388391

392+
with it('.shopping.availability.flight_availabilities.post'):
393+
self.client.shopping.availability.flight_availabilities.post(
394+
{'foo': 'bar'})
395+
expect(self.client.post).to(have_been_called_with(
396+
'/v1/shopping/availability/flight-availabilities', {'foo': 'bar'}
397+
))
398+
389399
with it('.booking.flight_order().get'):
390400
self.client.booking.flight_order('123').get(a='b')
391401
expect(self.client.get).to(have_been_called_with(

0 commit comments

Comments
 (0)