remove unnecessary clients

This commit is contained in:
Ali Asadi 2026-08-01 09:27:10 +03:30
parent 3c78cd2205
commit 7e04edbc48
40 changed files with 259 additions and 4027 deletions

View file

@ -26,3 +26,8 @@ WALLET_BASE_PUBLIC_URL=https://wallet-staging.gooyal.ir
WALLET_RIAL=af7d967f-30c0-409b-9066-2549f2da5e5e WALLET_RIAL=af7d967f-30c0-409b-9066-2549f2da5e5e
WALLET_REWARD=e7c9d4d1-4d1f-43b2-96f7-4d4a168f480d WALLET_REWARD=e7c9d4d1-4d1f-43b2-96f7-4d4a168f480d
ADVERTISING_BASE_PUBLIC_URL=https://advertising-staging.winsoo.ir ADVERTISING_BASE_PUBLIC_URL=https://advertising-staging.winsoo.ir
CHAT_BASE_PUBLIC_URL=
NOTIFICATIONS_BASE_PUBLIC_URL=
PROMOTIONS_BASE_PUBLIC_URL=
CAMPAIGN_BASE_PUBLIC_URL=
IPG_BASE_PUBLIC_URL=

0
apps/proxy/__init__.py Normal file
View file

6
apps/proxy/apps.py Normal file
View file

@ -0,0 +1,6 @@
from django.apps import AppConfig
class ProxyConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "apps.proxy"

112
apps/proxy/schema.py Normal file
View file

@ -0,0 +1,112 @@
import concurrent.futures
import copy
import logging
import requests
from django.conf import settings
from django.core.cache import cache
logger = logging.getLogger(__name__)
CACHE_KEY_TEMPLATE = "proxy_upstream_openapi_schema_{service}"
CACHE_TIMEOUT_SECONDS = 300
FETCH_TIMEOUT_SECONDS = 5
def _rewrite_schema_refs(node, rename):
"""Recursively repoint `$ref: '#/components/schemas/<Name>'` at the
renamed (service-prefixed) schema, in place."""
if isinstance(node, dict):
ref = node.get("$ref")
if isinstance(ref, str) and ref.startswith("#/components/schemas/"):
name = ref.rsplit("/", 1)[-1]
if name in rename:
node["$ref"] = f"#/components/schemas/{rename[name]}"
for value in node.values():
_rewrite_schema_refs(value, rename)
elif isinstance(node, list):
for item in node:
_rewrite_schema_refs(item, rename)
def _fetch_service_schema(service, base_url, schema_path):
cache_key = CACHE_KEY_TEMPLATE.format(service=service)
cached = cache.get(cache_key)
if cached is not None:
return cached
url = f"{base_url.rstrip('/')}{schema_path}"
try:
response = requests.get(url, timeout=FETCH_TIMEOUT_SECONDS)
response.raise_for_status()
schema = response.json()
except (requests.RequestException, ValueError) as exc:
logger.warning("Could not fetch OpenAPI schema for service %r from %s: %s", service, url, exc)
return None
cache.set(cache_key, schema, timeout=CACHE_TIMEOUT_SECONDS)
return schema
def merge_upstream_schemas(result, generator, request, public):
"""drf-spectacular POSTPROCESSING_HOOKS entry point.
Folds every proxied service's own OpenAPI document into this service's
schema under `/<service>/...` paths (mirroring apps.proxy.views), so the
combined swagger covers every endpoint this proxy forwards to, DTOs
included. Schemas are cached per service; a service that's unconfigured
or unreachable is skipped rather than failing the whole document.
"""
services = {
service: base_url
for service, base_url in settings.PROXY_SERVICE_BASE_URLS.items()
if base_url
}
if not services:
return result
schema_paths = settings.PROXY_SERVICE_SCHEMA_PATHS
with concurrent.futures.ThreadPoolExecutor(max_workers=len(services)) as executor:
futures = {
executor.submit(
_fetch_service_schema,
service,
base_url,
schema_paths.get(service, "/swagger/?format=json"),
): service
for service, base_url in services.items()
}
fetched = {}
for future in concurrent.futures.as_completed(futures):
service = futures[future]
schema = future.result()
if schema:
fetched[service] = schema
result.setdefault("paths", {})
result.setdefault("components", {}).setdefault("schemas", {})
for service, schema in fetched.items():
schema = copy.deepcopy(schema)
upstream_schemas = schema.get("components", {}).get("schemas", {})
rename = {name: f"{service}_{name}" for name in upstream_schemas}
_rewrite_schema_refs(schema.get("paths", {}), rename)
_rewrite_schema_refs(upstream_schemas, rename)
for name, definition in upstream_schemas.items():
result["components"]["schemas"][rename[name]] = definition
label = service.capitalize()
for path, operations in schema.get("paths", {}).items():
proxied_operations = copy.deepcopy(operations)
for operation in proxied_operations.values():
if not isinstance(operation, dict):
continue
operation["tags"] = [label]
if "operationId" in operation:
operation["operationId"] = f"{service}_{operation['operationId']}"
result["paths"][f"/{service}{path}"] = proxied_operations
return result

11
apps/proxy/urls.py Normal file
View file

@ -0,0 +1,11 @@
from django.urls import path
from apps.proxy.views import ServiceProxyView
app_name = "proxy"
urlpatterns = [
path("<str:service>/", ServiceProxyView.as_view(), name="proxy-root"),
path("<str:service>/<path:rest>", ServiceProxyView.as_view(), name="proxy"),
]

77
apps/proxy/views.py Normal file
View file

@ -0,0 +1,77 @@
import requests
from django.conf import settings
from django.http import HttpResponse
from django.utils.decorators import method_decorator
from django.views import View
from django.views.decorators.csrf import csrf_exempt
# Headers that must not be copied verbatim between hops (RFC 7230 6.1) plus
# framing headers that HttpResponse recomputes itself.
HOP_BY_HOP_HEADERS = {
"connection",
"keep-alive",
"proxy-authenticate",
"proxy-authorization",
"te",
"trailers",
"transfer-encoding",
"upgrade",
"content-encoding",
"content-length",
}
def _incoming_headers(request):
headers = {}
for key, value in request.META.items():
if key.startswith("HTTP_"):
name = key[5:].replace("_", "-").title()
elif key in ("CONTENT_TYPE", "CONTENT_LENGTH") and value:
name = key.replace("_", "-").title()
else:
continue
headers[name] = value
headers.pop("Host", None)
return headers
@method_decorator(csrf_exempt, name="dispatch")
class ServiceProxyView(View):
"""Forwards `/<service>/<rest>` to the configured base URL for `service`."""
def dispatch(self, request, service, rest="", *args, **kwargs):
base_url = settings.PROXY_SERVICE_BASE_URLS.get(service)
if not base_url:
return HttpResponse(
f'Unknown or unconfigured service "{service}".',
status=404,
content_type="text/plain",
)
target_url = f"{base_url.rstrip('/')}/{rest.lstrip('/')}"
query_string = request.META.get("QUERY_STRING", "")
if query_string:
target_url = f"{target_url}?{query_string}"
try:
upstream = requests.request(
method=request.method,
url=target_url,
headers=_incoming_headers(request),
data=request.body,
timeout=settings.SERVICE_REQUEST_TIMEOUT,
allow_redirects=False,
)
except requests.RequestException as exc:
return HttpResponse(
f'Error contacting upstream service "{service}": {exc}',
status=502,
content_type="text/plain",
)
response = HttpResponse(content=upstream.content, status=upstream.status_code)
for name, value in upstream.headers.items():
if name.lower() in HOP_BY_HOP_HEADERS:
continue
response[name] = value
return response

View file

