Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed base urls for HereMaps #28

Merged
merged 7 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions examples/compare_providers.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1384,9 +1384,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "routing-py",
chrstnbwnkl marked this conversation as resolved.
Show resolved Hide resolved
"display_name": "Python 3",
"language": "python",
"name": "routing-py"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -1398,7 +1398,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.9.5"
},
"toc": {
"base_numbering": 1,
Expand All @@ -1416,4 +1416,4 @@
},
"nbformat": 4,
"nbformat_minor": 1
}
}
9 changes: 6 additions & 3 deletions routingpy/routers/heremaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,11 +591,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"
chrstnbwnkl marked this conversation as resolved.
Show resolved Hide resolved
)

params = self.auth.copy()

locations = self._build_locations(locations)
Expand Down Expand Up @@ -992,11 +993,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]
Expand Down Expand Up @@ -1259,11 +1261,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)
Expand Down
16 changes: 8 additions & 8 deletions tests/test_heremaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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,
Expand All @@ -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",
Expand All @@ -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&"
Expand Down Expand Up @@ -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",
Expand All @@ -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,
Expand All @@ -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",
Expand All @@ -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&"
Expand Down