From c1d9ef8bdeb20a206022bb782dc6796f6a530c78 Mon Sep 17 00:00:00 2001 From: Brieuc Ryelandt Date: Thu, 28 Nov 2024 09:23:10 +0100 Subject: [PATCH] feat: add kwargs to pass to session request --- openmeteo_requests/Client.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openmeteo_requests/Client.py b/openmeteo_requests/Client.py index bb9d4be..97ecb3a 100644 --- a/openmeteo_requests/Client.py +++ b/openmeteo_requests/Client.py @@ -22,13 +22,13 @@ def __init__(self, session: TSession | None = None): self.session = session or requests.Session() # pylint: disable=too-many-arguments - def _get(self, cls: type[T], url: str, params: any, method: str, verify: bool | str | None) -> list[T]: + def _get(self, cls: type[T], url: str, params: any, method: str, verify: bool | str | None, **kwargs) -> list[T]: params["format"] = "flatbuffers" if method.upper() == "POST": - response = self.session.request("POST", url, data=params, verify=verify) + response = self.session.request("POST", url, data=params, verify=verify, **kwargs) else: - response = self.session.request("GET", url, params=params, verify=verify) + response = self.session.request("GET", url, params=params, verify=verify, **kwargs) if response.status_code in [400, 429]: response_body = response.json() @@ -48,10 +48,10 @@ def _get(self, cls: type[T], url: str, params: any, method: str, verify: bool | return messages def weather_api( - self, url: str, params: any, method: str = "GET", verify: bool | str | None = None + self, url: str, params: any, method: str = "GET", verify: bool | str | None = None, **kwargs ) -> list[WeatherApiResponse]: """Get and decode as weather api""" - return self._get(WeatherApiResponse, url, params, method, verify) + return self._get(WeatherApiResponse, url, params, method, verify, **kwargs) def __del__(self): """cleanup"""