@ -43,6 +43,7 @@ THIRD_PARTY_APPS = [
LOCAL_APPS = [ LOCAL_APPS = [
"apps.core", "apps.core",
"apps.reports", "apps.reports",
"apps.proxy",
] ]
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
@ -152,9 +153,16 @@ REST_FRAMEWORK = {
SPECTACULAR_SETTINGS = { SPECTACULAR_SETTINGS = {
"TITLE": "CRM Backend API", "TITLE": "CRM Backend API",
"DESCRIPTION": "API for CRM report generation and health checks.", "DESCRIPTION": (
"API for CRM report generation and health checks, plus a merged view of "
"every proxied service's own API (see apps.proxy)."
),
"VERSION": "1.0.0", "VERSION": "1.0.0",
"SERVE_INCLUDE_SCHEMA": False, "SERVE_INCLUDE_SCHEMA": False,
"POSTPROCESSING_HOOKS": [
"drf_spectacular.hooks.postprocess_schema_enums",
"apps.proxy.schema.merge_upstream_schemas",
],
} }
@ -172,3 +180,38 @@ OAUTH2_CLIENT_SECRET = env("OAUTH2_CLIENT_SECRET", default="")
OAUTH2_SCOPES = env("OAUTH2_SCOPES", default="") OAUTH2_SCOPES = env("OAUTH2_SCOPES", default="")
ADVERTISING_BASE_PUBLIC_URL = env("ADVERTISING_BASE_PUBLIC_URL", default="") ADVERTISING_BASE_PUBLIC_URL = env("ADVERTISING_BASE_PUBLIC_URL", default="")
ACCOUNTS_BASE_PUBLIC_URL = env("ACCOUNTS_BASE_PUBLIC_URL", default="") ACCOUNTS_BASE_PUBLIC_URL = env("ACCOUNTS_BASE_PUBLIC_URL", default="")
WALLET_BASE_PUBLIC_URL = env("WALLET_BASE_PUBLIC_URL", default="")
WALLET_RIAL = env("WALLET_RIAL", default="")
WALLET_REWARD = env("WALLET_REWARD", default="")
CHAT_BASE_PUBLIC_URL = env("CHAT_BASE_PUBLIC_URL", default="")
NOTIFICATIONS_BASE_PUBLIC_URL = env("NOTIFICATIONS_BASE_PUBLIC_URL", default="")
PROMOTIONS_BASE_PUBLIC_URL = env("PROMOTIONS_BASE_PUBLIC_URL", default="")
CAMPAIGN_BASE_PUBLIC_URL = env("CAMPAIGN_BASE_PUBLIC_URL", default="")
IPG_BASE_PUBLIC_URL = env("IPG_BASE_PUBLIC_URL", default="")
# Maps the first path segment of a proxied request (thisprojectbaseurl/<service>/<rest>)
# to the upstream service's base URL. See apps.proxy.views.ServiceProxyView.
PROXY_SERVICE_BASE_URLS = {
"accounts": ACCOUNTS_BASE_PUBLIC_URL,
"wallet": WALLET_BASE_PUBLIC_URL,
"advertising": ADVERTISING_BASE_PUBLIC_URL,
"chat": CHAT_BASE_PUBLIC_URL,
"notifications": NOTIFICATIONS_BASE_PUBLIC_URL,
"promotions": PROMOTIONS_BASE_PUBLIC_URL,
"campaign": CAMPAIGN_BASE_PUBLIC_URL,
"ipg": IPG_BASE_PUBLIC_URL,
}
# Where each service publishes its own raw OpenAPI document (drf-spectacular's
# SpectacularAPIView, mounted at different prefixes per service). Used by
# apps.proxy.schema to fold every proxied endpoint into this service's swagger.
PROXY_SERVICE_SCHEMA_PATHS = {
"accounts": "/swagger/?format=json",
"wallet": "/swagger/?format=json",
"advertising": "/swagger/?format=json",
"chat": "/swagger/?format=json",
"notifications": "/swagger/?format=json",
"promotions": "/swagger/?format=json",
"campaign": "/api/swagger/schema/?format=json",
"ipg": "/swagger/?format=json",
}

View file

@ -14,4 +14,7 @@ urlpatterns = [
path("api/redoc/", SpectacularRedocView.as_view(url_name="schema"), name="redoc"), path("api/redoc/", SpectacularRedocView.as_view(url_name="schema"), name="redoc"),
path("api/", include("apps.core.urls")), path("api/", include("apps.core.urls")),
path("api/reports/", include("apps.reports.urls")), path("api/reports/", include("apps.reports.urls")),
# Catch-all reverse proxy: thisprojectbaseurl/<service>/<rest of url>.
# Must stay last so it never shadows the routes above.
path("", include("apps.proxy.urls")),
] ]

View file

@ -9,9 +9,6 @@ from httpx import Request
from utils.clients.gooyal_accounts_client import AuthenticatedClient from utils.clients.gooyal_accounts_client import AuthenticatedClient
from utils.clients.gooyal_accounts_client.models import Account from utils.clients.gooyal_accounts_client.models import Account
from utils.clients.gooyal_accounts_client.api.users import (users_api_users_details_retrieve) from utils.clients.gooyal_accounts_client.api.users import (users_api_users_details_retrieve)
from utils.clients.gooyal_wallet_client.types import Response
from django.conf import Settings

View file

@ -1,8 +0,0 @@
"""A client library for accessing Gooyal Wallet"""
from .client import AuthenticatedClient, Client
__all__ = (
"AuthenticatedClient",
"Client",
)

View file

@ -1 +0,0 @@
"""Contains methods for accessing the API"""

View file

@ -1 +0,0 @@
"""Contains endpoint functions for accessing the API"""

View file

@ -1,168 +0,0 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.application_deposit import ApplicationDeposit
from ...types import Response
def _get_kwargs(
payer_wallet: str,
*,
body: ApplicationDeposit,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "post",
"url": f"/wallet/api/application/{payer_wallet}/deposit/",
}
_kwargs["json"] = body.to_dict()
headers["Content-Type"] = "application/json"
_kwargs["headers"] = headers
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[ApplicationDeposit]:
if response.status_code == 201:
response_201 = ApplicationDeposit.from_dict(response.json())
return response_201
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[ApplicationDeposit]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
payer_wallet: str,
*,
client: AuthenticatedClient,
body: ApplicationDeposit,
) -> Response[ApplicationDeposit]:
"""
Args:
payer_wallet (str):
body (ApplicationDeposit):
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[ApplicationDeposit]
"""
kwargs = _get_kwargs(
payer_wallet=payer_wallet,
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
payer_wallet: str,
*,
client: AuthenticatedClient,
body: ApplicationDeposit,
) -> Optional[ApplicationDeposit]:
"""
Args:
payer_wallet (str):
body (ApplicationDeposit):
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:
ApplicationDeposit
"""
return sync_detailed(
payer_wallet=payer_wallet,
client=client,
body=body,
).parsed
async def asyncio_detailed(
payer_wallet: str,
*,
client: AuthenticatedClient,
body: ApplicationDeposit,
) -> Response[ApplicationDeposit]:
"""
Args:
payer_wallet (str):
body (ApplicationDeposit):
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[ApplicationDeposit]
"""
kwargs = _get_kwargs(
payer_wallet=payer_wallet,
body=body,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
payer_wallet: str,
*,
client: AuthenticatedClient,
body: ApplicationDeposit,
) -> Optional[ApplicationDeposit]:
"""
Args:
payer_wallet (str):
body (ApplicationDeposit):
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:
ApplicationDeposit
"""
return (
await asyncio_detailed(
payer_wallet=payer_wallet,
client=client,
body=body,
)
).parsed

View file

@ -1,160 +0,0 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.application_deposit import ApplicationDeposit
from ...types import Response
def _get_kwargs(
payer_wallet: str,
uuid: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": f"/wallet/api/application/{payer_wallet}/deposit/{uuid}/rollback",
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[ApplicationDeposit]:
if response.status_code == 200:
response_200 = ApplicationDeposit.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[ApplicationDeposit]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
payer_wallet: str,
uuid: str,
*,
client: AuthenticatedClient,
) -> Response[ApplicationDeposit]:
"""
Args:
payer_wallet (str):
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[ApplicationDeposit]
"""
kwargs = _get_kwargs(
payer_wallet=payer_wallet,
uuid=uuid,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
payer_wallet: str,
uuid: str,
*,
client: AuthenticatedClient,
) -> Optional[ApplicationDeposit]:
"""
Args:
payer_wallet (str):
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:
ApplicationDeposit
"""
return sync_detailed(
payer_wallet=payer_wallet,
uuid=uuid,
client=client,
).parsed
async def asyncio_detailed(
payer_wallet: str,
uuid: str,
*,
client: AuthenticatedClient,
) -> Response[ApplicationDeposit]:
"""
Args:
payer_wallet (str):
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[ApplicationDeposit]
"""
kwargs = _get_kwargs(
payer_wallet=payer_wallet,
uuid=uuid,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
payer_wallet: str,
uuid: str,
*,
client: AuthenticatedClient,
) -> Optional[ApplicationDeposit]:
"""
Args:
payer_wallet (str):
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:
ApplicationDeposit
"""
return (
await asyncio_detailed(
payer_wallet=payer_wallet,
uuid=uuid,
client=client,
)
).parsed

View file

@ -1,160 +0,0 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.application_deposit import ApplicationDeposit
from ...types import Response
def _get_kwargs(
payer_wallet: str,
uuid: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": f"/wallet/api/application/{payer_wallet}/deposit/{uuid}/verify",
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[ApplicationDeposit]:
if response.status_code == 200:
response_200 = ApplicationDeposit.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[ApplicationDeposit]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
payer_wallet: str,
uuid: str,
*,
client: AuthenticatedClient,
) -> Response[ApplicationDeposit]:
"""
Args:
payer_wallet (str):
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[ApplicationDeposit]
"""
kwargs = _get_kwargs(
payer_wallet=payer_wallet,
uuid=uuid,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
payer_wallet: str,
uuid: str,
*,
client: AuthenticatedClient,
) -> Optional[ApplicationDeposit]:
"""
Args:
payer_wallet (str):
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:
ApplicationDeposit
"""
return sync_detailed(
payer_wallet=payer_wallet,
uuid=uuid,
client=client,
).parsed
async def asyncio_detailed(
payer_wallet: str,
uuid: str,
*,
client: AuthenticatedClient,
) -> Response[ApplicationDeposit]:
"""
Args:
payer_wallet (str):
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[ApplicationDeposit]
"""
kwargs = _get_kwargs(
payer_wallet=payer_wallet,
uuid=uuid,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
payer_wallet: str,
uuid: str,
*,
client: AuthenticatedClient,
) -> Optional[ApplicationDeposit]:
"""
Args:
payer_wallet (str):
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:
ApplicationDeposit
"""
return (
await asyncio_detailed(
payer_wallet=payer_wallet,
uuid=uuid,
client=client,
)
).parsed

View file

