@ -4,6 +4,7 @@ import httpx
|
||||
|
||||
from ...client import Client
|
||||
from ...models.auth_session import AuthSession
|
||||
from ...models.error_message import ErrorMessage
|
||||
from ...types import Response
|
||||
|
||||
def _get_kwargs(
|
||||
@ -23,20 +24,20 @@ def _get_kwargs(
|
||||
}
|
||||
|
||||
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Union[Any, AuthSession]]:
|
||||
def _parse_response(*, response: httpx.Response) -> Optional[Union[Any, AuthSession, ErrorMessage]]:
|
||||
if response.status_code == 200:
|
||||
response_200 = AuthSession.from_dict(response.json())
|
||||
return response_200
|
||||
if response.status_code == 401:
|
||||
response_401 = None
|
||||
response_401 = ErrorMessage.from_dict(response.json())
|
||||
return response_401
|
||||
if response.status_code == 403:
|
||||
response_403 = None
|
||||
response_403 = ErrorMessage.from_dict(response.json())
|
||||
return response_403
|
||||
return None
|
||||
|
||||
|
||||
def _build_response(*, response: httpx.Response) -> Response[Union[Any, AuthSession]]:
|
||||
def _build_response(*, response: httpx.Response) -> Response[Union[Any, AuthSession, ErrorMessage]]:
|
||||
return Response(
|
||||
status_code=response.status_code,
|
||||
content=response.content,
|
||||
@ -48,7 +49,7 @@ def _build_response(*, response: httpx.Response) -> Response[Union[Any, AuthSess
|
||||
def sync_detailed(
|
||||
*,
|
||||
client: Client,
|
||||
) -> Response[Union[Any, AuthSession]]:
|
||||
) -> Response[Union[Any, AuthSession, ErrorMessage]]:
|
||||
kwargs = _get_kwargs(
|
||||
client=client,
|
||||
)
|
||||
@ -64,7 +65,7 @@ def sync_detailed(
|
||||
def sync(
|
||||
*,
|
||||
client: Client,
|
||||
) -> Optional[Union[Any, AuthSession]]:
|
||||
) -> Optional[Union[Any, AuthSession, ErrorMessage]]:
|
||||
""" Get information about your API request session. This is primarily used for debugging. """
|
||||
|
||||
return sync_detailed(
|
||||
@ -75,7 +76,7 @@ def sync(
|
||||
async def asyncio_detailed(
|
||||
*,
|
||||
client: Client,
|
||||
) -> Response[Union[Any, AuthSession]]:
|
||||
) -> Response[Union[Any, AuthSession, ErrorMessage]]:
|
||||
kwargs = _get_kwargs(
|
||||
client=client,
|
||||
)
|
||||
@ -89,7 +90,7 @@ async def asyncio_detailed(
|
||||
async def asyncio(
|
||||
*,
|
||||
client: Client,
|
||||
) -> Optional[Union[Any, AuthSession]]:
|
||||
) -> Optional[Union[Any, AuthSession, ErrorMessage]]:
|
||||
""" Get information about your API request session. This is primarily used for debugging. """
|
||||
|
||||
return (
|
||||
|
Reference in New Issue
Block a user