better debugging URL
Browse files- camptocamp_api.py +9 -1
camptocamp_api.py
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
|
|
|
|
|
| 1 |
from pyproj import Transformer
|
| 2 |
import requests
|
| 3 |
import logging
|
|
@@ -16,10 +18,16 @@ class CamptocampAPI:
|
|
| 16 |
def __init__(self, language: str = "en") -> None:
|
| 17 |
self.language = language
|
| 18 |
|
|
|
|
|
|
|
| 19 |
def _request(self, endpoint: str, params: Dict[str, Any]) -> Dict[str, Any]:
|
| 20 |
params["pl"] = self.language
|
| 21 |
url = f"{self.BASE_URL}{endpoint}"
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
response = requests.get(url, params=params)
|
| 24 |
response.raise_for_status()
|
| 25 |
return response.json()
|
|
|
|
| 1 |
+
from urllib.parse import urlencode
|
| 2 |
+
|
| 3 |
from pyproj import Transformer
|
| 4 |
import requests
|
| 5 |
import logging
|
|
|
|
| 18 |
def __init__(self, language: str = "en") -> None:
|
| 19 |
self.language = language
|
| 20 |
|
| 21 |
+
from urllib.parse import urlencode
|
| 22 |
+
|
| 23 |
def _request(self, endpoint: str, params: Dict[str, Any]) -> Dict[str, Any]:
|
| 24 |
params["pl"] = self.language
|
| 25 |
url = f"{self.BASE_URL}{endpoint}"
|
| 26 |
+
full_url = f"{url}?{urlencode(params)}"
|
| 27 |
+
|
| 28 |
+
logger.info(f"[API REQUEST] {url} with params: {params}")
|
| 29 |
+
logger.info(f"[DEBUG URL] curl '{full_url}'")
|
| 30 |
+
|
| 31 |
response = requests.get(url, params=params)
|
| 32 |
response.raise_for_status()
|
| 33 |
return response.json()
|