@ -1,227 +0,0 @@
from http import HTTPStatus
from typing import Any, Optional, Union
from uuid import UUID
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.paginated_transaction_list import PaginatedTransactionList
from ...types import UNSET, Response, Unset
def _get_kwargs(
*,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
payee: Union[Unset, UUID] = UNSET,
payer: Union[Unset, UUID] = UNSET,
wallets: list[UUID],
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["limit"] = limit
params["offset"] = offset
json_payee: Union[Unset, str] = UNSET
if not isinstance(payee, Unset):
json_payee = str(payee)
params["payee"] = json_payee
json_payer: Union[Unset, str] = UNSET
if not isinstance(payer, Unset):
json_payer = str(payer)
params["payer"] = json_payer
json_wallets = []
for wallets_item_data in wallets:
wallets_item = str(wallets_item_data)
json_wallets.append(wallets_item)
params["wallets"] = json_wallets
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
_kwargs: dict[str, Any] = {
"method": "get",
"url": "/wallet/api/application/transactions/",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[PaginatedTransactionList]:
if response.status_code == 200:
response_200 = PaginatedTransactionList.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[PaginatedTransactionList]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
payee: Union[Unset, UUID] = UNSET,
payer: Union[Unset, UUID] = UNSET,
wallets: list[UUID],
) -> Response[PaginatedTransactionList]:
"""
Args:
limit (Union[Unset, int]):
offset (Union[Unset, int]):
payee (Union[Unset, UUID]):
payer (Union[Unset, UUID]):
wallets (list[UUID]):
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[PaginatedTransactionList]
"""
kwargs = _get_kwargs(
limit=limit,
offset=offset,
payee=payee,
payer=payer,
wallets=wallets,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
payee: Union[Unset, UUID] = UNSET,
payer: Union[Unset, UUID] = UNSET,
wallets: list[UUID],
) -> Optional[PaginatedTransactionList]:
"""
Args:
limit (Union[Unset, int]):
offset (Union[Unset, int]):
payee (Union[Unset, UUID]):
payer (Union[Unset, UUID]):
wallets (list[UUID]):
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:
PaginatedTransactionList
"""
return sync_detailed(
client=client,
limit=limit,
offset=offset,
payee=payee,
payer=payer,
wallets=wallets,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
payee: Union[Unset, UUID] = UNSET,
payer: Union[Unset, UUID] = UNSET,
wallets: list[UUID],
) -> Response[PaginatedTransactionList]:
"""
Args:
limit (Union[Unset, int]):
offset (Union[Unset, int]):
payee (Union[Unset, UUID]):
payer (Union[Unset, UUID]):
wallets (list[UUID]):
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[PaginatedTransactionList]
"""
kwargs = _get_kwargs(
limit=limit,
offset=offset,
payee=payee,
payer=payer,
wallets=wallets,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
payee: Union[Unset, UUID] = UNSET,
payer: Union[Unset, UUID] = UNSET,
wallets: list[UUID],
) -> Optional[PaginatedTransactionList]:
"""
Args:
limit (Union[Unset, int]):
offset (Union[Unset, int]):
payee (Union[Unset, UUID]):
payer (Union[Unset, UUID]):
wallets (list[UUID]):
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:
PaginatedTransactionList
"""
return (
await asyncio_detailed(
client=client,
limit=limit,
offset=offset,
payee=payee,
payer=payer,
wallets=wallets,
)
).parsed

View file

@ -1,144 +0,0 @@
from http import HTTPStatus
from typing import Any, Optional, Union
from uuid import UUID
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.transaction import Transaction
from ...types import Response
def _get_kwargs(
uuid: UUID,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": f"/wallet/api/application/transactions/{uuid}/",
}
return _kwargs
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Transaction]:
if response.status_code == 200:
response_200 = Transaction.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[Transaction]:
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: UUID,
*,
client: AuthenticatedClient,
) -> Response[Transaction]:
"""
Args:
uuid (UUID):
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[Transaction]
"""
kwargs = _get_kwargs(
uuid=uuid,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
uuid: UUID,
*,
client: AuthenticatedClient,
) -> Optional[Transaction]:
"""
Args:
uuid (UUID):
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:
Transaction
"""
return sync_detailed(
uuid=uuid,
client=client,
).parsed
async def asyncio_detailed(
uuid: UUID,
*,
client: AuthenticatedClient,
) -> Response[Transaction]:
"""
Args:
uuid (UUID):
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[Transaction]
"""
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: UUID,
*,
client: AuthenticatedClient,
) -> Optional[Transaction]:
"""
Args:
uuid (UUID):
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:
Transaction
"""
return (
await asyncio_detailed(
uuid=uuid,
client=client,
)
).parsed

View file

