mirror of
https://github.com/PaiGramTeam/SIMNet.git
synced 2024-11-25 15:42:16 +00:00
🎨 Add URLTypes
This commit is contained in:
parent
27325f2791
commit
15c7228e2c
@ -18,6 +18,7 @@ from simnet.utils.types import (
|
|||||||
RequestData,
|
RequestData,
|
||||||
QueryParamTypes,
|
QueryParamTypes,
|
||||||
TimeoutTypes,
|
TimeoutTypes,
|
||||||
|
URLTypes,
|
||||||
)
|
)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger("SIMNet.BaseClient")
|
_LOGGER = logging.getLogger("SIMNet.BaseClient")
|
||||||
@ -223,7 +224,7 @@ class BaseClient(AsyncContextManager["BaseClient"]):
|
|||||||
async def request(
|
async def request(
|
||||||
self,
|
self,
|
||||||
method: str,
|
method: str,
|
||||||
url: str,
|
url: URLTypes,
|
||||||
data: Optional[RequestData] = None,
|
data: Optional[RequestData] = None,
|
||||||
json: Optional[Any] = None,
|
json: Optional[Any] = None,
|
||||||
params: Optional[QueryParamTypes] = None,
|
params: Optional[QueryParamTypes] = None,
|
||||||
@ -237,7 +238,7 @@ class BaseClient(AsyncContextManager["BaseClient"]):
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
method (str): The HTTP method to use for the request (e.g., "GET", "POST").
|
method (str): The HTTP method to use for the request (e.g., "GET", "POST").
|
||||||
url (str): The URL to send the request to.
|
url (URLTypes): The URL to send the request to.
|
||||||
data (Optional[RequestData]): The request data to include in the body of the request.
|
data (Optional[RequestData]): The request data to include in the body of the request.
|
||||||
json (Optional[Any]): The JSON payload to include in the body of the request.
|
json (Optional[Any]): The JSON payload to include in the body of the request.
|
||||||
params (Optional[QueryParamTypes]): The query parameters to include in the request.
|
params (Optional[QueryParamTypes]): The query parameters to include in the request.
|
||||||
@ -268,7 +269,7 @@ class BaseClient(AsyncContextManager["BaseClient"]):
|
|||||||
async def request_api(
|
async def request_api(
|
||||||
self,
|
self,
|
||||||
method: str,
|
method: str,
|
||||||
url: str,
|
url: URLTypes,
|
||||||
json: Optional[Any] = None,
|
json: Optional[Any] = None,
|
||||||
params: Optional[QueryParamTypes] = None,
|
params: Optional[QueryParamTypes] = None,
|
||||||
headers: Optional[HeaderTypes] = None,
|
headers: Optional[HeaderTypes] = None,
|
||||||
@ -281,7 +282,7 @@ class BaseClient(AsyncContextManager["BaseClient"]):
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
method (str): The HTTP method to use for the request (e.g., "GET", "POST").
|
method (str): The HTTP method to use for the request (e.g., "GET", "POST").
|
||||||
url (str): The URL to send the request to.
|
url (URLTypes): The URL to send the request to.
|
||||||
json (Optional[Any]): The JSON payload to include in the body of the request.
|
json (Optional[Any]): The JSON payload to include in the body of the request.
|
||||||
params (Optional[QueryParamTypes]): The query parameters to include in the request.
|
params (Optional[QueryParamTypes]): The query parameters to include in the request.
|
||||||
headers (Optional[HeaderTypes]): The headers to include in the request.
|
headers (Optional[HeaderTypes]): The headers to include in the request.
|
||||||
@ -314,7 +315,7 @@ class BaseClient(AsyncContextManager["BaseClient"]):
|
|||||||
|
|
||||||
async def request_lab(
|
async def request_lab(
|
||||||
self,
|
self,
|
||||||
url: str,
|
url: URLTypes,
|
||||||
method: Optional[str] = None,
|
method: Optional[str] = None,
|
||||||
data: Optional[Any] = None,
|
data: Optional[Any] = None,
|
||||||
params: Optional[QueryParamTypes] = None,
|
params: Optional[QueryParamTypes] = None,
|
||||||
@ -330,7 +331,7 @@ class BaseClient(AsyncContextManager["BaseClient"]):
|
|||||||
It also adds headers for the lab API and handles the case where the method is not specified.
|
It also adds headers for the lab API and handles the case where the method is not specified.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
url (str): The URL to send the request to.
|
url (URLTypes): The URL to send the request to.
|
||||||
method (Optional[str]): The HTTP method to use for the request (e.g., "GET", "POST").
|
method (Optional[str]): The HTTP method to use for the request (e.g., "GET", "POST").
|
||||||
data (Optional[Any]): The JSON payload to include in the body of the request.
|
data (Optional[Any]): The JSON payload to include in the body of the request.
|
||||||
params (Optional[QueryParamTypes]): The query parameters to include in the request.
|
params (Optional[QueryParamTypes]): The query parameters to include in the request.
|
||||||
|
@ -2,6 +2,7 @@ from typing import TypeVar, Union, Mapping, Optional, Sequence, Dict, List, Tupl
|
|||||||
|
|
||||||
RT = TypeVar("RT", bound="BaseClient")
|
RT = TypeVar("RT", bound="BaseClient")
|
||||||
|
|
||||||
|
URLTypes = Union["URL", str]
|
||||||
|
|
||||||
CookieTypes = Union["Cookie", Dict[str, str], List[Tuple[str, str]]]
|
CookieTypes = Union["Cookie", Dict[str, str], List[Tuple[str, str]]]
|
||||||
RequestData = Mapping[str, Any]
|
RequestData = Mapping[str, Any]
|
||||||
|
Loading…
Reference in New Issue
Block a user