Skip to content

Commit

Permalink
feat: Option to disable SSL certificate verification (#77)
Browse files Browse the repository at this point in the history
* feat: option to disable SSL certificate verification

* Update openmeteo_requests/Client.py

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* pylint: disable=too-many-arguments

* Update openmeteo_requests/Client.py

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent c8e2bca commit 71e6436
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions openmeteo_requests/Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ 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]:
# pylint: disable=too-many-arguments
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()
Expand All @@ -46,9 +47,11 @@ 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"""
Expand Down

0 comments on commit 71e6436

Please sign in to comment.