@ -1,208 +0,0 @@
from http import HTTPStatus
from typing import Any, Optional, Union
from uuid import UUID
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.paginated_account_list import PaginatedAccountList
from ...types import UNSET, Response, Unset
def _get_kwargs(
owner: str,
*,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
wallet: list[UUID],
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["limit"] = limit
params["offset"] = offset
json_wallet = []
for wallet_item_data in wallet:
wallet_item = str(wallet_item_data)
json_wallet.append(wallet_item)
params["wallet"] = json_wallet
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
_kwargs: dict[str, Any] = {
"method": "get",
"url": f"/wallet/api/application/user/wallets/{owner}/",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[PaginatedAccountList]:
if response.status_code == 200:
response_200 = PaginatedAccountList.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[PaginatedAccountList]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
owner: str,
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
wallet: list[UUID],
) -> Response[PaginatedAccountList]:
"""API for getting specified user wallet.
Args:
owner (str):
limit (Union[Unset, int]):
offset (Union[Unset, int]):
wallet (list[UUID]):
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[PaginatedAccountList]
"""
kwargs = _get_kwargs(
owner=owner,
limit=limit,
offset=offset,
wallet=wallet,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
owner: str,
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
wallet: list[UUID],
) -> Optional[PaginatedAccountList]:
"""API for getting specified user wallet.
Args:
owner (str):
limit (Union[Unset, int]):
offset (Union[Unset, int]):
wallet (list[UUID]):
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:
PaginatedAccountList
"""
return sync_detailed(
owner=owner,
client=client,
limit=limit,
offset=offset,
wallet=wallet,
).parsed
async def asyncio_detailed(
owner: str,
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
wallet: list[UUID],
) -> Response[PaginatedAccountList]:
"""API for getting specified user wallet.
Args:
owner (str):
limit (Union[Unset, int]):
offset (Union[Unset, int]):
wallet (list[UUID]):
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[PaginatedAccountList]
"""
kwargs = _get_kwargs(
owner=owner,
limit=limit,
offset=offset,
wallet=wallet,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
owner: str,
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
wallet: list[UUID],
) -> Optional[PaginatedAccountList]:
"""API for getting specified user wallet.
Args:
owner (str):
limit (Union[Unset, int]):
offset (Union[Unset, int]):
wallet (list[UUID]):
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:
PaginatedAccountList
"""
return (
await asyncio_detailed(
owner=owner,
client=client,
limit=limit,
offset=offset,
wallet=wallet,
)
).parsed

View file

@ -1,174 +0,0 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.paginated_account_list import PaginatedAccountList
from ...types import UNSET, Response, Unset
def _get_kwargs(
*,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["limit"] = limit
params["offset"] = offset
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
_kwargs: dict[str, Any] = {
"method": "get",
"url": "/wallet/api/application/wallets/",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[PaginatedAccountList]:
if response.status_code == 200:
response_200 = PaginatedAccountList.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[PaginatedAccountList]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> Response[PaginatedAccountList]:
"""API for getting specified user or application balance.
Args:
limit (Union[Unset, int]):
offset (Union[Unset, int]):
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[PaginatedAccountList]
"""
kwargs = _get_kwargs(
limit=limit,
offset=offset,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> Optional[PaginatedAccountList]:
"""API for getting specified user or application balance.
Args:
limit (Union[Unset, int]):
offset (Union[Unset, int]):
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:
PaginatedAccountList
"""
return sync_detailed(
client=client,
limit=limit,
offset=offset,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> Response[PaginatedAccountList]:
"""API for getting specified user or application balance.
Args:
limit (Union[Unset, int]):
offset (Union[Unset, int]):
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[PaginatedAccountList]
"""
kwargs = _get_kwargs(
limit=limit,
offset=offset,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> Optional[PaginatedAccountList]:
"""API for getting specified user or application balance.
Args:
limit (Union[Unset, int]):
offset (Union[Unset, int]):
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:
PaginatedAccountList
"""
return (
await asyncio_detailed(
client=client,
limit=limit,
offset=offset,
)
).parsed

View file

@ -1,168 +0,0 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.application_withdraw import ApplicationWithdraw
from ...types import Response
def _get_kwargs(
payee_wallet: str,
*,
body: ApplicationWithdraw,
) -> dict[str, Any]:
headers: dict[str, Any] = {}
_kwargs: dict[str, Any] = {
"method": "post",
"url": f"/wallet/api/application/{payee_wallet}/withdraw/",
}
_kwargs["json"] = body.to_dict()
headers["Content-Type"] = "application/json"
_kwargs["headers"] = headers
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[ApplicationWithdraw]:
if response.status_code == 201:
response_201 = ApplicationWithdraw.from_dict(response.json())
return response_201
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[ApplicationWithdraw]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
payee_wallet: str,
*,
client: AuthenticatedClient,
body: ApplicationWithdraw,
) -> Response[ApplicationWithdraw]:
"""
Args:
payee_wallet (str):
body (ApplicationWithdraw):
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[ApplicationWithdraw]
"""
kwargs = _get_kwargs(
payee_wallet=payee_wallet,
body=body,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
payee_wallet: str,
*,
client: AuthenticatedClient,
body: ApplicationWithdraw,
) -> Optional[ApplicationWithdraw]:
"""
Args:
payee_wallet (str):
body (ApplicationWithdraw):
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:
ApplicationWithdraw
"""
return sync_detailed(
payee_wallet=payee_wallet,
client=client,
body=body,
).parsed
async def asyncio_detailed(
payee_wallet: str,
*,
client: AuthenticatedClient,
body: ApplicationWithdraw,
) -> Response[ApplicationWithdraw]:
"""
Args:
payee_wallet (str):
body (ApplicationWithdraw):
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[ApplicationWithdraw]
"""
kwargs = _get_kwargs(
payee_wallet=payee_wallet,
body=body,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
payee_wallet: str,
*,
client: AuthenticatedClient,
body: ApplicationWithdraw,
) -> Optional[ApplicationWithdraw]:
"""
Args:
payee_wallet (str):
body (ApplicationWithdraw):
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:
ApplicationWithdraw
"""
return (
await asyncio_detailed(
payee_wallet=payee_wallet,
client=client,
body=body,
)
).parsed

View file

@ -1,160 +0,0 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.application_withdraw import ApplicationWithdraw
from ...types import Response
def _get_kwargs(
payee_wallet: str,
uuid: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": f"/wallet/api/application/{payee_wallet}/withdraw/{uuid}/rollback",
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[ApplicationWithdraw]:
if response.status_code == 200:
response_200 = ApplicationWithdraw.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[ApplicationWithdraw]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
payee_wallet: str,
uuid: str,
*,
client: AuthenticatedClient,
) -> Response[ApplicationWithdraw]:
"""
Args:
payee_wallet (str):
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[ApplicationWithdraw]
"""
kwargs = _get_kwargs(
payee_wallet=payee_wallet,
uuid=uuid,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
payee_wallet: str,
uuid: str,
*,
client: AuthenticatedClient,
) -> Optional[ApplicationWithdraw]:
"""
Args:
payee_wallet (str):
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:
ApplicationWithdraw
"""
return sync_detailed(
payee_wallet=payee_wallet,
uuid=uuid,
client=client,
).parsed
async def asyncio_detailed(
payee_wallet: str,
uuid: str,
*,
client: AuthenticatedClient,
) -> Response[ApplicationWithdraw]:
"""
Args:
payee_wallet (str):
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[ApplicationWithdraw]
"""
kwargs = _get_kwargs(
payee_wallet=payee_wallet,
uuid=uuid,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
payee_wallet: str,
uuid: str,
*,
client: AuthenticatedClient,
) -> Optional[ApplicationWithdraw]:
"""
Args:
payee_wallet (str):
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:
ApplicationWithdraw
"""
return (
await asyncio_detailed(
payee_wallet=payee_wallet,
uuid=uuid,
client=client,
)
).parsed

View file

@ -1,160 +0,0 @@
from http import HTTPStatus
from typing import Any, Optional, Union
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.application_withdraw import ApplicationWithdraw
from ...types import Response
def _get_kwargs(
payee_wallet: str,
uuid: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": f"/wallet/api/application/{payee_wallet}/withdraw/{uuid}/verify",
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[ApplicationWithdraw]:
if response.status_code == 200:
response_200 = ApplicationWithdraw.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[ApplicationWithdraw]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
payee_wallet: str,
uuid: str,
*,
client: AuthenticatedClient,
) -> Response[ApplicationWithdraw]:
"""
Args:
payee_wallet (str):
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[ApplicationWithdraw]
"""
kwargs = _get_kwargs(
payee_wallet=payee_wallet,
uuid=uuid,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
payee_wallet: str,
uuid: str,
*,
client: AuthenticatedClient,
) -> Optional[ApplicationWithdraw]:
"""
Args:
payee_wallet (str):
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:
ApplicationWithdraw
"""
return sync_detailed(
payee_wallet=payee_wallet,
uuid=uuid,
client=client,
).parsed
async def asyncio_detailed(
payee_wallet: str,
uuid: str,
*,
client: AuthenticatedClient,
) -> Response[ApplicationWithdraw]:
"""
Args:
payee_wallet (str):
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[ApplicationWithdraw]
"""
kwargs = _get_kwargs(
payee_wallet=payee_wallet,
uuid=uuid,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
payee_wallet: str,
uuid: str,
*,
client: AuthenticatedClient,
) -> Optional[ApplicationWithdraw]:
"""
Args:
payee_wallet (str):
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:
ApplicationWithdraw
"""
return (
await asyncio_detailed(
payee_wallet=payee_wallet,
uuid=uuid,
client=client,
)
).parsed

View file

@ -1,227 +0,0 @@
from http import HTTPStatus
from typing import Any, Optional, Union
from uuid import UUID
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.paginated_transaction_grouped_list import PaginatedTransactionGroupedList
from ...types import UNSET, Response, Unset
def _get_kwargs(
*,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
payee: Union[Unset, UUID] = UNSET,
payer: Union[Unset, UUID] = UNSET,
wallets: list[UUID],
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["limit"] = limit
params["offset"] = offset
json_payee: Union[Unset, str] = UNSET
if not isinstance(payee, Unset):
json_payee = str(payee)
params["payee"] = json_payee
json_payer: Union[Unset, str] = UNSET
if not isinstance(payer, Unset):
json_payer = str(payer)
params["payer"] = json_payer
json_wallets = []
for wallets_item_data in wallets:
wallets_item = str(wallets_item_data)
json_wallets.append(wallets_item)
params["wallets"] = json_wallets
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
_kwargs: dict[str, Any] = {
"method": "get",
"url": "/wallet/api/transactions/grouped/",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[PaginatedTransactionGroupedList]:
if response.status_code == 200:
response_200 = PaginatedTransactionGroupedList.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[PaginatedTransactionGroupedList]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
payee: Union[Unset, UUID] = UNSET,
payer: Union[Unset, UUID] = UNSET,
wallets: list[UUID],
) -> Response[PaginatedTransactionGroupedList]:
"""
Args:
limit (Union[Unset, int]):
offset (Union[Unset, int]):
payee (Union[Unset, UUID]):
payer (Union[Unset, UUID]):
wallets (list[UUID]):
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[PaginatedTransactionGroupedList]
"""
kwargs = _get_kwargs(
limit=limit,
offset=offset,
payee=payee,
payer=payer,
wallets=wallets,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
payee: Union[Unset, UUID] = UNSET,
payer: Union[Unset, UUID] = UNSET,
wallets: list[UUID],
) -> Optional[PaginatedTransactionGroupedList]:
"""
Args:
limit (Union[Unset, int]):
offset (Union[Unset, int]):
payee (Union[Unset, UUID]):
payer (Union[Unset, UUID]):
wallets (list[UUID]):
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:
PaginatedTransactionGroupedList
"""
return sync_detailed(
client=client,
limit=limit,
offset=offset,
payee=payee,
payer=payer,
wallets=wallets,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
payee: Union[Unset, UUID] = UNSET,
payer: Union[Unset, UUID] = UNSET,
wallets: list[UUID],
) -> Response[PaginatedTransactionGroupedList]:
"""
Args:
limit (Union[Unset, int]):
offset (Union[Unset, int]):
payee (Union[Unset, UUID]):
payer (Union[Unset, UUID]):
wallets (list[UUID]):
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[PaginatedTransactionGroupedList]
"""
kwargs = _get_kwargs(
limit=limit,
offset=offset,
payee=payee,
payer=payer,
wallets=wallets,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
payee: Union[Unset, UUID] = UNSET,
payer: Union[Unset, UUID] = UNSET,
wallets: list[UUID],
) -> Optional[PaginatedTransactionGroupedList]:
"""
Args:
limit (Union[Unset, int]):
offset (Union[Unset, int]):
payee (Union[Unset, UUID]):
payer (Union[Unset, UUID]):
wallets (list[UUID]):
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:
PaginatedTransactionGroupedList
"""
return (
await asyncio_detailed(
client=client,
limit=limit,
offset=offset,
payee=payee,
payer=payer,
wallets=wallets,
)
).parsed

View file

@ -1,227 +0,0 @@
from http import HTTPStatus
from typing import Any, Optional, Union
from uuid import UUID
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.paginated_transaction_list import PaginatedTransactionList
from ...types import UNSET, Response, Unset
def _get_kwargs(
*,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
payee: Union[Unset, UUID] = UNSET,
payer: Union[Unset, UUID] = UNSET,
wallets: list[UUID],
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["limit"] = limit
params["offset"] = offset
json_payee: Union[Unset, str] = UNSET
if not isinstance(payee, Unset):
json_payee = str(payee)
params["payee"] = json_payee
json_payer: Union[Unset, str] = UNSET
if not isinstance(payer, Unset):
json_payer = str(payer)
params["payer"] = json_payer
json_wallets = []
for wallets_item_data in wallets:
wallets_item = str(wallets_item_data)
json_wallets.append(wallets_item)
params["wallets"] = json_wallets
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
_kwargs: dict[str, Any] = {
"method": "get",
"url": "/wallet/api/transactions/",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[PaginatedTransactionList]:
if response.status_code == 200:
response_200 = PaginatedTransactionList.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[PaginatedTransactionList]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
payee: Union[Unset, UUID] = UNSET,
payer: Union[Unset, UUID] = UNSET,
wallets: list[UUID],
) -> Response[PaginatedTransactionList]:
"""
Args:
limit (Union[Unset, int]):
offset (Union[Unset, int]):
payee (Union[Unset, UUID]):
payer (Union[Unset, UUID]):
wallets (list[UUID]):
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[PaginatedTransactionList]
"""
kwargs = _get_kwargs(
limit=limit,
offset=offset,
payee=payee,
payer=payer,
wallets=wallets,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
payee: Union[Unset, UUID] = UNSET,
payer: Union[Unset, UUID] = UNSET,
wallets: list[UUID],
) -> Optional[PaginatedTransactionList]:
"""
Args:
limit (Union[Unset, int]):
offset (Union[Unset, int]):
payee (Union[Unset, UUID]):
payer (Union[Unset, UUID]):
wallets (list[UUID]):
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:
PaginatedTransactionList
"""
return sync_detailed(
client=client,
limit=limit,
offset=offset,
payee=payee,
payer=payer,
wallets=wallets,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
payee: Union[Unset, UUID] = UNSET,
payer: Union[Unset, UUID] = UNSET,
wallets: list[UUID],
) -> Response[PaginatedTransactionList]:
"""
Args:
limit (Union[Unset, int]):
offset (Union[Unset, int]):
payee (Union[Unset, UUID]):
payer (Union[Unset, UUID]):
wallets (list[UUID]):
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[PaginatedTransactionList]
"""
kwargs = _get_kwargs(
limit=limit,
offset=offset,
payee=payee,
payer=payer,
wallets=wallets,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
payee: Union[Unset, UUID] = UNSET,
payer: Union[Unset, UUID] = UNSET,
wallets: list[UUID],
) -> Optional[PaginatedTransactionList]:
"""
Args:
limit (Union[Unset, int]):
offset (Union[Unset, int]):
payee (Union[Unset, UUID]):
payer (Union[Unset, UUID]):
wallets (list[UUID]):
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:
PaginatedTransactionList
"""
return (
await asyncio_detailed(
client=client,
limit=limit,
offset=offset,
payee=payee,
payer=payer,
wallets=wallets,
)
).parsed

View file

@ -1,195 +0,0 @@
from http import HTTPStatus
from typing import Any, Optional, Union
from uuid import UUID
import httpx
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.paginated_account_list import PaginatedAccountList
from ...types import UNSET, Response, Unset
def _get_kwargs(
*,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
wallet: list[UUID],
) -> dict[str, Any]:
params: dict[str, Any] = {}
params["limit"] = limit
params["offset"] = offset
json_wallet = []
for wallet_item_data in wallet:
wallet_item = str(wallet_item_data)
json_wallet.append(wallet_item)
params["wallet"] = json_wallet
params = {k: v for k, v in params.items() if v is not UNSET and v is not None}
_kwargs: dict[str, Any] = {
"method": "get",
"url": "/wallet/api/wallets/",
"params": params,
}
return _kwargs
def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[PaginatedAccountList]:
if response.status_code == 200:
response_200 = PaginatedAccountList.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[PaginatedAccountList]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)
def sync_detailed(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
wallet: list[UUID],
) -> Response[PaginatedAccountList]:
"""API for getting authenticated user balance.
Args:
limit (Union[Unset, int]):
offset (Union[Unset, int]):
wallet (list[UUID]):
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[PaginatedAccountList]
"""
kwargs = _get_kwargs(
limit=limit,
offset=offset,
wallet=wallet,
)
response = client.get_httpx_client().request(
**kwargs,
)
return _build_response(client=client, response=response)
def sync(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
wallet: list[UUID],
) -> Optional[PaginatedAccountList]:
"""API for getting authenticated user balance.
Args:
limit (Union[Unset, int]):
offset (Union[Unset, int]):
wallet (list[UUID]):
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:
PaginatedAccountList
"""
return sync_detailed(
client=client,
limit=limit,
offset=offset,
wallet=wallet,
).parsed
async def asyncio_detailed(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
wallet: list[UUID],
) -> Response[PaginatedAccountList]:
"""API for getting authenticated user balance.
Args:
limit (Union[Unset, int]):
offset (Union[Unset, int]):
wallet (list[UUID]):
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[PaginatedAccountList]
"""
kwargs = _get_kwargs(
limit=limit,
offset=offset,
wallet=wallet,
)
response = await client.get_async_httpx_client().request(**kwargs)
return _build_response(client=client, response=response)
async def asyncio(
*,
client: AuthenticatedClient,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
wallet: list[UUID],
) -> Optional[PaginatedAccountList]:
"""API for getting authenticated user balance.
Args:
limit (Union[Unset, int]):
offset (Union[Unset, int]):
wallet (list[UUID]):
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:
PaginatedAccountList
"""
return (
await asyncio_detailed(
client=client,
limit=limit,
offset=offset,
wallet=wallet,
)
).parsed

View file

@ -1,268 +0,0 @@
import ssl
from typing import Any, Optional, Union
import httpx
from attrs import define, evolve, field
@define
class Client:
"""A class for keeping track of data related to the API
The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
``base_url``: The base URL for the API, all requests are made to a relative path to this URL
``cookies``: A dictionary of cookies to be sent with every request
``headers``: A dictionary of headers to be sent with every request
``timeout``: The maximum amount of a time a request can take. API functions will raise
httpx.TimeoutException if this is exceeded.
``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
but can be set to False for testing purposes.
``follow_redirects``: Whether or not to follow redirects. Default value is False.
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
Attributes:
raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
argument to the constructor.
"""
raise_on_unexpected_status: bool = field(default=False, kw_only=True)
_base_url: str = field(alias="base_url")
_cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
_headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
_timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout")
_verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl")
_follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
_client: Optional[httpx.Client] = field(default=None, init=False)
_async_client: Optional[httpx.AsyncClient] = field(default=None, init=False)
def with_headers(self, headers: dict[str, str]) -> "Client":
"""Get a new client matching this one with additional headers"""
if self._client is not None:
self._client.headers.update(headers)
if self._async_client is not None:
self._async_client.headers.update(headers)
return evolve(self, headers={**self._headers, **headers})
def with_cookies(self, cookies: dict[str, str]) -> "Client":
"""Get a new client matching this one with additional cookies"""
if self._client is not None:
self._client.cookies.update(cookies)
if self._async_client is not None:
self._async_client.cookies.update(cookies)
return evolve(self, cookies={**self._cookies, **cookies})
def with_timeout(self, timeout: httpx.Timeout) -> "Client":
"""Get a new client matching this one with a new timeout (in seconds)"""
if self._client is not None:
self._client.timeout = timeout
if self._async_client is not None:
self._async_client.timeout = timeout
return evolve(self, timeout=timeout)
def set_httpx_client(self, client: httpx.Client) -> "Client":
"""Manually set the underlying httpx.Client
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
"""
self._client = client
return self
def get_httpx_client(self) -> httpx.Client:
"""Get the underlying httpx.Client, constructing a new one if not previously set"""
if self._client is None:
self._client = httpx.Client(
base_url=self._base_url,
cookies=self._cookies,
headers=self._headers,
timeout=self._timeout,
verify=self._verify_ssl,
follow_redirects=self._follow_redirects,
**self._httpx_args,
)
return self._client
def __enter__(self) -> "Client":
"""Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
self.get_httpx_client().__enter__()
return self
def __exit__(self, *args: Any, **kwargs: Any) -> None:
"""Exit a context manager for internal httpx.Client (see httpx docs)"""
self.get_httpx_client().__exit__(*args, **kwargs)
def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "Client":
"""Manually the underlying httpx.AsyncClient
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
"""
self._async_client = async_client
return self
def get_async_httpx_client(self) -> httpx.AsyncClient:
"""Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
if self._async_client is None:
self._async_client = httpx.AsyncClient(
base_url=self._base_url,
cookies=self._cookies,
headers=self._headers,
timeout=self._timeout,
verify=self._verify_ssl,
follow_redirects=self._follow_redirects,
**self._httpx_args,
)
return self._async_client
async def __aenter__(self) -> "Client":
"""Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
await self.get_async_httpx_client().__aenter__()
return self
async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
"""Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
await self.get_async_httpx_client().__aexit__(*args, **kwargs)
@define
class AuthenticatedClient:
"""A Client which has been authenticated for use on secured endpoints
The following are accepted as keyword arguments and will be used to construct httpx Clients internally:
``base_url``: The base URL for the API, all requests are made to a relative path to this URL
``cookies``: A dictionary of cookies to be sent with every request
``headers``: A dictionary of headers to be sent with every request
``timeout``: The maximum amount of a time a request can take. API functions will raise
httpx.TimeoutException if this is exceeded.
``verify_ssl``: Whether or not to verify the SSL certificate of the API server. This should be True in production,
but can be set to False for testing purposes.
``follow_redirects``: Whether or not to follow redirects. Default value is False.
``httpx_args``: A dictionary of additional arguments to be passed to the ``httpx.Client`` and ``httpx.AsyncClient`` constructor.
Attributes:
raise_on_unexpected_status: Whether or not to raise an errors.UnexpectedStatus if the API returns a
status code that was not documented in the source OpenAPI document. Can also be provided as a keyword
argument to the constructor.
token: The token to use for authentication
prefix: The prefix to use for the Authorization header
auth_header_name: The name of the Authorization header
"""
raise_on_unexpected_status: bool = field(default=False, kw_only=True)
_base_url: str = field(alias="base_url")
_cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
_headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
_timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout")
_verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl")
_follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
_client: Optional[httpx.Client] = field(default=None, init=False)
_async_client: Optional[httpx.AsyncClient] = field(default=None, init=False)
token: str
prefix: str = "Bearer"
auth_header_name: str = "Authorization"
def with_headers(self, headers: dict[str, str]) -> "AuthenticatedClient":
"""Get a new client matching this one with additional headers"""
if self._client is not None:
self._client.headers.update(headers)
if self._async_client is not None:
self._async_client.headers.update(headers)
return evolve(self, headers={**self._headers, **headers})
def with_cookies(self, cookies: dict[str, str]) -> "AuthenticatedClient":
"""Get a new client matching this one with additional cookies"""
if self._client is not None:
self._client.cookies.update(cookies)
if self._async_client is not None:
self._async_client.cookies.update(cookies)
return evolve(self, cookies={**self._cookies, **cookies})
def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient":
"""Get a new client matching this one with a new timeout (in seconds)"""
if self._client is not None:
self._client.timeout = timeout
if self._async_client is not None:
self._async_client.timeout = timeout
return evolve(self, timeout=timeout)
def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient":
"""Manually set the underlying httpx.Client
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
"""
self._client = client
return self
def get_httpx_client(self) -> httpx.Client:
"""Get the underlying httpx.Client, constructing a new one if not previously set"""
if self._client is None:
self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token
self._client = httpx.Client(
base_url=self._base_url,
cookies=self._cookies,
headers=self._headers,
timeout=self._timeout,
verify=self._verify_ssl,
follow_redirects=self._follow_redirects,
**self._httpx_args,
)
return self._client
def __enter__(self) -> "AuthenticatedClient":
"""Enter a context manager for self.client—you cannot enter twice (see httpx docs)"""
self.get_httpx_client().__enter__()
return self
def __exit__(self, *args: Any, **kwargs: Any) -> None:
"""Exit a context manager for internal httpx.Client (see httpx docs)"""
self.get_httpx_client().__exit__(*args, **kwargs)
def set_async_httpx_client(self, async_client: httpx.AsyncClient) -> "AuthenticatedClient":
"""Manually the underlying httpx.AsyncClient
**NOTE**: This will override any other settings on the client, including cookies, headers, and timeout.
"""
self._async_client = async_client
return self
def get_async_httpx_client(self) -> httpx.AsyncClient:
"""Get the underlying httpx.AsyncClient, constructing a new one if not previously set"""
if self._async_client is None:
self._headers[self.auth_header_name] = f"{self.prefix} {self.token}" if self.prefix else self.token
self._async_client = httpx.AsyncClient(
base_url=self._base_url,
cookies=self._cookies,
headers=self._headers,
timeout=self._timeout,
verify=self._verify_ssl,
follow_redirects=self._follow_redirects,
**self._httpx_args,
)
return self._async_client
async def __aenter__(self) -> "AuthenticatedClient":
"""Enter a context manager for underlying httpx.AsyncClient—you cannot enter twice (see httpx docs)"""
await self.get_async_httpx_client().__aenter__()
return self
async def __aexit__(self, *args: Any, **kwargs: Any) -> None:
"""Exit a context manager for underlying httpx.AsyncClient (see httpx docs)"""
await self.get_async_httpx_client().__aexit__(*args, **kwargs)

View file

@ -1,16 +0,0 @@
"""Contains shared errors types that can be raised from API functions"""
class UnexpectedStatus(Exception):
"""Raised by api functions when the response status an undocumented status and Client.raise_on_unexpected_status is True"""
def __init__(self, status_code: int, content: bytes):
self.status_code = status_code
self.content = content
super().__init__(
f"Unexpected status code: {status_code}\n\nResponse content:\n{content.decode(errors='ignore')}"
)
__all__ = ["UnexpectedStatus"]

View file

@ -1,23 +0,0 @@
"""Contains all the data models used in inputs/outputs"""
from .account import Account
from .application_deposit import ApplicationDeposit
from .application_withdraw import ApplicationWithdraw
from .paginated_account_list import PaginatedAccountList
from .paginated_transaction_grouped_list import PaginatedTransactionGroupedList
from .paginated_transaction_list import PaginatedTransactionList
from .state_enum import StateEnum
from .transaction import Transaction
from .transaction_grouped import TransactionGrouped
__all__ = (
"Account",
"ApplicationDeposit",
"ApplicationWithdraw",
"PaginatedAccountList",
"PaginatedTransactionGroupedList",
"PaginatedTransactionList",
"StateEnum",
"Transaction",
"TransactionGrouped",
)

View file

@ -1,90 +0,0 @@
from collections.abc import Mapping
from typing import Any, TypeVar, Union, cast
from uuid import UUID
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from ..types import UNSET, Unset
T = TypeVar("T", bound="Account")
@_attrs_define
class Account:
"""
Attributes:
balance (Union[Unset, int]):
wallet (Union[None, UUID, Unset]):
"""
balance: Union[Unset, int] = UNSET
wallet: Union[None, UUID, Unset] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
balance = self.balance
wallet: Union[None, Unset, str]
if isinstance(self.wallet, Unset):
wallet = UNSET
elif isinstance(self.wallet, UUID):
wallet = str(self.wallet)
else:
wallet = self.wallet
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update({})
if balance is not UNSET:
field_dict["balance"] = balance
if wallet is not UNSET:
field_dict["wallet"] = wallet
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
balance = d.pop("balance", UNSET)
def _parse_wallet(data: object) -> Union[None, UUID, Unset]:
if data is None:
return data
if isinstance(data, Unset):
return data
try:
if not isinstance(data, str):
raise TypeError()
wallet_type_0 = UUID(data)
return wallet_type_0
except: # noqa: E722
pass
return cast(Union[None, UUID, Unset], data)
wallet = _parse_wallet(d.pop("wallet", UNSET))
account = cls(
balance=balance,
wallet=wallet,
)
account.additional_properties = d
return account
@property
def additional_keys(self) -> list[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]
def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value
def __delitem__(self, key: str) -> None:
del self.additional_properties[key]
def __contains__(self, key: str) -> bool:
return key in self.additional_properties

View file

@ -1,170 +0,0 @@
import datetime
from collections.abc import Mapping
from typing import Any, TypeVar, Union
from uuid import UUID
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from dateutil.parser import isoparse
from ..models.state_enum import StateEnum
from ..types import UNSET, Unset
T = TypeVar("T", bound="ApplicationDeposit")
@_attrs_define
class ApplicationDeposit:
"""
Attributes:
payer (str):
payer_type (str):
payer_wallet (UUID):
payee (UUID):
payee_type (int):
payee_wallet (UUID):
created_at (datetime.datetime):
state (StateEnum): * `1` - created
* `2` - delayed
* `3` - pending
* `4` - incomplete
* `5` - success
* `6` - failed
* `7` - expected_failure
* `8` - ROLLED_BACK
* `9` - CANCELED
amount (int):
updated_at (datetime.datetime):
uuid (Union[Unset, UUID]):
details (Union[Unset, Any]):
"""
payer: str
payer_type: str
payer_wallet: UUID
payee: UUID
payee_type: int
payee_wallet: UUID
created_at: datetime.datetime
state: StateEnum
amount: int
updated_at: datetime.datetime
uuid: Union[Unset, UUID] = UNSET
details: Union[Unset, Any] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
payer = self.payer
payer_type = self.payer_type
payer_wallet = str(self.payer_wallet)
payee = str(self.payee)
payee_type = self.payee_type
payee_wallet = str(self.payee_wallet)
created_at = self.created_at.isoformat()
state = self.state.value
amount = self.amount
updated_at = self.updated_at.isoformat()
uuid: Union[Unset, str] = UNSET
if not isinstance(self.uuid, Unset):
uuid = str(self.uuid)
details = self.details
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"payer": payer,
"payer_type": payer_type,
"payer_wallet": payer_wallet,
"payee": payee,
"payee_type": payee_type,
"payee_wallet": payee_wallet,
"created_at": created_at,
"state": state,
"amount": amount,
"updated_at": updated_at,
}
)
if uuid is not UNSET:
field_dict["uuid"] = uuid
if details is not UNSET:
field_dict["details"] = details
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
payer = d.pop("payer")
payer_type = d.pop("payer_type")
payer_wallet = UUID(d.pop("payer_wallet"))
payee = UUID(d.pop("payee"))
payee_type = d.pop("payee_type")
payee_wallet = UUID(d.pop("payee_wallet"))
created_at = isoparse(d.pop("created_at"))
state = StateEnum(d.pop("state"))
amount = d.pop("amount")
updated_at = isoparse(d.pop("updated_at"))
_uuid = d.pop("uuid", UNSET)
uuid: Union[Unset, UUID]
if isinstance(_uuid, Unset):
uuid = UNSET
else:
uuid = UUID(_uuid)
details = d.pop("details", UNSET)
application_deposit = cls(
payer=payer,
payer_type=payer_type,
payer_wallet=payer_wallet,
payee=payee,
payee_type=payee_type,
payee_wallet=payee_wallet,
created_at=created_at,
state=state,
amount=amount,
updated_at=updated_at,
uuid=uuid,
details=details,
)
application_deposit.additional_properties = d
return application_deposit
@property
def additional_keys(self) -> list[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]
def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value
def __delitem__(self, key: str) -> None:
del self.additional_properties[key]
def __contains__(self, key: str) -> bool:
return key in self.additional_properties

View file

@ -1,170 +0,0 @@
import datetime
from collections.abc import Mapping
from typing import Any, TypeVar, Union
from uuid import UUID
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from dateutil.parser import isoparse
from ..models.state_enum import StateEnum
from ..types import UNSET, Unset
T = TypeVar("T", bound="ApplicationWithdraw")
@_attrs_define
class ApplicationWithdraw:
"""
Attributes:
payer (UUID):
payer_type (int):
payer_wallet (UUID):
payee (str):
payee_type (str):
payee_wallet (UUID):
created_at (datetime.datetime):
state (StateEnum): * `1` - created
* `2` - delayed
* `3` - pending
* `4` - incomplete
* `5` - success
* `6` - failed
* `7` - expected_failure
* `8` - ROLLED_BACK
* `9` - CANCELED
amount (int):
updated_at (datetime.datetime):
uuid (Union[Unset, UUID]):
details (Union[Unset, Any]):
"""
payer: UUID
payer_type: int
payer_wallet: UUID
payee: str
payee_type: str
payee_wallet: UUID
created_at: datetime.datetime
state: StateEnum
amount: int
updated_at: datetime.datetime
uuid: Union[Unset, UUID] = UNSET
details: Union[Unset, Any] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
payer = str(self.payer)
payer_type = self.payer_type
payer_wallet = str(self.payer_wallet)
payee = self.payee
payee_type = self.payee_type
payee_wallet = str(self.payee_wallet)
created_at = self.created_at.isoformat()
state = self.state.value
amount = self.amount
updated_at = self.updated_at.isoformat()
uuid: Union[Unset, str] = UNSET
if not isinstance(self.uuid, Unset):
uuid = str(self.uuid)
details = self.details
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"payer": payer,
"payer_type": payer_type,
"payer_wallet": payer_wallet,
"payee": payee,
"payee_type": payee_type,
"payee_wallet": payee_wallet,
"created_at": created_at,
"state": state,
"amount": amount,
"updated_at": updated_at,
}
)
if uuid is not UNSET:
field_dict["uuid"] = uuid
if details is not UNSET:
field_dict["details"] = details
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
payer = UUID(d.pop("payer"))
payer_type = d.pop("payer_type")
payer_wallet = UUID(d.pop("payer_wallet"))
payee = d.pop("payee")
payee_type = d.pop("payee_type")
payee_wallet = UUID(d.pop("payee_wallet"))
created_at = isoparse(d.pop("created_at"))
state = StateEnum(d.pop("state"))
amount = d.pop("amount")
updated_at = isoparse(d.pop("updated_at"))
_uuid = d.pop("uuid", UNSET)
uuid: Union[Unset, UUID]
if isinstance(_uuid, Unset):
uuid = UNSET
else:
uuid = UUID(_uuid)
details = d.pop("details", UNSET)
application_withdraw = cls(
payer=payer,
payer_type=payer_type,
payer_wallet=payer_wallet,
payee=payee,
payee_type=payee_type,
payee_wallet=payee_wallet,
created_at=created_at,
state=state,
amount=amount,
updated_at=updated_at,
uuid=uuid,
details=details,
)
application_withdraw.additional_properties = d
return application_withdraw
@property
def additional_keys(self) -> list[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]
def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value
def __delitem__(self, key: str) -> None:
del self.additional_properties[key]
def __contains__(self, key: str) -> bool:
return key in self.additional_properties

View file

@ -1,123 +0,0 @@
from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from ..types import UNSET, Unset
if TYPE_CHECKING:
from ..models.account import Account
T = TypeVar("T", bound="PaginatedAccountList")
@_attrs_define
class PaginatedAccountList:
"""
Attributes:
count (int): Example: 123.
results (list['Account']):
next_ (Union[None, Unset, str]): Example: http://api.example.org/accounts/?offset=400&limit=100.
previous (Union[None, Unset, str]): Example: http://api.example.org/accounts/?offset=200&limit=100.
"""
count: int
results: list["Account"]
next_: Union[None, Unset, str] = UNSET
previous: Union[None, Unset, str] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
count = self.count
results = []
for results_item_data in self.results:
results_item = results_item_data.to_dict()
results.append(results_item)
next_: Union[None, Unset, str]
if isinstance(self.next_, Unset):
next_ = UNSET
else:
next_ = self.next_
previous: Union[None, Unset, str]
if isinstance(self.previous, Unset):
previous = UNSET
else:
previous = self.previous
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"count": count,
"results": results,
}
)
if next_ is not UNSET:
field_dict["next"] = next_
if previous is not UNSET:
field_dict["previous"] = previous
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
from ..models.account import Account
d = dict(src_dict)
count = d.pop("count")
results = []
_results = d.pop("results")
for results_item_data in _results:
results_item = Account.from_dict(results_item_data)
results.append(results_item)
def _parse_next_(data: object) -> Union[None, Unset, str]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, str], data)
next_ = _parse_next_(d.pop("next", UNSET))
def _parse_previous(data: object) -> Union[None, Unset, str]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, str], data)
previous = _parse_previous(d.pop("previous", UNSET))
paginated_account_list = cls(
count=count,
results=results,
next_=next_,
previous=previous,
)
paginated_account_list.additional_properties = d
return paginated_account_list
@property
def additional_keys(self) -> list[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]
def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value
def __delitem__(self, key: str) -> None:
del self.additional_properties[key]
def __contains__(self, key: str) -> bool:
return key in self.additional_properties

