Skip to content

Commit

Permalink
SDK - Trip Purpose Prediction (#43)
Browse files Browse the repository at this point in the history
Add support for Trip Purpose Prediction API
  • Loading branch information
Anna Tsolakou authored and anthonyroux committed Oct 2, 2019
1 parent 56c0e5c commit 7c00e22
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ List of supported endpoints
# What are the popular places in Barcelona? (based on a square)
amadeus.reference_data.locations.points_of_interest.by_square.get(north=41.397158, west=2.160873, south=41.394582, east=2.177181)
# Trip Purpose Prediction
amadeus.travel.predictions.trip_purpose.get(originLocationCode='ATH', destinationLocationCode='MAD', departureDate='2020-08-01', returnDate='2020-08-12', searchDate='2020-06-11')
Development & Contributing
--------------------------
Expand Down
2 changes: 2 additions & 0 deletions amadeus/namespaces/_travel.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from amadeus.client.decorator import Decorator
from amadeus.travel._analytics import Analytics
from amadeus.travel._predictions import Predictions


class Travel(Decorator, object):
def __init__(self, client):
Decorator.__init__(self, client)
self.analytics = Analytics(client)
self.predictions = Predictions(client)
4 changes: 2 additions & 2 deletions amadeus/travel/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._analytics import Analytics
from ._predictions import TripPurpose


__all__ = ['Analytics']
__all__ = ['Analytics', 'TripPurpose']
8 changes: 8 additions & 0 deletions amadeus/travel/_predictions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from amadeus.client.decorator import Decorator
from .predictions import TripPurpose


class Predictions(Decorator, object):
def __init__(self, client):
Decorator.__init__(self, client)
self.trip_purpose = TripPurpose(client)
4 changes: 4 additions & 0 deletions amadeus/travel/predictions/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from ._trip_purpose import TripPurpose


__all__ = ['TripPurpose']
37 changes: 37 additions & 0 deletions amadeus/travel/predictions/_trip_purpose.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from amadeus.client.decorator import Decorator


class TripPurpose(Decorator, object):
def get(self, **params):
'''
Predicts traveler purpose, Business or Leisure,
with the probability in the context of search & shopping
.. code-block:: python
amadeus.travel.predictions.trip_purpose.get(
originLocationCode='NYC',
destinationLocationCode='MAD',
departureDate='2020-08-01',
returnDate='2020-08-12',
searchDate='2020-06-11')
:param originLocationCode: the City/Airport IATA code from which
the flight will depart. ``"NYC"``, for example for New York
:param destinationLocationCode: the City/Airport IATA code to which
the flight is going. ``"MAD"``, for example for Madrid
:param departureDate: the date on which to fly out, in `YYYY-MM-DD` format
:param returnDate: the date on which the flight returns to the origin,
in `YYYY-MM-DD` format
:param searchDate: the date on which the traveler performs the search,
in `YYYY-MM-DD` format.
If it is not specified the current date will be used
:rtype: amadeus.Response
:raises amadeus.ResponseError: if the request could not be completed
'''
return self.client.get('/v1/travel/predictions/trip-purpose', **params)
6 changes: 6 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ Travel/Analytics
.. autoclass:: amadeus.travel.analytics.FareSearches
:members: get

Travel/Predictions
================

.. autoclass:: amadeus.travel.predictions.TripPurpose
:members: get

ReferenceData/Locations
=======================

Expand Down
11 changes: 11 additions & 0 deletions specs/namespaces/namespaces_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
be_none)
expect(client.travel.analytics.air_traffic.busiest_period).not_to(be_none)

expect(client.travel.predictions).not_to(be_none)
expect(client.travel.predictions.trip_purpose).not_to(be_none)

expect(client.shopping).not_to(be_none)
expect(client.shopping.flight_dates).not_to(be_none)
expect(client.shopping.flight_destinations).not_to(be_none)
Expand Down Expand Up @@ -68,6 +71,8 @@
client.travel.analytics.air_traffic.busiest_period.get).not_to(
be_none)

expect(client.travel.predictions.trip_purpose.get).not_to(be_none)

expect(client.shopping.flight_dates.get).not_to(be_none)
expect(client.shopping.flight_destinations.get).not_to(be_none)
expect(client.shopping.flight_offers.get).not_to(be_none)
Expand Down Expand Up @@ -156,6 +161,12 @@
'/v1/travel/analytics/air-traffic/searched/by-destination',
a='b'))

with it('.travel.predictions.trip_purpose.get'):
self.client.travel.predictions.trip_purpose.get(a='b')
expect(self.client.get).to(have_been_called_with(
'/v1/travel/predictions/trip-purpose', a='b'
))

with it('.shopping.flight_dates.get'):
self.client.shopping.flight_dates.get(a='b')
expect(self.client.get).to(have_been_called_with(
Expand Down

0 comments on commit 7c00e22

Please sign in to comment.