Skip to content

Commit adb5773

Browse files
authored
Merge pull request #52 from amadeus4dev/support-flight-delay-prediction
Add support for Flight Delay Prediction
2 parents 56ad9a3 + 9049a2f commit adb5773

File tree

7 files changed

+71
-4
lines changed

7 files changed

+71
-4
lines changed

README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ List of supported endpoints
269269
# Trip Purpose Prediction
270270
amadeus.travel.predictions.trip_purpose.get(originLocationCode='ATH', destinationLocationCode='MAD', departureDate='2020-08-01', returnDate='2020-08-12', searchDate='2020-06-11')
271271
272+
# 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')
272274
273275
Development & Contributing
274276
--------------------------

amadeus/travel/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from ._analytics import Analytics
2-
from ._predictions import TripPurpose
2+
from ._predictions import TripPurpose, FlightDelay
33

4-
__all__ = ['Analytics', 'TripPurpose']
4+
__all__ = ['Analytics', 'TripPurpose', 'FlightDelay']

amadeus/travel/_predictions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from amadeus.client.decorator import Decorator
2-
from .predictions import TripPurpose
2+
from .predictions import TripPurpose, FlightDelay
33

44

55
class Predictions(Decorator, object):
66
def __init__(self, client):
77
Decorator.__init__(self, client)
88
self.trip_purpose = TripPurpose(client)
9+
self.flight_delay = FlightDelay(client)
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from ._trip_purpose import TripPurpose
2+
from ._flight_delay import FlightDelay
23

34

4-
__all__ = ['TripPurpose']
5+
__all__ = ['TripPurpose', 'FlightDelay']
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
from amadeus.client.decorator import Decorator
2+
3+
4+
class FlightDelay(Decorator, object):
5+
def get(self, **params):
6+
'''
7+
Forecast the chances for a flight to be delayed
8+
9+
.. code-block:: python
10+
11+
amadeus.travel.predictions.flight_delay.get(originLocationCode='BRU',
12+
destinationLocationCode='FRA',
13+
departureDate='2020-01-14',
14+
departureTime='11:05:00',
15+
arrivalDate='2020-01-14',
16+
arrivalTime='12:10:00',
17+
aircraftCode='32A',
18+
carrierCode='LH',
19+
flightNumber='1009',
20+
duration='PT1H05M')
21+
22+
:param originLocationCode: the City/Airport IATA code from which
23+
the flight will depart. ``"NYC"``, for example for New York
24+
25+
:param destinationLocationCode: the City/Airport IATA code to which
26+
the flight is going. ``"MAD"``, for example for Madrid
27+
28+
:param departureDate: the date on which the traveler departs
29+
from the origin, in `YYYY-MM-DD` format
30+
31+
:param departureTime: local time on which to fly out,
32+
in `HH:MM:SS` format
33+
34+
:param arrivalDate: the date on which the traveler arrives
35+
to the destination, in `YYYY-MM-DD` format
36+
37+
:param arrivalTime: local time on which the traveler arrives
38+
to the destination, in `HH:MM:SS` format
39+
40+
:param aircraftCode: IATA aircraft code
41+
42+
:param carrierCode: airline / carrier code
43+
44+
:param flightNumber: flight number as assigned by the carrier
45+
46+
:param duration: flight duration,
47+
in `PnYnMnDTnHnMnS` format e.g. PT2H10M
48+
49+
:rtype: amadeus.Response
50+
:raises amadeus.ResponseError: if the request could not be completed
51+
'''
52+
return self.client.get('/v1/travel/predictions/flight-delay', **params)

docs/index.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ Travel/Predictions
7474
.. autoclass:: amadeus.travel.predictions.TripPurpose
7575
:members: get
7676

77+
.. autoclass:: amadeus.travel.predictions.FlightDelay
78+
:members: get
79+
7780
ReferenceData/Locations
7881
=======================
7982

specs/namespaces/namespaces_spec.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
expect(client.travel.predictions).not_to(be_none)
3939
expect(client.travel.predictions.trip_purpose).not_to(be_none)
40+
expect(client.travel.predictions.flight_delay).not_to(be_none)
4041

4142
expect(client.shopping).not_to(be_none)
4243
expect(client.shopping.flight_dates).not_to(be_none)
@@ -74,6 +75,7 @@
7475
be_none)
7576

7677
expect(client.travel.predictions.trip_purpose.get).not_to(be_none)
78+
expect(client.travel.predictions.flight_delay.get).not_to(be_none)
7779

7880
expect(client.shopping.flight_dates.get).not_to(be_none)
7981
expect(client.shopping.flight_destinations.get).not_to(be_none)
@@ -171,6 +173,12 @@
171173
'/v1/travel/predictions/trip-purpose', a='b'
172174
))
173175

176+
with it('.travel.predictions.flight_delay.get'):
177+
self.client.travel.predictions.flight_delay.get(a='b')
178+
expect(self.client.get).to(have_been_called_with(
179+
'/v1/travel/predictions/flight-delay', a='b'
180+
))
181+
174182
with it('.shopping.flight_dates.get'):
175183
self.client.shopping.flight_dates.get(a='b')
176184
expect(self.client.get).to(have_been_called_with(

0 commit comments

Comments
 (0)