View file

@ -1,123 +0,0 @@
from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from ..types import UNSET, Unset
if TYPE_CHECKING:
from ..models.transaction_grouped import TransactionGrouped
T = TypeVar("T", bound="PaginatedTransactionGroupedList")
@_attrs_define
class PaginatedTransactionGroupedList:
"""
Attributes:
count (int): Example: 123.
results (list['TransactionGrouped']):
next_ (Union[None, Unset, str]): Example: http://api.example.org/accounts/?offset=400&limit=100.
previous (Union[None, Unset, str]): Example: http://api.example.org/accounts/?offset=200&limit=100.
"""
count: int
results: list["TransactionGrouped"]
next_: Union[None, Unset, str] = UNSET
previous: Union[None, Unset, str] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
count = self.count
results = []
for results_item_data in self.results:
results_item = results_item_data.to_dict()
results.append(results_item)
next_: Union[None, Unset, str]
if isinstance(self.next_, Unset):
next_ = UNSET
else:
next_ = self.next_
previous: Union[None, Unset, str]
if isinstance(self.previous, Unset):
previous = UNSET
else:
previous = self.previous
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"count": count,
"results": results,
}
)
if next_ is not UNSET:
field_dict["next"] = next_
if previous is not UNSET:
field_dict["previous"] = previous
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
from ..models.transaction_grouped import TransactionGrouped
d = dict(src_dict)
count = d.pop("count")
results = []
_results = d.pop("results")
for results_item_data in _results:
results_item = TransactionGrouped.from_dict(results_item_data)
results.append(results_item)
def _parse_next_(data: object) -> Union[None, Unset, str]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, str], data)
next_ = _parse_next_(d.pop("next", UNSET))
def _parse_previous(data: object) -> Union[None, Unset, str]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, str], data)
previous = _parse_previous(d.pop("previous", UNSET))
paginated_transaction_grouped_list = cls(
count=count,
results=results,
next_=next_,
previous=previous,
)
paginated_transaction_grouped_list.additional_properties = d
return paginated_transaction_grouped_list
@property
def additional_keys(self) -> list[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]
def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value
def __delitem__(self, key: str) -> None:
del self.additional_properties[key]
def __contains__(self, key: str) -> bool:
return key in self.additional_properties

