From abbd9fa90ea6e198a0a74b7c322bb8a79324044a Mon Sep 17 00:00:00 2001 From: patrick-zippenfenig Date: Mon, 5 Aug 2024 17:42:25 +0200 Subject: [PATCH] feat: option to disable SSL certificate verification --- 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 d12c16d..f6bb80a 100644 --- a/openmeteo_requests/Client.py +++ b/openmeteo_requests/Client.py @@ -21,13 +21,13 @@ class Client: def __init__(self, session: TSession | None = None): self.session = session or requests.Session() - def _get(self, cls: type[T], url: str, params: any, method: str) -> list[T]: + def _get(self, cls: type[T], url: str, params: any, method: str, verify: bool | str | None) -> list[T]: params["format"] = "flatbuffers" if method.upper() == "POST": - response = self.session.request("POST", url, data=params) + response = self.session.request("POST", url, data=params, verify=verify) else: - response = self.session.request("GET", url, params=params) + response = self.session.request("GET", url, params=params, verify=verify) if response.status_code in [400, 429]: response_body = response.json() @@ -46,9 +46,9 @@ def _get(self, cls: type[T], url: str, params: any, method: str) -> list[T]: pos += length + 4 return messages - def weather_api(self, url: str, params: any, method: str = "GET") -> list[WeatherApiResponse]: + def weather_api(self, url: str, params: any, method: str = "GET", verify: bool | str | None = None) -> list[WeatherApiResponse]: """Get and decode as weather api""" - return self._get(WeatherApiResponse, url, params, method) + return self._get(WeatherApiResponse, url, params, method, verify) def __del__(self): """cleanup"""