Skip to content

Commit 7c00e22

Browse files
Anna Tsolakouanthonyroux
authored andcommitted
SDK - Trip Purpose Prediction (#43)
Add support for Trip Purpose Prediction API
1 parent 56c0e5c commit 7c00e22

File tree

8 files changed

+73
-2
lines changed

8 files changed

+73
-2
lines changed

README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ List of supported endpoints
256256
# What are the popular places in Barcelona? (based on a square)
257257
amadeus.reference_data.locations.points_of_interest.by_square.get(north=41.397158, west=2.160873, south=41.394582, east=2.177181)
258258
259+
# Trip Purpose Prediction
260+
amadeus.travel.predictions.trip_purpose.get(originLocationCode='ATH', destinationLocationCode='MAD', departureDate='2020-08-01', returnDate='2020-08-12', searchDate='2020-06-11')
261+
259262
260263
Development & Contributing
261264
--------------------------

amadeus/namespaces/_travel.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from amadeus.client.decorator import Decorator
22
from amadeus.travel._analytics import Analytics
3+
from amadeus.travel._predictions import Predictions
34

45

56
class Travel(Decorator, object):
67
def __init__(self, client):
78
Decorator.__init__(self, client)
89
self.analytics = Analytics(client)
10+
self.predictions = Predictions(client)

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
23

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

amadeus/travel/_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 TripPurpose
3+
4+
5+
class Predictions(Decorator, object):
6+
def __init__(self, client):
7+
Decorator.__init__(self, client)
8+
self.trip_purpose = TripPurpose(client)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from ._trip_purpose import TripPurpose
2+
3+
4+
__all__ = ['TripPurpose']
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from amadeus.client.decorator import Decorator
2+
3+
4+
class TripPurpose(Decorator, object):
5+
def get(self, **params):
6+
'''
7+
Predicts traveler purpose, Business or Leisure,
8+
with the probability in the context of search & shopping
9+
10+
.. code-block:: python
11+
12+
amadeus.travel.predictions.trip_purpose.get(
13+
originLocationCode='NYC',
14+
destinationLocationCode='MAD',
15+
departureDate='2020-08-01',
16+
returnDate='2020-08-12',
17+
searchDate='2020-06-11')
18+
19+
:param originLocationCode: the City/Airport IATA code from which
20+
the flight will depart. ``"NYC"``, for example for New York
21+
22+
:param destinationLocationCode: the City/Airport IATA code to which
23+
the flight is going. ``"MAD"``, for example for Madrid
24+
25+
:param departureDate: the date on which to fly out, in `YYYY-MM-DD` format
26+
27+
:param returnDate: the date on which the flight returns to the origin,
28+
in `YYYY-MM-DD` format
29+
30+
:param searchDate: the date on which the traveler performs the search,
31+
in `YYYY-MM-DD` format.
32+
If it is not specified the current date will be used
33+
34+
:rtype: amadeus.Response
35+
:raises amadeus.ResponseError: if the request could not be completed
36+
'''
37+
return self.client.get('/v1/travel/predictions/trip-purpose', **params)

docs/index.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ Travel/Analytics
6868
.. autoclass:: amadeus.travel.analytics.FareSearches
6969
:members: get
7070

71+
Travel/Predictions
72+
================
73+
74+
.. autoclass:: amadeus.travel.predictions.TripPurpose
75+
:members: get
76+
7177
ReferenceData/Locations
7278
=======================
7379

specs/namespaces/namespaces_spec.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
be_none)
3636
expect(client.travel.analytics.air_traffic.busiest_period).not_to(be_none)
3737

38+
expect(client.travel.predictions).not_to(be_none)
39+
expect(client.travel.predictions.trip_purpose).not_to(be_none)
40+
3841
expect(client.shopping).not_to(be_none)
3942
expect(client.shopping.flight_dates).not_to(be_none)
4043
expect(client.shopping.flight_destinations).not_to(be_none)
@@ -68,6 +71,8 @@
6871
client.travel.analytics.air_traffic.busiest_period.get).not_to(
6972
be_none)
7073

74+
expect(client.travel.predictions.trip_purpose.get).not_to(be_none)
75+
7176
expect(client.shopping.flight_dates.get).not_to(be_none)
7277
expect(client.shopping.flight_destinations.get).not_to(be_none)
7378
expect(client.shopping.flight_offers.get).not_to(be_none)
@@ -156,6 +161,12 @@
156161
'/v1/travel/analytics/air-traffic/searched/by-destination',
157162
a='b'))
158163

164+
with it('.travel.predictions.trip_purpose.get'):
165+
self.client.travel.predictions.trip_purpose.get(a='b')
166+
expect(self.client.get).to(have_been_called_with(
167+
'/v1/travel/predictions/trip-purpose', a='b'
168+
))
169+
159170
with it('.shopping.flight_dates.get'):
160171
self.client.shopping.flight_dates.get(a='b')
161172
expect(self.client.get).to(have_been_called_with(

0 commit comments

Comments
 (0)