View file

@ -1,123 +0,0 @@
from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from ..types import UNSET, Unset
if TYPE_CHECKING:
from ..models.transaction import Transaction
T = TypeVar("T", bound="PaginatedTransactionList")
@_attrs_define
class PaginatedTransactionList:
"""
Attributes:
count (int): Example: 123.
results (list['Transaction']):
next_ (Union[None, Unset, str]): Example: http://api.example.org/accounts/?offset=400&limit=100.
previous (Union[None, Unset, str]): Example: http://api.example.org/accounts/?offset=200&limit=100.
"""
count: int
results: list["Transaction"]
next_: Union[None, Unset, str] = UNSET
previous: Union[None, Unset, str] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
count = self.count
results = []
for results_item_data in self.results:
results_item = results_item_data.to_dict()
results.append(results_item)
next_: Union[None, Unset, str]
if isinstance(self.next_, Unset):
next_ = UNSET
else:
next_ = self.next_
previous: Union[None, Unset, str]
if isinstance(self.previous, Unset):
previous = UNSET
else:
previous = self.previous
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"count": count,
"results": results,
}
)
if next_ is not UNSET:
field_dict["next"] = next_
if previous is not UNSET:
field_dict["previous"] = previous
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
from ..models.transaction import Transaction
d = dict(src_dict)
count = d.pop("count")
results = []
_results = d.pop("results")
for results_item_data in _results:
results_item = Transaction.from_dict(results_item_data)
results.append(results_item)
def _parse_next_(data: object) -> Union[None, Unset, str]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, str], data)
next_ = _parse_next_(d.pop("next", UNSET))
def _parse_previous(data: object) -> Union[None, Unset, str]:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(Union[None, Unset, str], data)
previous = _parse_previous(d.pop("previous", UNSET))
paginated_transaction_list = cls(
count=count,
results=results,
next_=next_,
previous=previous,
)
paginated_transaction_list.additional_properties = d
return paginated_transaction_list
@property
def additional_keys(self) -> list[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]
def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value
def __delitem__(self, key: str) -> None:
del self.additional_properties[key]
def __contains__(self, key: str) -> bool:
return key in self.additional_properties

