diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 53cf31b3..b8a6f1fa 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -3,7 +3,7 @@ To run the project locally, clone the repository, and then create a virtual environment and install the dependencies. ```sh git clone https://github.com/amadeus4dev/amadeus-python.git -cd amadeus-ruby +cd amadeus-python ``` First, ensure you have a version of every Python we support installed. Your versions may differ. diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 8efb1152..7212b0b6 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,38 @@ Changelog ========= +2.0.0 - 2018-10-14 +-------------------- + +`Flight Most Searched Destinations `_: Redesign of the API - Split the previous endpoint in 2 endpoints: + +- 1st endpoint to find the most searched destinations +- 2nd endpoint to have more data about a dedicated origin & destination + +`Flight Most Booked Destinations `_: + +- Rename origin to originCityCode + +`Flight Most Traveled Destinations `_: + +- Rename origin in originCityCode + +`Flight Check-in Links `_: + +- Rename airline to airlineCode + +`Airport & City Search `_: + +- Remove parameter onlyMajor + +`Airport Nearest Relevant `_: + +- Add radius as parameter + +`Airline Code Lookup `_: + +- Regroup parameters *IATACode* and *ICAOCode* under the same name *airlineCodes* + 1.1.0 - 2018-08-01 -------------------- diff --git a/README.rst b/README.rst index f984feba..7ecd41a6 100644 --- a/README.rst +++ b/README.rst @@ -209,10 +209,10 @@ List of supported endpoints amadeus.shopping.flight_offers.get(origin='MAD', destination='NYC', departureDate='2019-08-01') # Flight Checkin Links - amadeus.reference_data.urls.checkin_links.get(airline='BA') + amadeus.reference_data.urls.checkin_links.get(airlineCode='BA') # Airline Code Lookup - amadeus.reference_data.airlines.get(IATACode='U2') + amadeus.reference_data.airlines.get(airlineCodes='U2') # Airport and City Search (autocomplete) # Find all the cities and airports starting by 'LON' @@ -224,16 +224,16 @@ List of supported endpoints amadeus.reference_data.locations.airports.get(longitude=49.000, latitude=2.55) # Flight Most Searched Destinations - amadeus.travel.analytics.fare_searches.get(origin='MAD', sourceCountry='SP', period='2017-08') + amadeus.travel.analytics.fare_searches.get(originCityCode='MAD', sourceCountry='SP', period='2017-08') # Flight Most Booked Destinations - amadeus.travel.analytics.air_traffic.booked.get(origin='MAD', period='2017-08') + amadeus.travel.analytics.air_traffic.booked.get(originCityCode='MAD', period='2017-08') # Flight Most Traveled Destinations - amadeus.travel.analytics.air_traffic.traveled.get(origin='MAD', period='2017-01') + amadeus.travel.analytics.air_traffic.traveled.get(originCityCode='MAD', period='2017-01') # Flight Busiest Travel Period - amadeus.travel.analytics.air_traffic.busiest_period.get(origin='MAD', period='2017', direction='ARRIVING') + amadeus.travel.analytics.air_traffic.busiest_period.get(cityCode='MAD', period='2017', direction='ARRIVING') # Hotel Search API # Get list of Hotels by city code diff --git a/amadeus/reference_data/_airlines.py b/amadeus/reference_data/_airlines.py index b419acc2..3c7e4ccf 100644 --- a/amadeus/reference_data/_airlines.py +++ b/amadeus/reference_data/_airlines.py @@ -8,9 +8,11 @@ def get(self, **params): .. code-block:: python - amadeus.reference_data.airlines.get(IATACode='U2') + amadeus.reference_data.airlines.get(airlineCodes='U2') - :param IATACode: the IATA code for the airline, e.g. ``"1X"`` + :param airlineCodes: the IATA or ICAO code for the airline, e.g. + :``"AF"`` (Air France IATA code) + :or ``"AFR"`` (Air France ICAO code) :rtype: amadeus.Response :raises amadeus.ResponseError: if the request could not be completed diff --git a/amadeus/reference_data/urls/_checkin_links.py b/amadeus/reference_data/urls/_checkin_links.py index be31e150..d15af059 100644 --- a/amadeus/reference_data/urls/_checkin_links.py +++ b/amadeus/reference_data/urls/_checkin_links.py @@ -9,9 +9,9 @@ def get(self, **params): .. code-block:: python - amadeus.reference_data.urls.checkin_links.get(airline='1X') + amadeus.reference_data.urls.checkin_links.get(airlineCode='BA') - :param airline: the IATA code for the airline, e.g. ``"1X"`` + :param airlineCode: the IATA code for the airline, e.g. ``"BA"`` :param language: the locale for the links, for example ``"en-GB"`` :rtype: amadeus.Response diff --git a/amadeus/travel/_analytics.py b/amadeus/travel/_analytics.py index faa17a9c..05b85a36 100644 --- a/amadeus/travel/_analytics.py +++ b/amadeus/travel/_analytics.py @@ -1,10 +1,8 @@ from amadeus.client.decorator import Decorator from .analytics._air_traffic import AirTraffic -from .analytics._fare_searches import FareSearches class Analytics(Decorator, object): def __init__(self, client): Decorator.__init__(self, client) - self.fare_searches = FareSearches(client) self.air_traffic = AirTraffic(client) diff --git a/amadeus/travel/analytics/__init__.py b/amadeus/travel/analytics/__init__.py index 74ee1940..3f5cf2d2 100644 --- a/amadeus/travel/analytics/__init__.py +++ b/amadeus/travel/analytics/__init__.py @@ -1,5 +1,4 @@ -from ._fare_searches import FareSearches from ._air_traffic import AirTraffic -__all__ = ['FareSearches', 'AirTraffic'] +__all__ = ['AirTraffic'] diff --git a/amadeus/travel/analytics/_air_traffic.py b/amadeus/travel/analytics/_air_traffic.py index 99ed7f6c..074fa979 100644 --- a/amadeus/travel/analytics/_air_traffic.py +++ b/amadeus/travel/analytics/_air_traffic.py @@ -1,6 +1,8 @@ from amadeus.client.decorator import Decorator from .air_traffic._traveled import Traveled from .air_traffic._booked import Booked +from .air_traffic._searched import Searched +from .air_traffic._searched_by_destination import SearchedByDestination from .air_traffic._busiest_period import BusiestPeriod @@ -9,4 +11,6 @@ def __init__(self, client): Decorator.__init__(self, client) self.booked = Booked(client) self.traveled = Traveled(client) + self.searched = Searched(client) + self.searched_by_destination = SearchedByDestination(client) self.busiest_period = BusiestPeriod(client) diff --git a/amadeus/travel/analytics/_fare_searches.py b/amadeus/travel/analytics/_fare_searches.py deleted file mode 100644 index 107e93a7..00000000 --- a/amadeus/travel/analytics/_fare_searches.py +++ /dev/null @@ -1,33 +0,0 @@ -from amadeus.client.decorator import Decorator - - -class FareSearches(Decorator, object): - def get(self, **params): - ''' - The Fare Search History API allows to find the number of - estimated searches from an origin, optionally a destination, - within a time period when travelers are performing the searches. - - .. code-block:: python - - amadeus.travel.analytics.fare_searches.get( - origin='LHR', - sourceCountry='FR' - period='2011' - ) - - :param cityCode: IATA code of the origin city, for - example ``"BOS"`` for Boston. - :param sourceCountry: IATA code of the country from which fare - searches were made - e.g. ``"US"`` for United States - :param period: period of search; can be a year - or a month or a week. ISO format must be used - e.g. ``"2015"`` - for year; ``"2015-05"`` for month and ``"2015-W04"`` for week. - Period ranges are not supported. Only periods from year - ``"2011-01"`` up to current year and previous month or week - are valid. Future dates are not supported. - - :rtype: amadeus.Response - :raises amadeus.ResponseError: if the request could not be completed - ''' - return self.client.get('/v1/travel/analytics/fare-searches', **params) diff --git a/amadeus/travel/analytics/air_traffic/__init__.py b/amadeus/travel/analytics/air_traffic/__init__.py index dc81499c..27c6c959 100644 --- a/amadeus/travel/analytics/air_traffic/__init__.py +++ b/amadeus/travel/analytics/air_traffic/__init__.py @@ -1,6 +1,9 @@ from ._traveled import Traveled +from ._searched import Searched +from ._searched_by_destination import SearchedByDestination from ._booked import Booked from ._busiest_period import BusiestPeriod -__all__ = ['Traveled', 'Booked', 'BusiestPeriod'] +__all__ = ['Searched', 'SearchedByDestination', + 'Traveled', 'Booked', 'BusiestPeriod'] diff --git a/amadeus/travel/analytics/air_traffic/_booked.py b/amadeus/travel/analytics/air_traffic/_booked.py index a0770275..49df031e 100644 --- a/amadeus/travel/analytics/air_traffic/_booked.py +++ b/amadeus/travel/analytics/air_traffic/_booked.py @@ -9,11 +9,11 @@ def get(self, **params): .. code-block:: python amadeus.travel.analytics.air_traffic.booked.get( - origin='LHR', + originCityCode='LHR', period='2017-01' ) - :param cityCode: IATA code of the origin city, for + :param originCityCode: IATA code of the origin city, for example ``"BOS"`` for Boston. :param query: period when consumers are traveling in ``YYYY-MM`` format diff --git a/amadeus/travel/analytics/air_traffic/_busiest_period.py b/amadeus/travel/analytics/air_traffic/_busiest_period.py index fcec7cd7..43939edf 100644 --- a/amadeus/travel/analytics/air_traffic/_busiest_period.py +++ b/amadeus/travel/analytics/air_traffic/_busiest_period.py @@ -9,15 +9,17 @@ def get(self, **params): .. code-block:: python amadeus.travel.analytics.air_traffic.busiest_period.get( - origin='MAD', + cityCode='MAD', period='2017', direction=Direction.ARRIVING ) :param cityCode: IATA code of the origin city, for example ``"BOS"`` for Boston. - :param query: period when consumers are traveling + :param period: period when consumers are traveling in ``YYYY`` format + :param direction: to select between + arrivals and departures (default: arrivals) :rtype: amadeus.Response :raises amadeus.ResponseError: if the request could not be completed diff --git a/amadeus/travel/analytics/air_traffic/_searched.py b/amadeus/travel/analytics/air_traffic/_searched.py new file mode 100644 index 00000000..ec21cf38 --- /dev/null +++ b/amadeus/travel/analytics/air_traffic/_searched.py @@ -0,0 +1,29 @@ +from amadeus.client.decorator import Decorator + + +class Searched(Decorator, object): + def get(self, **params): + ''' + Returns a list of air traffic reports, based on number of searches. + + .. code-block:: python + + amadeus.travel.analytics.air_traffic.searched.get( + originCityCode='MAD', + searchPeriod='2017-08', + marketCountryCode='ES' + ) + + :param originCityCode: IATA code of the origin city, for + example ``"MAD"`` for Madrid. + :param searchPeriod: period when consumers are traveling + in ``YYYY-MM`` format + :param marketCountryCode: IATA code of the country from which + searches were made - e.g. ``"ES"`` for Spain + + + :rtype: amadeus.Response + :raises amadeus.ResponseError: if the request could not be completed + ''' + return self.client.get('/v1/travel/analytics/air-traffic/searched', + **params) diff --git a/amadeus/travel/analytics/air_traffic/_searched_by_destination.py b/amadeus/travel/analytics/air_traffic/_searched_by_destination.py new file mode 100644 index 00000000..0d959312 --- /dev/null +++ b/amadeus/travel/analytics/air_traffic/_searched_by_destination.py @@ -0,0 +1,33 @@ +from amadeus.client.decorator import Decorator + + +class SearchedByDestination(Decorator, object): + def get(self, **params): + ''' + The Flight Most Searched Destinations API allows to find the number of + estimated searches from an origin and a destination, + within a time period when travelers are performing the searches. + + .. code-block:: python + + amadeus.travel.analytics.air_traffic.searched_by_destination.get( + originCityCode='MAD', + destinationCityCode='NYC', + marketCountryCode='ES' + searchPeriod='2017-08' + ) + + :param originCityCode: IATA code of the origin city, for + example ``"MAD"`` for Madrid. + :param destinationCityCode: IATA code of the destination city, for + example ``"NYC"`` for New-York. + :param marketCountryCode: IATA code of the country from which + searches were made - e.g. ``"ES"`` for Spain + :param searchPeriod: period when consumers are traveling + in ``YYYY-MM`` format + + :rtype: amadeus.Response + :raises amadeus.ResponseError: if the request could not be completed + ''' + return self.client.get( + '/v1/travel/analytics/air-traffic/searched/by-destination', **params) diff --git a/amadeus/travel/analytics/air_traffic/_traveled.py b/amadeus/travel/analytics/air_traffic/_traveled.py index 93baa344..e40c945b 100644 --- a/amadeus/travel/analytics/air_traffic/_traveled.py +++ b/amadeus/travel/analytics/air_traffic/_traveled.py @@ -9,13 +9,13 @@ def get(self, **params): .. code-block:: python amadeus.travel.analytics.air_traffic.traveled.get( - origin='LHR', + originCityCode='LHR', period='2017-01' ) - :param cityCode: IATA code of the origin city, for + :param originCityCode: IATA code of the origin city, for example ``"BOS"`` for Boston. - :param query: period when consumers are traveling + :param period: period when consumers are traveling in ``YYYY-MM`` format :rtype: amadeus.Response diff --git a/amadeus/version.py b/amadeus/version.py index 8ba6d65d..0ca6c8fa 100644 --- a/amadeus/version.py +++ b/amadeus/version.py @@ -1,2 +1,2 @@ -version_info = (1, 1, 0) +version_info = (2, 0, 0) version = '.'.join(str(v) for v in version_info) diff --git a/specs/namespaces/namespaces_spec.py b/specs/namespaces/namespaces_spec.py index 2b979ffc..feed9613 100644 --- a/specs/namespaces/namespaces_spec.py +++ b/specs/namespaces/namespaces_spec.py @@ -24,7 +24,12 @@ expect(client.travel).not_to(be_none) expect(client.travel.analytics).not_to(be_none) expect(client.travel.analytics.air_traffic.traveled).not_to(be_none) - expect(client.travel.analytics.fare_searches).not_to(be_none) + expect(client.travel.analytics.air_traffic.searched).not_to(be_none) + expect(client.travel.analytics.air_traffic.booked).not_to(be_none) + expect( + client.travel.analytics.air_traffic.searched_by_destination).not_to( + be_none) + expect(client.travel.analytics.air_traffic.busiest_period).not_to(be_none) expect(client.shopping).not_to(be_none) expect(client.shopping.flight_dates).not_to(be_none) @@ -44,7 +49,15 @@ expect(client.reference_data.locations.airports.get).not_to(be_none) expect(client.travel.analytics.air_traffic.traveled.get).not_to(be_none) - expect(client.travel.analytics.fare_searches.get).not_to(be_none) + expect(client.travel.analytics.air_traffic.booked.get).not_to(be_none) + expect(client.travel.analytics.air_traffic.searched.get).not_to(be_none) + expect( + client.travel.analytics.air_traffic. + searched_by_destination.get).not_to( + be_none) + expect( + client.travel.analytics.air_traffic.busiest_period.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) @@ -106,12 +119,21 @@ '/v1/travel/analytics/air-traffic/busiest-period', a='b' )) - with it('.travel.analytics.fare_searches.get'): - self.client.travel.analytics.fare_searches.get(a='b') + with it('.travel.analytics.air_traffic.searched.get'): + self.client.travel.analytics.air_traffic.searched.get(a='b') expect(self.client.get).to(have_been_called_with( - '/v1/travel/analytics/fare-searches', a='b' + '/v1/travel/analytics/air-traffic/searched', a='b' )) + with it('.travel.analytics.air_traffic.searched_by_destination.get'): + self.client.travel.analytics.air_traffic.searched_by_destination.get( + a='b') + expect( + self.client.get).to( + have_been_called_with( + '/v1/travel/analytics/air-traffic/searched/by-destination', + 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(