Skip to content

Commit 8cdf6e8

Browse files
authored
Support for Airport on Time (#53)
* add support and update test-docs * fix docs * change line * update test
1 parent adb5773 commit 8cdf6e8

File tree

9 files changed

+70
-1
lines changed

9 files changed

+70
-1
lines changed

README.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,11 @@ List of supported endpoints
270270
amadeus.travel.predictions.trip_purpose.get(originLocationCode='ATH', destinationLocationCode='MAD', departureDate='2020-08-01', returnDate='2020-08-12', searchDate='2020-06-11')
271271
272272
# Flight Delay Prediction
273-
amadeus.travel.predictions.flight_delay.get(originLocationCode='BRU', destinationLocationCode='FRA', departureDate='2020-01-14', departureTime='11:05:00', arrivalDate='2020-01-14', arrivalTime='12:10:00', aircraftCode='32A', carrierCode='LH', flightNumber='1009', duration='PT1H05M')
273+
amadeus.travel.predictions.flight_delay.get(originLocationCode='BRU', destinationLocationCode='FRA', departureDate='2020-01-14', \
274+
departureTime='11:05:00', arrivalDate='2020-01-14', arrivalTime='12:10:00', aircraftCode='32A', carrierCode='LH', flightNumber='1009', duration='PT1H05M')
275+
276+
# Airport On-Time Performance
277+
amadeus.airport.predictions.on_time.get(airportCode='JFK', date='2020-03-01')
274278
275279
Development & Contributing
276280
--------------------------

amadeus/airport/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from ._predictions import AirportOnTime
2+
3+
__all__ = ['AirportOnTime']

amadeus/airport/_predictions.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 .predictions import AirportOnTime
3+
4+
5+
class Predictions(Decorator, object):
6+
def __init__(self, client):
7+
Decorator.__init__(self, client)
8+
self.on_time = AirportOnTime(client)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from ._on_time import AirportOnTime
2+
3+
__all__ = ['AirportOnTime']
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from amadeus.client.decorator import Decorator
2+
3+
4+
class AirportOnTime(Decorator, object):
5+
def get(self, **params):
6+
'''
7+
Returns a percentage of on-time flight departures
8+
9+
.. code-block:: python
10+
11+
amadeus.airport.predictions.on_time.get(
12+
airportCode='JFK',
13+
date='2020-03-01')
14+
15+
:param airportCode: the City/Airport IATA code from which
16+
the flight will depart. ``"NYC"``, for example for New York
17+
18+
:param date: the date on which to fly out, in `YYYY-MM-DD` format
19+
20+
:rtype: amadeus.Response
21+
:raises amadeus.ResponseError: if the request could not be completed
22+
'''
23+
return self.client.get('/v1/airport/predictions/on-time', **params)

amadeus/namespaces/_airport.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 amadeus.airport._predictions import Predictions
3+
4+
5+
class Airport(Decorator, object):
6+
def __init__(self, client):
7+
Decorator.__init__(self, client)
8+
self.predictions = Predictions(client)

amadeus/namespaces/core.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from amadeus.namespaces._travel import Travel
33
from amadeus.namespaces._shopping import Shopping
44
from amadeus.namespaces._e_reputation import EReputation
5+
from amadeus.namespaces._airport import Airport
56

67

78
class Core(object):
@@ -10,3 +11,4 @@ def __init__(self):
1011
self.travel = Travel(self)
1112
self.shopping = Shopping(self)
1213
self.e_reputation = EReputation(self)
14+
self.airport = Airport(self)

docs/index.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,9 @@ Helper/Location
102102
==================
103103

104104
.. autoclass:: amadeus.Location
105+
106+
Airport/Predictions
107+
================
108+
109+
.. autoclass:: amadeus.airport.predictions.AirportOnTime
110+
:members: get

specs/namespaces/namespaces_spec.py

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

5151
expect(client.e_reputation.hotel_sentiments).not_to(be_none)
5252

53+
expect(client.airport).not_to(be_none)
54+
expect(client.airport.predictions).not_to(be_none)
55+
expect(client.airport.predictions.on_time).not_to(be_none)
56+
5357
with it('should define all expected .get methods'):
5458
client = self.client
5559
expect(client.reference_data.urls.checkin_links.get).not_to(be_none)
@@ -87,6 +91,8 @@
8791

8892
expect(client.e_reputation.hotel_sentiments.get).not_to(be_none)
8993

94+
expect(client.airport.predictions.on_time.get).not_to(be_none)
95+
9096
with context('testing all calls to the client'):
9197
with before.each:
9298
self.client.get = method_returning(None)
@@ -220,3 +226,9 @@
220226
expect(self.client.get).to(have_been_called_with(
221227
'/v2/e-reputation/hotel-sentiments', hotelIds='XKPARC12'
222228
))
229+
230+
with it('.airport.predictions.on_time.get'):
231+
self.client.airport.predictions.on_time.get(a='b')
232+
expect(self.client.get).to(have_been_called_with(
233+
'/v1/airport/predictions/on-time', a='b'
234+
))

0 commit comments

Comments
 (0)