View file

@ -1,16 +0,0 @@
from enum import IntEnum
class StateEnum(IntEnum):
VALUE_1 = 1
VALUE_2 = 2
VALUE_3 = 3
VALUE_4 = 4
VALUE_5 = 5
VALUE_6 = 6
VALUE_7 = 7
VALUE_8 = 8
VALUE_9 = 9
def __str__(self) -> str:
return str(self.value)

View file

@ -1,178 +0,0 @@
import datetime
from collections.abc import Mapping
from typing import Any, TypeVar, Union
from uuid import UUID
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from dateutil.parser import isoparse
from ..models.state_enum import StateEnum
from ..types import UNSET, Unset
T = TypeVar("T", bound="Transaction")
@_attrs_define
class Transaction:
"""
Attributes:
uuid (UUID):
payer (str):
payer_type (str):
payer_wallet (str):
payee (UUID):
payee_type (int):
payee_wallet (str):
created_at (datetime.datetime):
state (StateEnum): * `1` - created
* `2` - delayed
* `3` - pending
* `4` - incomplete
* `5` - success
* `6` - failed
* `7` - expected_failure
* `8` - ROLLED_BACK
* `9` - CANCELED
amount (int):
updated_at (datetime.datetime):
details (Any):
role (int):
delay (Union[Unset, int]):
"""
uuid: UUID
payer: str
payer_type: str
payer_wallet: str
payee: UUID
payee_type: int
payee_wallet: str
created_at: datetime.datetime
state: StateEnum
amount: int
updated_at: datetime.datetime
details: Any
role: int
delay: Union[Unset, int] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
uuid = str(self.uuid)
payer = self.payer
payer_type = self.payer_type
payer_wallet = self.payer_wallet
payee = str(self.payee)
payee_type = self.payee_type
payee_wallet = self.payee_wallet
created_at = self.created_at.isoformat()
state = self.state.value
amount = self.amount
updated_at = self.updated_at.isoformat()
details = self.details
role = self.role
delay = self.delay
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"uuid": uuid,
"payer": payer,
"payer_type": payer_type,
"payer_wallet": payer_wallet,
"payee": payee,
"payee_type": payee_type,
"payee_wallet": payee_wallet,
"created_at": created_at,
"state": state,
"amount": amount,
"updated_at": updated_at,
"details": details,
"role": role,
}
)
if delay is not UNSET:
field_dict["delay"] = delay
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
uuid = UUID(d.pop("uuid"))
payer = d.pop("payer")
payer_type = d.pop("payer_type")
payer_wallet = d.pop("payer_wallet")
payee = UUID(d.pop("payee"))
payee_type = d.pop("payee_type")
payee_wallet = d.pop("payee_wallet")
created_at = isoparse(d.pop("created_at"))
state = StateEnum(d.pop("state"))
amount = d.pop("amount")
updated_at = isoparse(d.pop("updated_at"))
details = d.pop("details")
role = d.pop("role")
delay = d.pop("delay", UNSET)
transaction = cls(
uuid=uuid,
payer=payer,
payer_type=payer_type,
payer_wallet=payer_wallet,
payee=payee,
payee_type=payee_type,
payee_wallet=payee_wallet,
created_at=created_at,
state=state,
amount=amount,
updated_at=updated_at,
details=details,
role=role,
delay=delay,
)
transaction.additional_properties = d
return transaction
@property
def additional_keys(self) -> list[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]
def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value
def __delitem__(self, key: str) -> None:
del self.additional_properties[key]
def __contains__(self, key: str) -> bool:
return key in self.additional_properties

