Skip to content

Commit

Permalink
api_client: wrap methods
Browse files Browse the repository at this point in the history
  • Loading branch information
aviau committed Aug 15, 2024
1 parent c975ccd commit 3b32b58
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions flareio/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
import typing as t


T = t.TypeVar("T")


def _type_wraps(_: T) -> t.Callable[..., T]:
return lambda x: x # type: ignore


class FlareApiClient:
def __init__(
self,
Expand Down Expand Up @@ -79,27 +86,31 @@ def _request(
headers=headers,
)

@_type_wraps(requests.post)
def post(
self,
*args: t.Any,
**kwargs: t.Any,
) -> requests.Response:
return self._request("POST", *args, **kwargs)

@_type_wraps(requests.get)
def get(
self,
*args: t.Any,
**kwargs: t.Any,
) -> requests.Response:
return self._request("GET", *args, **kwargs)

@_type_wraps(requests.put)
def put(
self,
*args: t.Any,
**kwargs: t.Any,
) -> requests.Response:
return self._request("PUT", *args, **kwargs)

@_type_wraps(requests.delete)
def delete(
self,
*args: t.Any,
Expand Down

0 comments on commit 3b32b58

Please sign in to comment.