diff --git a/CHANGELOG.md b/CHANGELOG.md index 44c67b5..5c76095 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Fixed - enhanced error handling for directions with Google [#15](https://github.com/gis-ops/routing-py/issues/15) - fixed MapboxOSRM client, removing unused parameters and unifying Isochrones interface [#21](https://github.com/gis-ops/routing-py/issues/21) +- fixed bug that caused HereMaps client to use wrong API endpoints [#28](https://github.com/gis-ops/routing-py/pull/28) ### Changed - BREAKING: pulled client stuff into a separate Client class which gets passed to the individual router instances with the default being the same as before [#24](https://github.com/gis-ops/routing-py/pull/24) diff --git a/routingpy/routers/heremaps.py b/routingpy/routers/heremaps.py index e02514e..5e2bfb1 100644 --- a/routingpy/routers/heremaps.py +++ b/routingpy/routers/heremaps.py @@ -28,9 +28,6 @@ class HereMaps: """Performs requests to the HERE Maps API services.""" - _DEFAULT_BASE_URL = "https://route.api.here.com/routing/7.2" - _APIKEY_BASE_URL = "https://route.ls.hereapi.com/routing/7.2" - def __init__( self, app_id=None, @@ -95,14 +92,12 @@ def __init__( self.api_key = api_key if self.api_key: - self.base_url = self._APIKEY_BASE_URL self.auth = {"apikey": self.api_key} else: - self.base_url = self._DEFAULT_BASE_URL self.auth = {"app_id": self.app_id, "app_code": self.app_code} self.client = client( - self.base_url, + "", user_agent, timeout, retry_timeout, @@ -591,11 +586,12 @@ def directions( # noqa: C901 :rtype: :class:`routingpy.direction.Direction` or :class:`routingpy.direction.Directions` """ - self.base_url = ( + self.client.base_url = ( "https://route.api.here.com/routing/7.2" if self.api_key is None else "https://route.ls.hereapi.com/routing/7.2" ) + params = self.auth.copy() locations = self._build_locations(locations) @@ -992,11 +988,12 @@ def isochrones( # noqa: C901 :rtype: dict """ - self.base_url = ( + self.client.base_url = ( "https://isoline.route.api.here.com/routing/7.2" if self.api_key is None else "https://isoline.route.ls.hereapi.com/routing/7.2" ) + params = self.auth.copy() params[center_type] = self._build_locations(locations)[0] @@ -1259,11 +1256,12 @@ def matrix( # noqa: C901 :returns: raw JSON response :rtype: dict """ - self.base_url = ( + self.client.base_url = ( "https://matrix.route.api.here.com/routing/7.2" if self.api_key is None else "https://matrix.route.ls.hereapi.com/routing/7.2" ) + params = self.auth.copy() locations = self._build_locations(locations) diff --git a/tests/test_heremaps.py b/tests/test_heremaps.py index f3446bf..8687949 100644 --- a/tests/test_heremaps.py +++ b/tests/test_heremaps.py @@ -148,7 +148,7 @@ def test_full_isochrones_response_object(self): responses.add( responses.GET, - "https://route.api.here.com/routing/7.2/calculateisoline.json", + "https://isoline.route.api.here.com/routing/7.2/calculateisoline.json", status=200, json=ENDPOINTS_RESPONSES[self.name]["isochrones"], content_type="application/json", @@ -158,7 +158,7 @@ def test_full_isochrones_response_object(self): self.assertEqual(1, len(responses.calls)) self.assertURLEqual( - "https://route.api.here.com/routing/7.2/calculateisoline.json?app_code=sample_app_code&" + "https://isoline.route.api.here.com/routing/7.2/calculateisoline.json?app_code=sample_app_code&" "app_id=sample_app_id&mode=fastest%3Bcar&quality=1&range=1000%2C2000%2C3000&rangeType=distance&" "singleComponent=false&start=geo%2148.23424%2C8.34234", responses.calls[0].request.url, @@ -178,7 +178,7 @@ def test_full_matrix(self): responses.add( responses.GET, - "https://route.api.here.com/routing/7.2/calculatematrix.json", + "https://matrix.route.api.here.com/routing/7.2/calculatematrix.json", status=200, json=ENDPOINTS_RESPONSES[self.name]["matrix"], content_type="application/json", @@ -188,7 +188,7 @@ def test_full_matrix(self): self.assertEqual(1, len(responses.calls)) self.assertURLEqual( - "https://route.api.here.com/routing/7.2/calculatematrix.json?app_code=sample_app_code&" + "https://matrix.route.api.here.com/routing/7.2/calculatematrix.json?app_code=sample_app_code&" "app_id=sample_app_id&destination0=geo%2149.445776%2C8.780916&height=20&length=10&limitedWeight=10&" "mode=fastest%3Bcar&shippedHazardousGoods=gas%2Cflammable&start0=geo%2149.420577%2C8.688641&" "start1=geo%2149.415776%2C8.680916&summaryAttributes=traveltime%2Ccostfactor&trailersCount=3&truckType=truck&" @@ -333,7 +333,7 @@ def test_full_isochrones_response_object(self): responses.add( responses.GET, - "https://route.ls.hereapi.com/routing/7.2/calculateisoline.json", + "https://isoline.route.ls.hereapi.com/routing/7.2/calculateisoline.json", status=200, json=ENDPOINTS_RESPONSES[self.name]["isochrones"], content_type="application/json", @@ -343,7 +343,7 @@ def test_full_isochrones_response_object(self): self.assertEqual(1, len(responses.calls)) self.assertURLEqual( - "https://route.ls.hereapi.com/routing/7.2/calculateisoline.json?apikey=sample_api_key&" + "https://isoline.route.ls.hereapi.com/routing/7.2/calculateisoline.json?apikey=sample_api_key&" "mode=fastest%3Bcar&quality=1&range=1000%2C2000%2C3000&rangeType=distance&" "singleComponent=false&start=geo%2148.23424%2C8.34234", responses.calls[0].request.url, @@ -363,7 +363,7 @@ def test_full_matrix(self): responses.add( responses.GET, - "https://route.ls.hereapi.com/routing/7.2/calculatematrix.json", + "https://matrix.route.ls.hereapi.com/routing/7.2/calculatematrix.json", status=200, json=ENDPOINTS_RESPONSES[self.name]["matrix"], content_type="application/json", @@ -373,7 +373,7 @@ def test_full_matrix(self): self.assertEqual(1, len(responses.calls)) self.assertURLEqual( - "https://route.ls.hereapi.com/routing/7.2/calculatematrix.json?apikey=sample_api_key&" + "https://matrix.route.ls.hereapi.com/routing/7.2/calculatematrix.json?apikey=sample_api_key&" "destination0=geo%2149.445776%2C8.780916&height=20&length=10&limitedWeight=10&" "mode=fastest%3Bcar&shippedHazardousGoods=gas%2Cflammable&start0=geo%2149.420577%2C8.688641&" "start1=geo%2149.415776%2C8.680916&summaryAttributes=traveltime%2Ccostfactor&trailersCount=3&truckType=truck&"