From 75457e90381b6ff38becfed0befe214c9d6c0fc1 Mon Sep 17 00:00:00 2001 From: ardydedase Date: Mon, 12 Sep 2016 17:01:46 +0800 Subject: [PATCH 01/13] Include skyscanner version to be used by doc. --- skyscanner/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skyscanner/__init__.py b/skyscanner/__init__.py index b60224f..941009c 100755 --- a/skyscanner/__init__.py +++ b/skyscanner/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- __author__ = 'Ardy Dedase' __email__ = 'ardy.dedase@skyscanner.net' -__version__ = '1.1.3' +__version__ = '1.1.4' __copyright__ = "Copyright (C) 2016 Skyscanner Ltd" __license__ = """ Licensed under the Apache License, Version 2.0 (the "License"); From 62a4034d871e4445a6e90bade3d5c0264543a296 Mon Sep 17 00:00:00 2001 From: Sam Heyman Date: Mon, 12 Sep 2016 12:57:36 +0100 Subject: [PATCH 02/13] updating the README file with API key instructions, documentation links and moved dates to 2017 --- README.rst | 20 ++++++++++++-------- docs/usage.rst | 28 ++++++++++++++-------------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/README.rst b/README.rst index 292be86..1439484 100644 --- a/README.rst +++ b/README.rst @@ -46,13 +46,14 @@ Or, if you have virtualenvwrapper installed:: Quick start ----------- -1. Request for an API Key from `Skyscanner for Business Contact Page`_. -2. Set your API Key:: +1. If you don't already have one, create a `Skyscanner account`_. +2. Sign into your account and under Add Apps click Travel APIs to create your Travel API key +3. Set your API Key in your code:: from skyscanner.skyscanner import Flights flights_service = Flights('') -3. Get the flights live pricing result by writing a few lines of code:: +4. Get the flights live pricing result by writing a few lines of code:: from skyscanner.skyscanner import Flights @@ -63,23 +64,24 @@ Quick start locale='en-GB', originplace='SIN-sky', destinationplace='KUL-sky', - outbounddate='2016-07-28', - inbounddate='2016-07-31', + outbounddate='2017-05-28', + inbounddate='2017-05-31', adults=1).parsed print(result) Note that both the ``inbounddate`` and ``outbounddate`` might need to be updated. -.. _Skyscanner for Business Contact Page: http://en.business.skyscanner.net/en-gb/contact/ +.. _Skyscanner account: http://portal.business.skyscanner.net/en-gb/accounts/login/ More examples ------------- -For more example usage, `refer to our documentation`_. +For more example usage, refer to the `SDK documentation`_ or the `API documentation`_. -.. _refer to our documentation: https://skyscanner.readthedocs.org/en/latest/usage.html +.. _SDK documentation: https://skyscanner.readthedocs.org/en/latest/usage.html +.. _API documentation: http://business.skyscanner.net/portal/en-GB/Documentation/ApiOverview Known Issues @@ -88,4 +90,6 @@ Known Issues * Tests might appear to be broken sometimes, this is due to the throttling in the API. In such cases, you will see the following error in the build log:: requests.exceptions.HTTPError: 429 Client Error: Too many requests in the last minute. + +** Please allow up to 15 minutes for your API key to be activated. Until it is activated you will get a 403 exception. diff --git a/docs/usage.rst b/docs/usage.rst index 8cb9ffe..2e861f0 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -25,8 +25,8 @@ Get live prices:: locale='en-GB', originplace='SIN-sky', destinationplace='KUL-sky', - outbounddate='2015-05-28', - inbounddate='2015-05-31', + outbounddate='2017-05-28', + inbounddate='2017-05-31', adults=1).parsed Flights: Browse Cache @@ -45,8 +45,8 @@ Cheapest quotes:: locale='en-GB', originplace='SIN-sky', destinationplace='KUL-sky', - outbounddate='2015-05', - inbounddate='2015-06').parsed + outbounddate='2017-05', + inbounddate='2017-06').parsed Cheapest price by route:: @@ -59,8 +59,8 @@ Cheapest price by route:: locale='en-GB', originplace='SIN-sky', destinationplace='KUL-sky', - outbounddate='2015-05', - inbounddate='2015-06').parsed + outbounddate='2017-05', + inbounddate='2017-06').parsed Cheapest price by date:: @@ -73,8 +73,8 @@ Cheapest price by date:: locale='en-GB', originplace='SIN-sky', destinationplace='KUL-sky', - outbounddate='2015-05', - inbounddate='2015-06').parsed + outbounddate='2017-05', + inbounddate='2017-06').parsed Grid of prices by date:: @@ -87,8 +87,8 @@ Grid of prices by date:: locale='en-GB', originplace='SIN-sky', destinationplace='KUL-sky', - outbounddate='2015-05', - inbounddate='2015-06').parsed + outbounddate='2017-05', + inbounddate='2017-06').parsed Car Hire ~~~~~~~~ @@ -106,8 +106,8 @@ Get live prices:: locale='en-GB', pickupplace='LHR-sky', dropoffplace='LHR-sky', - pickupdatetime='2015-05-29T12:00', - dropoffdatetime='2015-05-29T18:00', + pickupdatetime='2017-05-29T12:00', + dropoffdatetime='2017-05-29T18:00', driverage='30', userip='175.156.244.174').parsed @@ -148,7 +148,7 @@ Hotels prices and details:: currency='GBP', locale='en-GB', entityid=27543923, - checkindate='2015-05-26', - checkoutdate='2015-05-30', + checkindate='2017-05-26', + checkoutdate='2017-05-30', guests=1, rooms=1).parsed \ No newline at end of file From dba5ef6dde5f09d8cc9784e0e26624c80e2f961a Mon Sep 17 00:00:00 2001 From: Sam Heyman Date: Mon, 12 Sep 2016 13:08:15 +0100 Subject: [PATCH 03/13] updating the info about the 403 error sometimes seen after API key is generated --- README.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 1439484..57edf45 100644 --- a/README.rst +++ b/README.rst @@ -47,7 +47,7 @@ Quick start ----------- 1. If you don't already have one, create a `Skyscanner account`_. -2. Sign into your account and under Add Apps click Travel APIs to create your Travel API key +2. Sign into your account and under Add Apps click Travel APIs to create an API key 3. Set your API Key in your code:: from skyscanner.skyscanner import Flights @@ -91,5 +91,8 @@ Known Issues requests.exceptions.HTTPError: 429 Client Error: Too many requests in the last minute. -** Please allow up to 15 minutes for your API key to be activated. Until it is activated you will get a 403 exception. +* Please allow up to 15 minutes for your API key to be activated. Until it is activated you will get a 403 exception:: + + requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: http://partners.api.skyscanner.net/apiservices/pricing/v1.0?apiKey= + From 8c43fd8fb5d578b95e05e45e9c64f70732608919 Mon Sep 17 00:00:00 2001 From: Sam Heyman Date: Tue, 30 May 2017 11:23:10 +0100 Subject: [PATCH 04/13] adding a message to say that users need to request an API key --- README.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.rst b/README.rst index 57edf45..3dbbf6a 100644 --- a/README.rst +++ b/README.rst @@ -2,6 +2,9 @@ Skyscanner Python SDK =============================== +> You will need to contact us to request an API key to use our APIs. Please use the following form: https://partners.skyscanner.net/contact. +> We receive a large number of requests and although we do our best to reply to all we cannot guarantee that your application will be successful. + .. image:: https://api.travis-ci.org/Skyscanner/skyscanner-python-sdk.svg :target: https://travis-ci.org/Skyscanner/skyscanner-python-sdk From 77b9a0b45b0b3d21dc379cd6906a45a5adcf1657 Mon Sep 17 00:00:00 2001 From: Sam Heyman Date: Tue, 30 May 2017 11:32:07 +0100 Subject: [PATCH 05/13] updating urls to docs and login page, and adding the contact us link to the SDK docs --- README.rst | 13 +++++++------ docs/usage.rst | 4 +++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/README.rst b/README.rst index 3dbbf6a..9b7fbf0 100644 --- a/README.rst +++ b/README.rst @@ -49,14 +49,15 @@ Or, if you have virtualenvwrapper installed:: Quick start ----------- -1. If you don't already have one, create a `Skyscanner account`_. -2. Sign into your account and under Add Apps click Travel APIs to create an API key -3. Set your API Key in your code:: +1. Contact us to request an API key: https://partners.skyscanner.net/contact +2. If you don't already have one, create a `Skyscanner account`_. +3. Sign into your account and click 'Import Existing App' and use your API key to create an App +4. Set your API Key in your code:: from skyscanner.skyscanner import Flights flights_service = Flights('') -4. Get the flights live pricing result by writing a few lines of code:: +5. Get the flights live pricing result by writing a few lines of code:: from skyscanner.skyscanner import Flights @@ -75,7 +76,7 @@ Quick start Note that both the ``inbounddate`` and ``outbounddate`` might need to be updated. -.. _Skyscanner account: http://portal.business.skyscanner.net/en-gb/accounts/login/ +.. _Skyscanner account: https://partners.skyscanner.net/log-in/ More examples @@ -84,7 +85,7 @@ More examples For more example usage, refer to the `SDK documentation`_ or the `API documentation`_. .. _SDK documentation: https://skyscanner.readthedocs.org/en/latest/usage.html -.. _API documentation: http://business.skyscanner.net/portal/en-GB/Documentation/ApiOverview +.. _API documentation: https://skyscanner.github.io/slate/ Known Issues diff --git a/docs/usage.rst b/docs/usage.rst index 2e861f0..50aeb17 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -2,7 +2,9 @@ Usage ======== -To use Skyscanner Python SDK in a project, make sure that you set your API Key. For example:: +To use Skyscanner Python SDK in a project, you will need to request an API key. Please use the following form: https://partners.skyscanner.net/contact/ + +Once you have an API key you can set it as follows: from skyscanner.skyscanner import Flights From 9f590a88e25d0b6ce298d9d39b9638cff7126c54 Mon Sep 17 00:00:00 2001 From: Sam Heyman Date: Tue, 30 May 2017 12:36:14 +0100 Subject: [PATCH 06/13] reformating the message on the README --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 9b7fbf0..64dcb07 100644 --- a/README.rst +++ b/README.rst @@ -2,8 +2,8 @@ Skyscanner Python SDK =============================== -> You will need to contact us to request an API key to use our APIs. Please use the following form: https://partners.skyscanner.net/contact. -> We receive a large number of requests and although we do our best to reply to all we cannot guarantee that your application will be successful. +You will need to contact us to request an API key to use our APIs. Please use the following form: https://partners.skyscanner.net/contact. +We receive a large number of requests and although we do our best to reply to all we cannot guarantee that your application will be successful. .. image:: https://api.travis-ci.org/Skyscanner/skyscanner-python-sdk.svg :target: https://travis-ci.org/Skyscanner/skyscanner-python-sdk From 26ce4a563f538a689f2a29063f3604731703ddac Mon Sep 17 00:00:00 2001 From: Sam Heyman Date: Tue, 30 May 2017 12:37:26 +0100 Subject: [PATCH 07/13] more rewording on the README file --- README.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 64dcb07..069b176 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,8 @@ Skyscanner Python SDK =============================== -You will need to contact us to request an API key to use our APIs. Please use the following form: https://partners.skyscanner.net/contact. +You will need to contact us to request an API key to use our APIs via the following form: https://partners.skyscanner.net/contact. + We receive a large number of requests and although we do our best to reply to all we cannot guarantee that your application will be successful. .. image:: https://api.travis-ci.org/Skyscanner/skyscanner-python-sdk.svg From 6f84af48f6fcb85ccb3031cd6038e6020dff0e9a Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Wed, 22 Apr 2020 15:49:22 +0300 Subject: [PATCH 08/13] Use secure urls for calling B2B API --- README.rst | 14 ++-- docs/usage.rst | 114 +++++++++++++++--------------- skyscanner/skyscanner.py | 14 ++-- tests/test_skyscanner.py | 148 ++++++++++++++++++++------------------- 4 files changed, 146 insertions(+), 144 deletions(-) diff --git a/README.rst b/README.rst index 069b176..8612991 100644 --- a/README.rst +++ b/README.rst @@ -2,9 +2,9 @@ Skyscanner Python SDK =============================== -You will need to contact us to request an API key to use our APIs via the following form: https://partners.skyscanner.net/contact. +You will need to contact us to request an API key to use our APIs via the following form: https://partners.skyscanner.net/contact. -We receive a large number of requests and although we do our best to reply to all we cannot guarantee that your application will be successful. +We receive a large number of requests and although we do our best to reply to all we cannot guarantee that your application will be successful. .. image:: https://api.travis-ci.org/Skyscanner/skyscanner-python-sdk.svg :target: https://travis-ci.org/Skyscanner/skyscanner-python-sdk @@ -24,7 +24,7 @@ Skyscanner Python SDK for Skyscanner's API * Free software: Apache license * SDK Documentation: https://skyscanner.readthedocs.org. -* API Documentation: http://business.skyscanner.net/portal/en-GB/Documentation/ApiOverview +* API Documentation: https://business.skyscanner.net/portal/en-GB/Documentation/ApiOverview Features @@ -87,7 +87,7 @@ For more example usage, refer to the `SDK documentation`_ or the `API documentat .. _SDK documentation: https://skyscanner.readthedocs.org/en/latest/usage.html .. _API documentation: https://skyscanner.github.io/slate/ - + Known Issues ------------ @@ -97,7 +97,7 @@ Known Issues requests.exceptions.HTTPError: 429 Client Error: Too many requests in the last minute. * Please allow up to 15 minutes for your API key to be activated. Until it is activated you will get a 403 exception:: - - requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: http://partners.api.skyscanner.net/apiservices/pricing/v1.0?apiKey= - + requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://partners.api.skyscanner.net/apiservices/pricing/v1.0?apiKey= + + diff --git a/docs/usage.rst b/docs/usage.rst index 50aeb17..0c3dd97 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -7,34 +7,34 @@ To use Skyscanner Python SDK in a project, you will need to request an API key. Once you have an API key you can set it as follows: from skyscanner.skyscanner import Flights - - flights_service = Flights('') + + flights_service = Flights('') Flights: Live Pricing ~~~~~~~~~~~~~~~~~~~~~ -http://business.skyscanner.net/portal/en-GB/Documentation/FlightsLivePricingList +https://business.skyscanner.net/portal/en-GB/Documentation/FlightsLivePricingList Get live prices:: from skyscanner.skyscanner import Flights - + flights_service = Flights('') result = flights_service.get_result( - country='UK', - currency='GBP', - locale='en-GB', - originplace='SIN-sky', - destinationplace='KUL-sky', - outbounddate='2017-05-28', - inbounddate='2017-05-31', + country='UK', + currency='GBP', + locale='en-GB', + originplace='SIN-sky', + destinationplace='KUL-sky', + outbounddate='2017-05-28', + inbounddate='2017-05-31', adults=1).parsed Flights: Browse Cache ~~~~~~~~~~~~~~~~~~~~~ -http://business.skyscanner.net/portal/en-GB/Documentation/FlightsBrowseCacheOverview +https://business.skyscanner.net/portal/en-GB/Documentation/FlightsBrowseCacheOverview Cheapest quotes:: @@ -43,11 +43,11 @@ Cheapest quotes:: flights_cache_service = FlightsCache('') result = flights_cache_service.get_cheapest_quotes( market='UK', - currency='GBP', - locale='en-GB', - originplace='SIN-sky', - destinationplace='KUL-sky', - outbounddate='2017-05', + currency='GBP', + locale='en-GB', + originplace='SIN-sky', + destinationplace='KUL-sky', + outbounddate='2017-05', inbounddate='2017-06').parsed Cheapest price by route:: @@ -57,11 +57,11 @@ Cheapest price by route:: flights_cache_service = FlightsCache('') result = flights_cache_service.get_cheapest_price_by_route( market='UK', - currency='GBP', - locale='en-GB', - originplace='SIN-sky', - destinationplace='KUL-sky', - outbounddate='2017-05', + currency='GBP', + locale='en-GB', + originplace='SIN-sky', + destinationplace='KUL-sky', + outbounddate='2017-05', inbounddate='2017-06').parsed Cheapest price by date:: @@ -71,11 +71,11 @@ Cheapest price by date:: flights_cache_service = FlightsCache('') result = flights_cache_service.get_cheapest_price_by_date( market='UK', - currency='GBP', - locale='en-GB', - originplace='SIN-sky', - destinationplace='KUL-sky', - outbounddate='2017-05', + currency='GBP', + locale='en-GB', + originplace='SIN-sky', + destinationplace='KUL-sky', + outbounddate='2017-05', inbounddate='2017-06').parsed Grid of prices by date:: @@ -85,31 +85,31 @@ Grid of prices by date:: flights_cache_service = FlightsCache('') result = flights_cache_service.get_grid_prices_by_date( market='UK', - currency='GBP', - locale='en-GB', - originplace='SIN-sky', - destinationplace='KUL-sky', - outbounddate='2017-05', + currency='GBP', + locale='en-GB', + originplace='SIN-sky', + destinationplace='KUL-sky', + outbounddate='2017-05', inbounddate='2017-06').parsed Car Hire ~~~~~~~~ -http://business.skyscanner.net/portal/en-GB/Documentation/CarHireLivePricing +https://business.skyscanner.net/portal/en-GB/Documentation/CarHireLivePricing Get live prices:: - + from skyscanner.skyscanner import CarHire carhire_service = CarHire('') result = carhire_service.get_result( - market='UK', - currency='GBP', - locale='en-GB', - pickupplace='LHR-sky', - dropoffplace='LHR-sky', - pickupdatetime='2017-05-29T12:00', - dropoffdatetime='2017-05-29T18:00', + market='UK', + currency='GBP', + locale='en-GB', + pickupplace='LHR-sky', + dropoffplace='LHR-sky', + pickupdatetime='2017-05-29T12:00', + dropoffdatetime='2017-05-29T18:00', driverage='30', userip='175.156.244.174').parsed @@ -119,25 +119,25 @@ Car hire autosuggest:: carhire_service = CarHire('') result = carhire_service.location_autosuggest( - market='UK', - currency='GBP', - locale='en-GB', + market='UK', + currency='GBP', + locale='en-GB', query='Kuala').parsed Hotels ~~~~~~ -http://business.skyscanner.net/portal/en-GB/Documentation/HotelsOverview +https://business.skyscanner.net/portal/en-GB/Documentation/HotelsOverview Hotels autosuggest:: - + from skyscanner.skyscanner import Hotels hotels_service = Hotels('') result = hotels_service.location_autosuggest( - market='UK', - currency='GBP', - locale='en-GB', + market='UK', + currency='GBP', + locale='en-GB', query='Kuala').parsed Hotels prices and details:: @@ -146,11 +146,11 @@ Hotels prices and details:: hotels_service = Hotels(self.api_key) result = hotels_service.get_result( - market='UK', - currency='GBP', - locale='en-GB', - entityid=27543923, - checkindate='2017-05-26', - checkoutdate='2017-05-30', - guests=1, - rooms=1).parsed \ No newline at end of file + market='UK', + currency='GBP', + locale='en-GB', + entityid=27543923, + checkindate='2017-05-26', + checkoutdate='2017-05-30', + guests=1, + rooms=1).parsed diff --git a/skyscanner/skyscanner.py b/skyscanner/skyscanner.py index faa1c47..3af982b 100755 --- a/skyscanner/skyscanner.py +++ b/skyscanner/skyscanner.py @@ -73,7 +73,7 @@ class Transport(object): """ Parent class for initialization """ - API_HOST = 'http://partners.api.skyscanner.net' + API_HOST = 'https://partners.api.skyscanner.net' MARKET_SERVICE_URL = '{api_host}/apiservices/reference/v1.0/countries'\ .format(api_host=API_HOST) LOCATION_AUTOSUGGEST_URL = '{api_host}/apiservices/autosuggest/v1.0'\ @@ -202,7 +202,7 @@ def make_request(self, service_url, method='get', headers=None, data=None, def get_markets(self, market): """ Get the list of markets - http://business.skyscanner.net/portal/en-GB/Documentation/Markets + https://business.skyscanner.net/portal/en-GB/Documentation/Markets """ url = "{url}/{market}".format(url=self.MARKET_SERVICE_URL, market=market) @@ -213,13 +213,13 @@ def location_autosuggest(self, **params): Location Autosuggest Services Doc URLs: - http://business.skyscanner.net/portal/en-GB/ + https://business.skyscanner.net/portal/en-GB/ Documentation/Autosuggest - http://business.skyscanner.net/portal/en-GB/ + https://business.skyscanner.net/portal/en-GB/ Documentation/CarHireAutoSuggest - http://business.skyscanner.net/portal/en-GB/ + https://business.skyscanner.net/portal/en-GB/ Documentation/HotelsAutoSuggest Format: @@ -424,7 +424,7 @@ class Flights(Transport): Flights Live Pricing Please see: - http://business.skyscanner.net/portal/en-GB/ + https://business.skyscanner.net/portal/en-GB/ Documentation/FlightsLivePricingList """ @@ -465,7 +465,7 @@ class FlightsCache(Flights): Flights Browse Cache Please see: - http://business.skyscanner.net/portal/en-GB/ + https://business.skyscanner.net/portal/en-GB/ Documentation/FlightsBrowseCacheOverview """ diff --git a/tests/test_skyscanner.py b/tests/test_skyscanner.py index d67e19c..6ed5fce 100755 --- a/tests/test_skyscanner.py +++ b/tests/test_skyscanner.py @@ -411,7 +411,7 @@ def test_location_autosuggest_xml(self): def test_get_result_json(self): """ - http://partners.api.skyscanner.net/apiservices/carhire/liveprices/v2/ + https://partners.api.skyscanner.net/apiservices/carhire/liveprices/v2/ {market}/{currency}/{locale}/{pickupplace}/{dropoffplace}/ {pickupdatetime}/{dropoffdatetime}/{driverage} ?apiKey={apiKey}&userip={userip} @@ -436,7 +436,7 @@ def test_get_result_json(self): # def test_get_result_xml(self): # """ - # http://partners.api.skyscanner.net/apiservices/carhire/liveprices/v2/ + # https://partners.api.skyscanner.net/apiservices/carhire/liveprices/v2/ # {market}/{currency}/{locale}/{pickupplace}/{dropoffplace}/ # {pickupdatetime}/{dropoffdatetime}/{driverage} # ?apiKey={apiKey}&userip={userip} @@ -461,7 +461,7 @@ def test_get_result_json(self): def test_create_session(self): """ - http://partners.api.skyscanner.net/apiservices/carhire/liveprices/v2/ + https://partners.api.skyscanner.net/apiservices/carhire/liveprices/v2/ {market}/{currency}/{locale}/{pickupplace}/ {dropoffplace}/{pickupdatetime}/{dropoffdatetime}/{driverage} ?apiKey={apiKey}&userip={userip} @@ -519,76 +519,78 @@ def test_location_autosuggest_xml(self): self.assertTrue( len(self.result.findall('./Results/HotelResultDto')) > 0) - def test_get_result_json(self): - """ - http://partners.api.skyscanner.net/apiservices/carhire/liveprices/v2/ - {market}/{currency}/{locale}/{pickupplace}/{dropoffplace}/ - {pickupdatetime}/{dropoffdatetime}/{driverage} - ?apiKey={apiKey}&userip={userip} - - YYYY-MM-DDThh:mm - """ - - hotels_service = Hotels(self.api_key, response_format='json') - self.result = hotels_service.get_result( - market='UK', - currency='GBP', - locale='en-GB', - entityid=27543923, - checkindate=self.checkin, - checkoutdate=self.checkout, - guests=1, - rooms=1).parsed - - self.assertTrue('hotels' in self.result) - self.assertTrue(len(self.result['hotels']) > 0) - - def test_get_result_xml(self): - """ - http://partners.api.skyscanner.net/apiservices/carhire/liveprices/v2/ - {market}/{currency}/{locale}/{pickupplace}/{dropoffplace}/ - {pickupdatetime}/{dropoffdatetime}/{driverage} - ?apiKey={apiKey}&userip={userip} - - YYYY-MM-DDThh:mm - """ - - hotels_service = Hotels(self.api_key, response_format='xml') - self.result = hotels_service.get_result( - market='DE', - currency='EUR', - locale='de-DE', - entityid=27543923, - checkindate=self.checkin, - checkoutdate=self.checkout, - guests=1, - rooms=1).parsed - - self.assertTrue(self.result.find('./Hotels') is not None) - self.assertTrue(len(self.result.findall('./Hotels/HotelDto')) > 0) - - def test_create_session(self): - """ - http://partners.api.skyscanner.net/apiservices/carhire/liveprices/v2/ - {market}/{currency}/{locale}/{pickupplace}/{dropoffplace}/ - {pickupdatetime}/{dropoffdatetime}/{driverage} - ?apiKey={apiKey}&userip={userip} - - YYYY-MM-DDThh:mm - """ - hotels_service = Hotels(self.api_key) - - poll_url = hotels_service.create_session( - market='UK', - currency='GBP', - locale='en-GB', - entityid=27543923, - checkindate=self.checkin, - checkoutdate=self.checkout, - guests=1, - rooms=1) - - self.assertTrue(poll_url) + # Tests below are ignored due to deprecated hotel endpoints + # + # def test_get_result_json(self): + # """ + # https://partners.api.skyscanner.net/apiservices/carhire/liveprices/v2/ + # {market}/{currency}/{locale}/{pickupplace}/{dropoffplace}/ + # {pickupdatetime}/{dropoffdatetime}/{driverage} + # ?apiKey={apiKey}&userip={userip} + # + # YYYY-MM-DDThh:mm + # """ + # + # hotels_service = Hotels(self.api_key, response_format='json') + # self.result = hotels_service.get_result( + # market='UK', + # currency='GBP', + # locale='en-GB', + # entityid=27543923, + # checkindate=self.checkin, + # checkoutdate=self.checkout, + # guests=1, + # rooms=1).parsed + # + # self.assertTrue('hotels' in self.result) + # self.assertTrue(len(self.result['hotels']) > 0) + # + # def test_get_result_xml(self): + # """ + # https://partners.api.skyscanner.net/apiservices/carhire/liveprices/v2/ + # {market}/{currency}/{locale}/{pickupplace}/{dropoffplace}/ + # {pickupdatetime}/{dropoffdatetime}/{driverage} + # ?apiKey={apiKey}&userip={userip} + # + # YYYY-MM-DDThh:mm + # """ + # + # hotels_service = Hotels(self.api_key, response_format='xml') + # self.result = hotels_service.get_result( + # market='DE', + # currency='EUR', + # locale='de-DE', + # entityid=27543923, + # checkindate=self.checkin, + # checkoutdate=self.checkout, + # guests=1, + # rooms=1).parsed + # + # self.assertTrue(self.result.find('./Hotels') is not None) + # self.assertTrue(len(self.result.findall('./Hotels/HotelDto')) > 0) + # + # def test_create_session(self): + # """ + # https://partners.api.skyscanner.net/apiservices/carhire/liveprices/v2/ + # {market}/{currency}/{locale}/{pickupplace}/{dropoffplace}/ + # {pickupdatetime}/{dropoffdatetime}/{driverage} + # ?apiKey={apiKey}&userip={userip} + # + # YYYY-MM-DDThh:mm + # """ + # hotels_service = Hotels(self.api_key) + # + # poll_url = hotels_service.create_session( + # market='UK', + # currency='GBP', + # locale='en-GB', + # entityid=27543923, + # checkindate=self.checkin, + # checkoutdate=self.checkout, + # guests=1, + # rooms=1) + # + # self.assertTrue(poll_url) class TestFlights(SkyScannerTestCase): From 6b5a15e08052d5744c06feb86abab202a26ec9e6 Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Wed, 22 Apr 2020 16:21:35 +0300 Subject: [PATCH 09/13] Fix flake8 rules --- skyscanner/skyscanner.py | 3 ++- tests/test_skyscanner.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/skyscanner/skyscanner.py b/skyscanner/skyscanner.py index 3af982b..9fab86e 100755 --- a/skyscanner/skyscanner.py +++ b/skyscanner/skyscanner.py @@ -45,6 +45,7 @@ def configure_logger(log_level=logging.WARN): logger.addHandler(sa) return logger + log = configure_logger() STRICT, GRACEFUL, IGNORE = 'strict', 'graceful', 'ignore' @@ -92,7 +93,7 @@ def __init__(self, api_key, response_format='json'): if response_format.lower() not in self._SUPPORTED_FORMATS: raise ValueError( 'Unknown response format: {}'.format(response_format) + - ', supported formats are '.format( + + ', supported formats are '.format( ', '.join(self._SUPPORTED_FORMATS) ) ) diff --git a/tests/test_skyscanner.py b/tests/test_skyscanner.py index 6ed5fce..e61a811 100755 --- a/tests/test_skyscanner.py +++ b/tests/test_skyscanner.py @@ -343,8 +343,8 @@ def test_default_resp_callback_xml(self): t._default_resp_callback, FakeResponse(content='invalid XML') ) - except: - self.assertRaises(Exception, + except Exception as e: + self.assertRaises(e, t._default_resp_callback, FakeResponse(content='invalid XML') ) @@ -840,5 +840,6 @@ def test_get_result_xml(self): self.assertTrue( len(self.result.findall('./Itineraries/ItineraryApiDto')) > 0) + if __name__ == '__main__': unittest.main() From 5167afdfde51500f6c04ea836ae542cce6071a7a Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Wed, 22 Apr 2020 16:38:37 +0300 Subject: [PATCH 10/13] Fix travis build --- .travis.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index a1533bd..cd037d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,9 +4,14 @@ language: python python: - "3.4" - - "3.3" - "2.7" - "pypy" + +matrix: + include: + - python: 3.3 + dist: trusty + # command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors install: - pip install -r requirements.txt @@ -15,5 +20,5 @@ install: script: - flake8 - python runtests.py - - coverage run --source skyscanner setup.py test -after_success: coveralls \ No newline at end of file + - coverage run --source skyscanner setup.py test +after_success: coveralls From 0e51465743650a39c78084aa033726c5cce2bfd6 Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Wed, 22 Apr 2020 16:57:01 +0300 Subject: [PATCH 11/13] Fix Travis build --- .travis.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index cd037d6..bbb1fd1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,12 +6,6 @@ python: - "3.4" - "2.7" - "pypy" - -matrix: - include: - - python: 3.3 - dist: trusty - # command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors install: - pip install -r requirements.txt From 8cdbf306a3f60fadd36ab97151a094615cb42771 Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Wed, 22 Apr 2020 17:11:37 +0300 Subject: [PATCH 12/13] Bump lib version to 1.1.5 --- skyscanner/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skyscanner/__init__.py b/skyscanner/__init__.py index 941009c..e81d8fe 100755 --- a/skyscanner/__init__.py +++ b/skyscanner/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- __author__ = 'Ardy Dedase' __email__ = 'ardy.dedase@skyscanner.net' -__version__ = '1.1.4' +__version__ = '1.1.5' __copyright__ = "Copyright (C) 2016 Skyscanner Ltd" __license__ = """ Licensed under the Apache License, Version 2.0 (the "License"); From ff3aaa052b35b3f950b4cad3aa9dee564641b774 Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Mon, 27 Apr 2020 11:55:43 +0300 Subject: [PATCH 13/13] Update project README --- README.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.rst b/README.rst index 8612991..b826b5b 100644 --- a/README.rst +++ b/README.rst @@ -2,6 +2,14 @@ Skyscanner Python SDK =============================== +Important +========= + As of May 1st, 2020, the project is deprecated and no longer maintained. + The latest update in v1.1.5 includes changing the library to use a secure connection when calling Skyscanner's APIs as this is required for all users and http is no longer supported. The development of this SDK from that point on is fully abandoned. + + As we cannot guarantee for how long it will continue working, you should not to use the SDK when starting new projects. If it is already in use in your projects, please upgrade to its latest version and keep in mind that due to planned changes in our Skyscanner APIs it may not work as expected after July 2020. + + You will need to contact us to request an API key to use our APIs via the following form: https://partners.skyscanner.net/contact. We receive a large number of requests and although we do our best to reply to all we cannot guarantee that your application will be successful.