promotions/gooyal_wallet_client/api/wallet/wallet_api_application_retrieve.py
Sayyid Hamid Mahdavi 18a866ca02 basic promote api
2025-08-03 15:54:22 +03:30

146 lines
3.5 KiB
Python

from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.application_transaction import ApplicationTransaction
from ...types import Response
def _get_kwargs(
uuid: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": f"/wallet/api/application/{uuid}/",
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[ApplicationTransaction]:
if response.status_code == 200:
response_200 = ApplicationTransaction.from_dict(response.json())
return response_200
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(response.status_code, response.content)
else:
return None
def _build_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Response[ApplicationTransaction]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
uuid: str,
*,
client: AuthenticatedClient,
) -> Response[ApplicationTransaction]:
"""
Args:
uuid (str):
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
Response[ApplicationTransaction]
"""
kwargs = _get_kwargs(
uuid=uuid,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
uuid: str,
*,
client: AuthenticatedClient,
) -> Optional[ApplicationTransaction]:
"""
Args:
uuid (str):
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
ApplicationTransaction
"""
return sync_detailed(
uuid=uuid,
client=client,
).parsed
async def asyncio_detailed(
uuid: str,
*,
client: AuthenticatedClient,
) -> Response[ApplicationTransaction]:
"""
Args:
uuid (str):
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
Response[ApplicationTransaction]
"""
kwargs = _get_kwargs(
uuid=uuid,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
uuid: str,
*,
client: AuthenticatedClient,
) -> Optional[ApplicationTransaction]:
"""
Args:
uuid (str):
Raises:
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.
Returns:
ApplicationTransaction
"""
return (
await asyncio_detailed(
uuid=uuid,
client=client,
)
).parsed