View file

@ -1,140 +0,0 @@
import datetime
from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, TypeVar
from uuid import UUID
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from dateutil.parser import isoparse
if TYPE_CHECKING:
from ..models.transaction import Transaction
T = TypeVar("T", bound="TransactionGrouped")
@_attrs_define
class TransactionGrouped:
"""
Attributes:
reference (UUID):
application (UUID):
total_amount (float):
total_count (int):
state (int):
description (str):
created_at (datetime.datetime):
role (int):
transactions (list['Transaction']):
"""
reference: UUID
application: UUID
total_amount: float
total_count: int
state: int
description: str
created_at: datetime.datetime
role: int
transactions: list["Transaction"]
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
reference = str(self.reference)
application = str(self.application)
total_amount = self.total_amount
total_count = self.total_count
state = self.state
description = self.description
created_at = self.created_at.isoformat()
role = self.role
transactions = []
for transactions_item_data in self.transactions:
transactions_item = transactions_item_data.to_dict()
transactions.append(transactions_item)
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"reference": reference,
"application": application,
"total_amount": total_amount,
"total_count": total_count,
"state": state,
"description": description,
"created_at": created_at,
"role": role,
"transactions": transactions,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
from ..models.transaction import Transaction
d = dict(src_dict)
reference = UUID(d.pop("reference"))
application = UUID(d.pop("application"))
total_amount = d.pop("total_amount")
total_count = d.pop("total_count")
state = d.pop("state")
description = d.pop("description")
created_at = isoparse(d.pop("created_at"))
role = d.pop("role")
transactions = []
_transactions = d.pop("transactions")
for transactions_item_data in _transactions:
transactions_item = Transaction.from_dict(transactions_item_data)
transactions.append(transactions_item)
transaction_grouped = cls(
reference=reference,
application=application,
total_amount=total_amount,
total_count=total_count,
state=state,
description=description,
created_at=created_at,
role=role,
transactions=transactions,
)
transaction_grouped.additional_properties = d
return transaction_grouped
@property
def additional_keys(self) -> list[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]
def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value
def __delitem__(self, key: str) -> None:
del self.additional_properties[key]
def __contains__(self, key: str) -> bool:
return key in self.additional_properties

View file

@ -1 +0,0 @@
# Marker file for PEP 561

View file

@ -1,54 +0,0 @@
"""Contains some shared types for properties"""
from collections.abc import Mapping, MutableMapping
from http import HTTPStatus
from typing import IO, BinaryIO, Generic, Literal, Optional, TypeVar, Union
from attrs import define
class Unset:
def __bool__(self) -> Literal[False]:
return False
UNSET: Unset = Unset()
# The types that `httpx.Client(files=)` can accept, copied from that library.
FileContent = Union[IO[bytes], bytes, str]
FileTypes = Union[
# (filename, file (or bytes), content_type)
tuple[Optional[str], FileContent, Optional[str]],
# (filename, file (or bytes), content_type, headers)
tuple[Optional[str], FileContent, Optional[str], Mapping[str, str]],
]
RequestFiles = list[tuple[str, FileTypes]]
@define
class File:
"""Contains information for file uploads"""
payload: BinaryIO
file_name: Optional[str] = None
mime_type: Optional[str] = None
def to_tuple(self) -> FileTypes:
"""Return a tuple representation that httpx will accept for multipart/form-data"""
return self.file_name, self.payload, self.mime_type
T = TypeVar("T")
@define
class Response(Generic[T]):
"""A response from an endpoint"""
status_code: HTTPStatus
content: bytes
headers: MutableMapping[str, str]
parsed: Optional[T]
__all__ = ["UNSET", "File", "FileTypes", "RequestFiles", "Response", "Unset"]

View file

@ -1,139 +0,0 @@
import time
import requests
from django.conf import settings
from django.core.cache import cache
from httpx import Request
from utils.clients.gooyal_wallet_client import AuthenticatedClient
from utils.clients.gooyal_wallet_client.models import Transaction, Account, ApplicationDeposit, ApplicationWithdraw, PaginatedAccountList
from utils.clients.gooyal_wallet_client.api.wallet import (wallet_api_application_deposit_create,
wallet_api_application_deposit_rollback_retrieve,
wallet_api_application_deposit_verify_retrieve,
wallet_api_application_withdraw_create,
wallet_api_application_withdraw_rollback_retrieve,
wallet_api_application_withdraw_verify_retrieve,
wallet_api_application_user_wallets_list)
def login_as_client_credentials():
access_token = cache.get('settlement_access_token')
# expires_in = self.auth_data.get('expires_in')
# created_at = self.auth_data.get('created_at')
#
# if access_token and expires_in > time.time() - created_at:
# return self.auth_data
if access_token:
print('already in cache')
return access_token
print('not in cache')
data = {
"grant_type": 'client_credentials',
"scope": settings.OAUTH2_PROVIDER_SCOPES,
}
auth = (settings.OAUTH2_PROVIDER_CLIENT_ID, settings.OAUTH2_PROVIDER_CLIENT_SECRET)
response = requests.post(f'{settings.OAUTH2_PROVIDER_BASE_PUBLIC_URL}/token/',
data=data,
auth=auth)
print(response.content)
auth_data = response.json()
if 'access_token' in auth_data:
auth_data['created_at'] = time.time()
cache.set('settlement_access_token', auth_data, timeout=auth_data.get('expires_in') - 5)
return auth_data
def log_request(request: Request):
print(request.headers['authorization'])
print(
f"Request event hook: {request.method} {request.url} {request.method} {request.headers} - Waiting for response")
def log_response(response):
request = response.request
print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}")
def get_client():
access_token = login_as_client_credentials()['access_token']
client = AuthenticatedClient(base_url=settings.WALLET_BASE_PUBLIC_URL, token=access_token,
httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
)
return client
def deposit_to_user_wallet_submit(payer_wallet, data):
class Tmp():
def to_dict(self):
return data
deposit_data = Tmp()
client = get_client()
response: ApplicationDeposit = wallet_api_application_deposit_create.sync(payer_wallet=payer_wallet,
client=client,
body=deposit_data)
print(response)
return response
def deposit_to_user_wallet_verify(payer_wallet, uuid):
client = get_client()
response: ApplicationDeposit = wallet_api_application_deposit_verify_retrieve.sync(payer_wallet=payer_wallet, uuid=uuid, client=client)
print(response)
return response
def rollback_deposit_to_user_wallet(payer_wallet, uuid):
client = get_client()
response: ApplicationDeposit = wallet_api_application_deposit_rollback_retrieve.sync(payer_wallet=payer_wallet, uuid=uuid, client=client)
print(response)
return response
def withdraw_from_user_wallet_submit(payee_wallet, data):
class Tmp():
def to_dict(self):
return data
withdraw_data = Tmp()
client = get_client()
response: ApplicationWithdraw = wallet_api_application_withdraw_create.sync(payee_wallet=payee_wallet, client=client, body=withdraw_data)
print(response)
return response
def rollback_withdraw_from_user_wallet(payee_wallet, uuid):
client = get_client()
response: ApplicationWithdraw = wallet_api_application_withdraw_rollback_retrieve.sync(payee_wallet=payee_wallet, uuid=uuid, client=client)
print(response)
return response
def withdraw_from_user_wallet_verify(payee_wallet, uuid):
client = get_client()
response: ApplicationWithdraw = wallet_api_application_withdraw_verify_retrieve.sync(payee_wallet=payee_wallet, uuid=uuid, client=client)
print(response)
return response
def get_user_wallets(owner, wallets):
client = get_client()
# by pass several wallet query params: [','.join([str(i) for i in wallets])]
response: PaginatedAccountList = wallet_api_application_user_wallets_list.sync(owner=owner, wallet=[','.join([str(i) for i in wallets])], client=client)
print(response)
balances = dict(map(lambda result: (str(result.wallet), result.balance), response.results))
return balances
sample_data = {
"uuid": "3fa85f64-5717-4562-b3fc-2c963f66afb1",
"payee_id": "5d66d02e-6087-4b0a-bb0c-291d5c11755a",
"payee_type": 1,
"amount": 2000,
"details": "string",
}