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

feat: add kwargs to pass to session request #81

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all 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
10 changes: 5 additions & 5 deletions openmeteo_requests/Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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"""
Expand Down