diff --git a/apps/pg/admin.py b/apps/pg/admin.py index c555afa..fcc83d2 100644 --- a/apps/pg/admin.py +++ b/apps/pg/admin.py @@ -1,15 +1,20 @@ +import logging import io import jdatetime import xlsxwriter -from django.contrib import admin +from django.contrib import admin, messages from django.db.models import Sum from django.http import HttpResponse from django.utils import timezone +from django.utils.html import format_html +from django.shortcuts import redirect, get_object_or_404 +from django.urls import path from .constans import StateChoices from .models import PaymentRequest, PNA, Fake +logger = logging.getLogger(__name__) class PNAAdmin(admin.ModelAdmin): list_display = ['pna_status_code', 'pna_status_message', 'jajali_datetime', 'payment_request'] @@ -68,6 +73,7 @@ def mark_as_registered(model_admin, request, queryset): class PaymentRequestAdmin(admin.ModelAdmin): list_display = ['state', 'uuid', 'splited_amount', 'user_id', 'jajali_datetime', 'is_registered', 'created_at', 'application', 'gateway'] + list_display = ['state', 'check_success_again', 'uuid', 'splited_amount', 'user_id', 'jajali_datetime', 'created_at', 'application', 'gateway'] search_fields = ['application__uuid','application__client_id', 'amount', 'user__uuid'] list_filter = ['application', 'state', 'gateway'] actions = [export_exel, change_to_success, change_to_failed, mark_as_registered] @@ -84,6 +90,35 @@ class PaymentRequestAdmin(admin.ModelAdmin): extra_context['totals'] = totals return super().changelist_view(request, extra_context=extra_context) + def check_success_again(self, obj): + if obj.state in [StateChoices.IPG_SUCCESS, StateChoices.WALLET_SUBMIT_PENDING, StateChoices.WALLET_SUBMIT_SUCCESS]: + return format_html( + 'بررسی دوباره موفقیت', + f'{obj.uuid}/check_success_again/' + ) + return '' + + def get_urls(self): + urls = super().get_urls() + custom_urls = [ + path('/check_success_again/', self.admin_site.admin_view(self.check_success_again_view)) + ] + return custom_urls + urls + def check_success_again_view(self, request, payment_request_uuid): + logger.info(f"[Admin panel] Check success again for payment_request_uuid={payment_request_uuid}") + payment_request: PaymentRequest = get_object_or_404(PaymentRequest, uuid=payment_request_uuid) + logger.info(f"[Admin panel] initial payment_request state={payment_request.state}") + if payment_request.state == StateChoices.IPG_SUCCESS: + payment_request.charge_wallet_balance() + elif payment_request.state == StateChoices.WALLET_SUBMIT_PENDING: + payment_request.deposit_submit() + elif payment_request.state == StateChoices.WALLET_SUBMIT_SUCCESS: + payment_request.deposit_verify() + payment_request.refresh_from_db() + logger.info(f"[Admin panel] final payment_request state={payment_request.state}") + self.message_user(request, f"درخواست {payment_request_uuid} بررسی شد ✅") + return redirect(request.META.get("HTTP_REFERER", "..")) + class FakeAdmin(admin.ModelAdmin): list_display = [ 'created_at'] diff --git a/apps/pg/models.py b/apps/pg/models.py index af26d87..025567e 100644 --- a/apps/pg/models.py +++ b/apps/pg/models.py @@ -1,5 +1,6 @@ +import logging + import urllib.parse -from mimetypes import guess_all_extensions import jdatetime from django.conf import settings @@ -18,7 +19,7 @@ from utils.wallet_client import deposit_to_user_wallet_submit, withdraw_from_use from utils.pna import PNAClient from django.utils.translation import gettext_lazy as _ - +logger = logging.getLogger(__name__) class GatewayChoise(TextChoices): FAKE = "fake", _("fake") @@ -116,7 +117,67 @@ class PaymentRequest(models.Model): else: raise Exception(error_message) + def deposit_submit(self): + data = { + "uuid": str(self.uuid), + "payee_id": str(self.user.uuid), + "payee_type": 1, + "amount": self.amount, + "details": { + 'description': str(_("charge via ipg")), + 'reference_id': str(self.uuid), + 'application_details_url': '' + }, + } + submit_response = deposit_to_user_wallet_submit(settings.WALLET_CATEGORY_UUID, data) + + if not submit_response or not submit_response.uuid: + logger.error(f"[Deposit Submit] Wallet submission failed | payment_id={self.pk}") + raise Exception('Failed to submit payment in wallet') + + to_success = PaymentRequest.objects.filter( + pk=self.pk, + state=StateChoices.WALLET_SUBMIT_PENDING.value, + ).update( + state=StateChoices.WALLET_SUBMIT_SUCCESS.value) + + if not to_success: + logger.error(f"[Deposit Submit] Failed to update state to WALLET_SUBMIT_SUCCESS | payment_id={self.pk}") + raise Exception('Cannot charge balance because state') + return to_success + + def deposit_verify(self): + verify_response = deposit_to_user_wallet_verify(settings.WALLET_CATEGORY_UUID, self.uuid) + + if not verify_response: + logger.error(f"[Deposit Verify] Failed to get response from wallet service | payment_id={self.pk}") + raise Exception('Failed to get response from wallet service') + + if not verify_response.uuid or verify_response.state != 5: + logger.error(f"[Deposit Verify] Wallet verification failed | payment_id={self.pk}, response={verify_response}") + to_pay_failed = PaymentRequest.objects.filter( + pk=self.pk, + state=StateChoices.WALLET_SUBMIT_SUCCESS.value + ).update( + state=StateChoices.FAILED.value, + ) + raise Exception('Failed to verify payment in wallet') + + to_pay_success = PaymentRequest.objects.filter( + pk=self.pk, + state=StateChoices.WALLET_SUBMIT_SUCCESS.value + ).update( + state=StateChoices.SUCCESS.value, + ) + + if not to_pay_success: + logger.error(f"[Deposit Verify] Failed to update state to SUCCESS | payment_id={self.pk}") + raise Exception('Failed to update state payment') + + return to_pay_success + def charge_wallet_balance(self): + logger.info(f"[Charge Wallet] Starting wallet charge process | payment_id={self.pk}") if self.state in [StateChoices.IPG_SUCCESS]: to_pending = PaymentRequest.objects.filter( pk=self.pk, @@ -124,54 +185,15 @@ class PaymentRequest(models.Model): ).update( state=StateChoices.WALLET_SUBMIT_PENDING.value) if not to_pending: + logger.error(f"[Charge Wallet] Failed to update state to WALLET_SUBMIT_PENDING | payment_id={self.pk}") raise Exception('Cannot charge balance because state') - - data = { - "uuid": str(self.uuid), - "payee_id": str(self.user.uuid), - "payee_type": 1, - "amount": self.amount, - "details": { - 'description': str(_("charge via ipg")), - 'reference_id': str(self.uuid), - 'application_details_url': '' - }, - } - submit_response = deposit_to_user_wallet_submit(data) - - if not submit_response.uuid: - raise Exception('Failed to submit payment in wallet') - - to_success = PaymentRequest.objects.filter( - pk=self.pk, - state=StateChoices.WALLET_SUBMIT_PENDING.value, - ).update( - state=StateChoices.WALLET_SUBMIT_SUCCESS.value) - - if not to_success: - raise Exception('Cannot charge balance because state') - - verify_response = deposit_to_user_wallet_verify(self.uuid) - - if not verify_response.uuid or verify_response.state != 5: - to_pay_failed = PaymentRequest.objects.filter( - pk=self.pk, - state=StateChoices.WALLET_SUBMIT_SUCCESS.value - ).update( - state=StateChoices.FAILED.value, - ) - raise Exception('Failed to verify payment in wallet') - - to_pay_success = PaymentRequest.objects.filter( - pk=self.pk, - state=StateChoices.WALLET_SUBMIT_SUCCESS.value - ).update( - state=StateChoices.SUCCESS.value, - ) - - if not to_pay_success: - raise Exception('Failed to update state payment') - + logger.info(f"[Charge Wallet] State updated to WALLET_SUBMIT_PENDING | payment_id={self.pk}") + self.deposit_submit() + to_pay_success = self.deposit_verify() + if to_pay_success: + logger.info(f"[Charge Wallet] Wallet charged successfully | payment_id={self.pk}") + else: + logger.warning(f"[Charge Wallet] Wallet charge verification failed | payment_id={self.pk}") return bool(to_pay_success) diff --git a/gooyal_wallet_client/api/api/__init__.py b/gooyal_wallet_client/api/api/__init__.py new file mode 100644 index 0000000..2d7c0b2 --- /dev/null +++ b/gooyal_wallet_client/api/api/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/gooyal_wallet_client/api/api/api_charge_create_create.py b/gooyal_wallet_client/api/api/api_charge_create_create.py new file mode 100644 index 0000000..d85ea99 --- /dev/null +++ b/gooyal_wallet_client/api/api/api_charge_create_create.py @@ -0,0 +1,151 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.charge import Charge +from ...types import Response + + +def _get_kwargs( + *, + body: Charge, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": "/api/charge_create", + } + + _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[Charge]: + if response.status_code == 201: + response_201 = Charge.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[Charge]: + 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, + body: Charge, +) -> Response[Charge]: + """ + Args: + body (Charge): + + 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[Charge] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + *, + client: AuthenticatedClient, + body: Charge, +) -> Optional[Charge]: + """ + Args: + body (Charge): + + 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: + Charge + """ + + return sync_detailed( + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + *, + client: AuthenticatedClient, + body: Charge, +) -> Response[Charge]: + """ + Args: + body (Charge): + + 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[Charge] + """ + + kwargs = _get_kwargs( + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + *, + client: AuthenticatedClient, + body: Charge, +) -> Optional[Charge]: + """ + Args: + body (Charge): + + 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: + Charge + """ + + return ( + await asyncio_detailed( + client=client, + body=body, + ) + ).parsed diff --git a/gooyal_wallet_client/api/wallet/__init__.py b/gooyal_wallet_client/api/wallet/__init__.py index e69de29..2d7c0b2 100644 --- a/gooyal_wallet_client/api/wallet/__init__.py +++ b/gooyal_wallet_client/api/wallet/__init__.py @@ -0,0 +1 @@ +"""Contains endpoint functions for accessing the API""" diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_balance_retrieve.py b/gooyal_wallet_client/api/wallet/wallet_api_application_balance_retrieve.py index 6e39db6..f896c6c 100644 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_balance_retrieve.py +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_balance_retrieve.py @@ -25,6 +25,7 @@ def _parse_response( response_200 = ApplicationBalance.from_dict(response.json()) return response_200 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_balance_retrieve_2.py b/gooyal_wallet_client/api/wallet/wallet_api_application_balance_retrieve_2.py new file mode 100644 index 0000000..6c10de8 --- /dev/null +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_balance_retrieve_2.py @@ -0,0 +1,151 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.application_balance import ApplicationBalance +from ...types import Response + + +def _get_kwargs( + category_uuid: str, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/wallet/api/application/{category_uuid}/balance", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[ApplicationBalance]: + if response.status_code == 200: + response_200 = ApplicationBalance.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[ApplicationBalance]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + category_uuid: str, + *, + client: AuthenticatedClient, +) -> Response[ApplicationBalance]: + """API for getting specified user or application balance. + + Args: + category_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[ApplicationBalance] + """ + + kwargs = _get_kwargs( + category_uuid=category_uuid, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + category_uuid: str, + *, + client: AuthenticatedClient, +) -> Optional[ApplicationBalance]: + """API for getting specified user or application balance. + + Args: + category_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: + ApplicationBalance + """ + + return sync_detailed( + category_uuid=category_uuid, + client=client, + ).parsed + + +async def asyncio_detailed( + category_uuid: str, + *, + client: AuthenticatedClient, +) -> Response[ApplicationBalance]: + """API for getting specified user or application balance. + + Args: + category_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[ApplicationBalance] + """ + + kwargs = _get_kwargs( + category_uuid=category_uuid, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + category_uuid: str, + *, + client: AuthenticatedClient, +) -> Optional[ApplicationBalance]: + """API for getting specified user or application balance. + + Args: + category_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: + ApplicationBalance + """ + + return ( + await asyncio_detailed( + category_uuid=category_uuid, + client=client, + ) + ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_create.py b/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_create.py index 0612c2d..12f96d7 100644 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_create.py +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_create.py @@ -20,9 +20,8 @@ def _get_kwargs( "url": "/wallet/api/application/deposit/", } - _body = body.to_dict() + _kwargs["json"] = body.to_dict() - _kwargs["json"] = _body headers["Content-Type"] = "application/json" _kwargs["headers"] = headers @@ -36,6 +35,7 @@ def _parse_response( 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: diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_create_2.py b/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_create_2.py new file mode 100644 index 0000000..ef013a5 --- /dev/null +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_create_2.py @@ -0,0 +1,168 @@ +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( + category_uuid: str, + *, + body: ApplicationDeposit, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": f"/wallet/api/application/{category_uuid}/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( + category_uuid: str, + *, + client: AuthenticatedClient, + body: ApplicationDeposit, +) -> Response[ApplicationDeposit]: + """ + Args: + category_uuid (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( + category_uuid=category_uuid, + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + category_uuid: str, + *, + client: AuthenticatedClient, + body: ApplicationDeposit, +) -> Optional[ApplicationDeposit]: + """ + Args: + category_uuid (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( + category_uuid=category_uuid, + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + category_uuid: str, + *, + client: AuthenticatedClient, + body: ApplicationDeposit, +) -> Response[ApplicationDeposit]: + """ + Args: + category_uuid (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( + category_uuid=category_uuid, + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + category_uuid: str, + *, + client: AuthenticatedClient, + body: ApplicationDeposit, +) -> Optional[ApplicationDeposit]: + """ + Args: + category_uuid (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( + category_uuid=category_uuid, + client=client, + body=body, + ) + ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_verify_retrieve.py b/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_verify_retrieve.py index e5b7c34..fde4421 100644 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_verify_retrieve.py +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_verify_retrieve.py @@ -27,6 +27,7 @@ def _parse_response( 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: diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_verify_retrieve_2.py b/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_verify_retrieve_2.py new file mode 100644 index 0000000..e21cbdb --- /dev/null +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_deposit_verify_retrieve_2.py @@ -0,0 +1,160 @@ +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( + category_uuid: str, + uuid: str, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/wallet/api/application/{category_uuid}/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( + category_uuid: str, + uuid: str, + *, + client: AuthenticatedClient, +) -> Response[ApplicationDeposit]: + """ + Args: + category_uuid (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( + category_uuid=category_uuid, + uuid=uuid, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + category_uuid: str, + uuid: str, + *, + client: AuthenticatedClient, +) -> Optional[ApplicationDeposit]: + """ + Args: + category_uuid (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( + category_uuid=category_uuid, + uuid=uuid, + client=client, + ).parsed + + +async def asyncio_detailed( + category_uuid: str, + uuid: str, + *, + client: AuthenticatedClient, +) -> Response[ApplicationDeposit]: + """ + Args: + category_uuid (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( + category_uuid=category_uuid, + uuid=uuid, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + category_uuid: str, + uuid: str, + *, + client: AuthenticatedClient, +) -> Optional[ApplicationDeposit]: + """ + Args: + category_uuid (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( + category_uuid=category_uuid, + uuid=uuid, + client=client, + ) + ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_list.py b/gooyal_wallet_client/api/wallet/wallet_api_application_list.py index 8c65444..b3c7624 100644 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_list.py +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_list.py @@ -11,11 +11,14 @@ from ...types import UNSET, Response, Unset def _get_kwargs( *, - page: Union[Unset, int] = UNSET, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, ) -> dict[str, Any]: params: dict[str, Any] = {} - params["page"] = page + 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} @@ -35,6 +38,7 @@ def _parse_response( response_200 = PaginatedApplicationTransactionList.from_dict(response.json()) return response_200 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: @@ -55,11 +59,13 @@ def _build_response( def sync_detailed( *, client: AuthenticatedClient, - page: Union[Unset, int] = UNSET, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, ) -> Response[PaginatedApplicationTransactionList]: """ Args: - page (Union[Unset, int]): + 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. @@ -70,7 +76,8 @@ def sync_detailed( """ kwargs = _get_kwargs( - page=page, + limit=limit, + offset=offset, ) response = client.get_httpx_client().request( @@ -83,11 +90,13 @@ def sync_detailed( def sync( *, client: AuthenticatedClient, - page: Union[Unset, int] = UNSET, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, ) -> Optional[PaginatedApplicationTransactionList]: """ Args: - page (Union[Unset, int]): + 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. @@ -99,18 +108,21 @@ def sync( return sync_detailed( client=client, - page=page, + limit=limit, + offset=offset, ).parsed async def asyncio_detailed( *, client: AuthenticatedClient, - page: Union[Unset, int] = UNSET, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, ) -> Response[PaginatedApplicationTransactionList]: """ Args: - page (Union[Unset, int]): + 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. @@ -121,7 +133,8 @@ async def asyncio_detailed( """ kwargs = _get_kwargs( - page=page, + limit=limit, + offset=offset, ) response = await client.get_async_httpx_client().request(**kwargs) @@ -132,11 +145,13 @@ async def asyncio_detailed( async def asyncio( *, client: AuthenticatedClient, - page: Union[Unset, int] = UNSET, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, ) -> Optional[PaginatedApplicationTransactionList]: """ Args: - page (Union[Unset, int]): + 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. @@ -149,6 +164,7 @@ async def asyncio( return ( await asyncio_detailed( client=client, - page=page, + limit=limit, + offset=offset, ) ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_list_2.py b/gooyal_wallet_client/api/wallet/wallet_api_application_list_2.py new file mode 100644 index 0000000..84cbf49 --- /dev/null +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_list_2.py @@ -0,0 +1,183 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.paginated_application_transaction_list import PaginatedApplicationTransactionList +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + category_uuid: str, + *, + 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": f"/wallet/api/application/{category_uuid}/", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[PaginatedApplicationTransactionList]: + if response.status_code == 200: + response_200 = PaginatedApplicationTransactionList.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[PaginatedApplicationTransactionList]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + category_uuid: str, + *, + client: AuthenticatedClient, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, +) -> Response[PaginatedApplicationTransactionList]: + """ + Args: + category_uuid (str): + 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[PaginatedApplicationTransactionList] + """ + + kwargs = _get_kwargs( + category_uuid=category_uuid, + limit=limit, + offset=offset, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + category_uuid: str, + *, + client: AuthenticatedClient, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, +) -> Optional[PaginatedApplicationTransactionList]: + """ + Args: + category_uuid (str): + 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: + PaginatedApplicationTransactionList + """ + + return sync_detailed( + category_uuid=category_uuid, + client=client, + limit=limit, + offset=offset, + ).parsed + + +async def asyncio_detailed( + category_uuid: str, + *, + client: AuthenticatedClient, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, +) -> Response[PaginatedApplicationTransactionList]: + """ + Args: + category_uuid (str): + 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[PaginatedApplicationTransactionList] + """ + + kwargs = _get_kwargs( + category_uuid=category_uuid, + limit=limit, + offset=offset, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + category_uuid: str, + *, + client: AuthenticatedClient, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, +) -> Optional[PaginatedApplicationTransactionList]: + """ + Args: + category_uuid (str): + 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: + PaginatedApplicationTransactionList + """ + + return ( + await asyncio_detailed( + category_uuid=category_uuid, + client=client, + limit=limit, + offset=offset, + ) + ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_retrieve.py b/gooyal_wallet_client/api/wallet/wallet_api_application_retrieve.py index bbb4146..9ef9349 100644 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_retrieve.py +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_retrieve.py @@ -10,11 +10,12 @@ from ...types import Response def _get_kwargs( + category_uuid: str, uuid: str, ) -> dict[str, Any]: _kwargs: dict[str, Any] = { "method": "get", - "url": f"/wallet/api/application/{uuid}/", + "url": f"/wallet/api/application/{category_uuid}/{uuid}/", } return _kwargs @@ -27,6 +28,7 @@ def _parse_response( response_200 = ApplicationTransaction.from_dict(response.json()) return response_200 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: @@ -45,12 +47,14 @@ def _build_response( def sync_detailed( + category_uuid: str, uuid: str, *, client: AuthenticatedClient, ) -> Response[ApplicationTransaction]: """ Args: + category_uuid (str): uuid (str): Raises: @@ -62,6 +66,7 @@ def sync_detailed( """ kwargs = _get_kwargs( + category_uuid=category_uuid, uuid=uuid, ) @@ -73,12 +78,14 @@ def sync_detailed( def sync( + category_uuid: str, uuid: str, *, client: AuthenticatedClient, ) -> Optional[ApplicationTransaction]: """ Args: + category_uuid (str): uuid (str): Raises: @@ -90,18 +97,21 @@ def sync( """ return sync_detailed( + category_uuid=category_uuid, uuid=uuid, client=client, ).parsed async def asyncio_detailed( + category_uuid: str, uuid: str, *, client: AuthenticatedClient, ) -> Response[ApplicationTransaction]: """ Args: + category_uuid (str): uuid (str): Raises: @@ -113,6 +123,7 @@ async def asyncio_detailed( """ kwargs = _get_kwargs( + category_uuid=category_uuid, uuid=uuid, ) @@ -122,12 +133,14 @@ async def asyncio_detailed( async def asyncio( + category_uuid: str, uuid: str, *, client: AuthenticatedClient, ) -> Optional[ApplicationTransaction]: """ Args: + category_uuid (str): uuid (str): Raises: @@ -140,6 +153,7 @@ async def asyncio( return ( await asyncio_detailed( + category_uuid=category_uuid, uuid=uuid, client=client, ) diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_retrieve_2.py b/gooyal_wallet_client/api/wallet/wallet_api_application_retrieve_2.py new file mode 100644 index 0000000..50d6347 --- /dev/null +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_retrieve_2.py @@ -0,0 +1,147 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.application_transaction import ApplicationTransaction +from ...types import Response + + +def _get_kwargs( + uuid: str, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/wallet/api/application/{uuid}/", + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[ApplicationTransaction]: + if response.status_code == 200: + response_200 = ApplicationTransaction.from_dict(response.json()) + + return response_200 + + if client.raise_on_unexpected_status: + raise errors.UnexpectedStatus(response.status_code, response.content) + else: + return None + + +def _build_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Response[ApplicationTransaction]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + uuid: str, + *, + client: AuthenticatedClient, +) -> Response[ApplicationTransaction]: + """ + Args: + uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ApplicationTransaction] + """ + + kwargs = _get_kwargs( + uuid=uuid, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + uuid: str, + *, + client: AuthenticatedClient, +) -> Optional[ApplicationTransaction]: + """ + Args: + uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ApplicationTransaction + """ + + return sync_detailed( + uuid=uuid, + client=client, + ).parsed + + +async def asyncio_detailed( + uuid: str, + *, + client: AuthenticatedClient, +) -> Response[ApplicationTransaction]: + """ + Args: + uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ApplicationTransaction] + """ + + kwargs = _get_kwargs( + uuid=uuid, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + uuid: str, + *, + client: AuthenticatedClient, +) -> Optional[ApplicationTransaction]: + """ + Args: + uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + ApplicationTransaction + """ + + return ( + await asyncio_detailed( + uuid=uuid, + client=client, + ) + ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_user_balance_retrieve.py b/gooyal_wallet_client/api/wallet/wallet_api_application_user_balance_retrieve.py new file mode 100644 index 0000000..2062248 --- /dev/null +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_user_balance_retrieve.py @@ -0,0 +1,147 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.my_wallet import MyWallet +from ...types import Response + + +def _get_kwargs( + uuid: str, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/wallet/api/application/user_balance/{uuid}", + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[MyWallet]: + if response.status_code == 200: + response_200 = MyWallet.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[MyWallet]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + uuid: str, + *, + client: AuthenticatedClient, +) -> Response[MyWallet]: + """API for getting specified user or application balance. + + Args: + uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[MyWallet] + """ + + kwargs = _get_kwargs( + uuid=uuid, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + uuid: str, + *, + client: AuthenticatedClient, +) -> Optional[MyWallet]: + """API for getting specified user or application balance. + + Args: + uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + MyWallet + """ + + return sync_detailed( + uuid=uuid, + client=client, + ).parsed + + +async def asyncio_detailed( + uuid: str, + *, + client: AuthenticatedClient, +) -> Response[MyWallet]: + """API for getting specified user or application balance. + + Args: + uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[MyWallet] + """ + + kwargs = _get_kwargs( + uuid=uuid, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + uuid: str, + *, + client: AuthenticatedClient, +) -> Optional[MyWallet]: + """API for getting specified user or application balance. + + Args: + uuid (str): + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + MyWallet + """ + + return ( + await asyncio_detailed( + uuid=uuid, + client=client, + ) + ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_user_balance_retrieve_2.py b/gooyal_wallet_client/api/wallet/wallet_api_application_user_balance_retrieve_2.py new file mode 100644 index 0000000..f77f03f --- /dev/null +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_user_balance_retrieve_2.py @@ -0,0 +1,160 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.my_wallet import MyWallet +from ...types import Response + + +def _get_kwargs( + category_uuid: str, + uuid: str, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/wallet/api/application/{category_uuid}/user/{uuid}/balance", + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[MyWallet]: + if response.status_code == 200: + response_200 = MyWallet.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[MyWallet]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + category_uuid: str, + uuid: str, + *, + client: AuthenticatedClient, +) -> Response[MyWallet]: + """API for getting specified user or application balance. + + Args: + category_uuid (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[MyWallet] + """ + + kwargs = _get_kwargs( + category_uuid=category_uuid, + uuid=uuid, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + category_uuid: str, + uuid: str, + *, + client: AuthenticatedClient, +) -> Optional[MyWallet]: + """API for getting specified user or application balance. + + Args: + category_uuid (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: + MyWallet + """ + + return sync_detailed( + category_uuid=category_uuid, + uuid=uuid, + client=client, + ).parsed + + +async def asyncio_detailed( + category_uuid: str, + uuid: str, + *, + client: AuthenticatedClient, +) -> Response[MyWallet]: + """API for getting specified user or application balance. + + Args: + category_uuid (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[MyWallet] + """ + + kwargs = _get_kwargs( + category_uuid=category_uuid, + uuid=uuid, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + category_uuid: str, + uuid: str, + *, + client: AuthenticatedClient, +) -> Optional[MyWallet]: + """API for getting specified user or application balance. + + Args: + category_uuid (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: + MyWallet + """ + + return ( + await asyncio_detailed( + category_uuid=category_uuid, + uuid=uuid, + client=client, + ) + ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_create.py b/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_create.py index 731ae3c..3853436 100644 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_create.py +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_create.py @@ -20,9 +20,8 @@ def _get_kwargs( "url": "/wallet/api/application/withdraw/", } - _body = body.to_dict() + _kwargs["json"] = body.to_dict() - _kwargs["json"] = _body headers["Content-Type"] = "application/json" _kwargs["headers"] = headers @@ -36,6 +35,7 @@ def _parse_response( 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: diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_create_2.py b/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_create_2.py new file mode 100644 index 0000000..f4b42ac --- /dev/null +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_create_2.py @@ -0,0 +1,168 @@ +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( + category_uuid: str, + *, + body: ApplicationWithdraw, +) -> dict[str, Any]: + headers: dict[str, Any] = {} + + _kwargs: dict[str, Any] = { + "method": "post", + "url": f"/wallet/api/application/{category_uuid}/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( + category_uuid: str, + *, + client: AuthenticatedClient, + body: ApplicationWithdraw, +) -> Response[ApplicationWithdraw]: + """ + Args: + category_uuid (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( + category_uuid=category_uuid, + body=body, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + category_uuid: str, + *, + client: AuthenticatedClient, + body: ApplicationWithdraw, +) -> Optional[ApplicationWithdraw]: + """ + Args: + category_uuid (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( + category_uuid=category_uuid, + client=client, + body=body, + ).parsed + + +async def asyncio_detailed( + category_uuid: str, + *, + client: AuthenticatedClient, + body: ApplicationWithdraw, +) -> Response[ApplicationWithdraw]: + """ + Args: + category_uuid (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( + category_uuid=category_uuid, + body=body, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + category_uuid: str, + *, + client: AuthenticatedClient, + body: ApplicationWithdraw, +) -> Optional[ApplicationWithdraw]: + """ + Args: + category_uuid (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( + category_uuid=category_uuid, + client=client, + body=body, + ) + ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_verify_retrieve.py b/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_verify_retrieve.py index 0e0d0db..dd57a27 100644 --- a/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_verify_retrieve.py +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_verify_retrieve.py @@ -27,6 +27,7 @@ def _parse_response( 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: diff --git a/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_verify_retrieve_2.py b/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_verify_retrieve_2.py new file mode 100644 index 0000000..651a764 --- /dev/null +++ b/gooyal_wallet_client/api/wallet/wallet_api_application_withdraw_verify_retrieve_2.py @@ -0,0 +1,160 @@ +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( + category_uuid: str, + uuid: str, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/wallet/api/application/{category_uuid}/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( + category_uuid: str, + uuid: str, + *, + client: AuthenticatedClient, +) -> Response[ApplicationWithdraw]: + """ + Args: + category_uuid (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( + category_uuid=category_uuid, + uuid=uuid, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + category_uuid: str, + uuid: str, + *, + client: AuthenticatedClient, +) -> Optional[ApplicationWithdraw]: + """ + Args: + category_uuid (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( + category_uuid=category_uuid, + uuid=uuid, + client=client, + ).parsed + + +async def asyncio_detailed( + category_uuid: str, + uuid: str, + *, + client: AuthenticatedClient, +) -> Response[ApplicationWithdraw]: + """ + Args: + category_uuid (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( + category_uuid=category_uuid, + uuid=uuid, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + category_uuid: str, + uuid: str, + *, + client: AuthenticatedClient, +) -> Optional[ApplicationWithdraw]: + """ + Args: + category_uuid (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( + category_uuid=category_uuid, + uuid=uuid, + client=client, + ) + ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_transactions_list.py b/gooyal_wallet_client/api/wallet/wallet_api_transactions_list.py index 4009fe1..7880004 100644 --- a/gooyal_wallet_client/api/wallet/wallet_api_transactions_list.py +++ b/gooyal_wallet_client/api/wallet/wallet_api_transactions_list.py @@ -11,11 +11,14 @@ from ...types import UNSET, Response, Unset def _get_kwargs( *, - page: Union[Unset, int] = UNSET, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, ) -> dict[str, Any]: params: dict[str, Any] = {} - params["page"] = page + 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} @@ -35,6 +38,7 @@ def _parse_response( response_200 = PaginatedUserTransactionList.from_dict(response.json()) return response_200 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: @@ -55,7 +59,8 @@ def _build_response( def sync_detailed( *, client: AuthenticatedClient, - page: Union[Unset, int] = UNSET, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, ) -> Response[PaginatedUserTransactionList]: """GET: API for getting list of transactions for authenticated user POST: API for creating transaction for transferring funds from authenticated user to application @@ -64,7 +69,8 @@ def sync_detailed( - user: authenticated user Args: - page (Union[Unset, int]): + 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. @@ -75,7 +81,8 @@ def sync_detailed( """ kwargs = _get_kwargs( - page=page, + limit=limit, + offset=offset, ) response = client.get_httpx_client().request( @@ -88,7 +95,8 @@ def sync_detailed( def sync( *, client: AuthenticatedClient, - page: Union[Unset, int] = UNSET, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, ) -> Optional[PaginatedUserTransactionList]: """GET: API for getting list of transactions for authenticated user POST: API for creating transaction for transferring funds from authenticated user to application @@ -97,7 +105,8 @@ def sync( - user: authenticated user Args: - page (Union[Unset, int]): + 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. @@ -109,14 +118,16 @@ def sync( return sync_detailed( client=client, - page=page, + limit=limit, + offset=offset, ).parsed async def asyncio_detailed( *, client: AuthenticatedClient, - page: Union[Unset, int] = UNSET, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, ) -> Response[PaginatedUserTransactionList]: """GET: API for getting list of transactions for authenticated user POST: API for creating transaction for transferring funds from authenticated user to application @@ -125,7 +136,8 @@ async def asyncio_detailed( - user: authenticated user Args: - page (Union[Unset, int]): + 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. @@ -136,7 +148,8 @@ async def asyncio_detailed( """ kwargs = _get_kwargs( - page=page, + limit=limit, + offset=offset, ) response = await client.get_async_httpx_client().request(**kwargs) @@ -147,7 +160,8 @@ async def asyncio_detailed( async def asyncio( *, client: AuthenticatedClient, - page: Union[Unset, int] = UNSET, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, ) -> Optional[PaginatedUserTransactionList]: """GET: API for getting list of transactions for authenticated user POST: API for creating transaction for transferring funds from authenticated user to application @@ -156,7 +170,8 @@ async def asyncio( - user: authenticated user Args: - page (Union[Unset, int]): + 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. @@ -169,6 +184,7 @@ async def asyncio( return ( await asyncio_detailed( client=client, - page=page, + limit=limit, + offset=offset, ) ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_user_balance_retrieve.py b/gooyal_wallet_client/api/wallet/wallet_api_user_balance_retrieve.py new file mode 100644 index 0000000..2928286 --- /dev/null +++ b/gooyal_wallet_client/api/wallet/wallet_api_user_balance_retrieve.py @@ -0,0 +1,147 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.my_wallet import MyWallet +from ...types import Response + + +def _get_kwargs( + category_uuid: str, +) -> dict[str, Any]: + _kwargs: dict[str, Any] = { + "method": "get", + "url": f"/wallet/api/user/{category_uuid}/balance", + } + + return _kwargs + + +def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[MyWallet]: + if response.status_code == 200: + response_200 = MyWallet.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[MyWallet]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + category_uuid: str, + *, + client: AuthenticatedClient, +) -> Response[MyWallet]: + """API for getting authenticated user balance. + + Args: + category_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[MyWallet] + """ + + kwargs = _get_kwargs( + category_uuid=category_uuid, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + category_uuid: str, + *, + client: AuthenticatedClient, +) -> Optional[MyWallet]: + """API for getting authenticated user balance. + + Args: + category_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: + MyWallet + """ + + return sync_detailed( + category_uuid=category_uuid, + client=client, + ).parsed + + +async def asyncio_detailed( + category_uuid: str, + *, + client: AuthenticatedClient, +) -> Response[MyWallet]: + """API for getting authenticated user balance. + + Args: + category_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[MyWallet] + """ + + kwargs = _get_kwargs( + category_uuid=category_uuid, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + category_uuid: str, + *, + client: AuthenticatedClient, +) -> Optional[MyWallet]: + """API for getting authenticated user balance. + + Args: + category_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: + MyWallet + """ + + return ( + await asyncio_detailed( + category_uuid=category_uuid, + client=client, + ) + ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_user_transactions_list.py b/gooyal_wallet_client/api/wallet/wallet_api_user_transactions_list.py new file mode 100644 index 0000000..50cbc86 --- /dev/null +++ b/gooyal_wallet_client/api/wallet/wallet_api_user_transactions_list.py @@ -0,0 +1,203 @@ +from http import HTTPStatus +from typing import Any, Optional, Union + +import httpx + +from ... import errors +from ...client import AuthenticatedClient, Client +from ...models.paginated_user_transaction_list import PaginatedUserTransactionList +from ...types import UNSET, Response, Unset + + +def _get_kwargs( + category_uuid: str, + *, + 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": f"/wallet/api/user/{category_uuid}/transactions/", + "params": params, + } + + return _kwargs + + +def _parse_response( + *, client: Union[AuthenticatedClient, Client], response: httpx.Response +) -> Optional[PaginatedUserTransactionList]: + if response.status_code == 200: + response_200 = PaginatedUserTransactionList.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[PaginatedUserTransactionList]: + return Response( + status_code=HTTPStatus(response.status_code), + content=response.content, + headers=response.headers, + parsed=_parse_response(client=client, response=response), + ) + + +def sync_detailed( + category_uuid: str, + *, + client: AuthenticatedClient, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, +) -> Response[PaginatedUserTransactionList]: + """GET: API for getting list of transactions for authenticated user + POST: API for creating transaction for transferring funds from authenticated user to application + owner. (deprecated) + args: + - user: authenticated user + + Args: + category_uuid (str): + 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[PaginatedUserTransactionList] + """ + + kwargs = _get_kwargs( + category_uuid=category_uuid, + limit=limit, + offset=offset, + ) + + response = client.get_httpx_client().request( + **kwargs, + ) + + return _build_response(client=client, response=response) + + +def sync( + category_uuid: str, + *, + client: AuthenticatedClient, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, +) -> Optional[PaginatedUserTransactionList]: + """GET: API for getting list of transactions for authenticated user + POST: API for creating transaction for transferring funds from authenticated user to application + owner. (deprecated) + args: + - user: authenticated user + + Args: + category_uuid (str): + 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: + PaginatedUserTransactionList + """ + + return sync_detailed( + category_uuid=category_uuid, + client=client, + limit=limit, + offset=offset, + ).parsed + + +async def asyncio_detailed( + category_uuid: str, + *, + client: AuthenticatedClient, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, +) -> Response[PaginatedUserTransactionList]: + """GET: API for getting list of transactions for authenticated user + POST: API for creating transaction for transferring funds from authenticated user to application + owner. (deprecated) + args: + - user: authenticated user + + Args: + category_uuid (str): + 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[PaginatedUserTransactionList] + """ + + kwargs = _get_kwargs( + category_uuid=category_uuid, + limit=limit, + offset=offset, + ) + + response = await client.get_async_httpx_client().request(**kwargs) + + return _build_response(client=client, response=response) + + +async def asyncio( + category_uuid: str, + *, + client: AuthenticatedClient, + limit: Union[Unset, int] = UNSET, + offset: Union[Unset, int] = UNSET, +) -> Optional[PaginatedUserTransactionList]: + """GET: API for getting list of transactions for authenticated user + POST: API for creating transaction for transferring funds from authenticated user to application + owner. (deprecated) + args: + - user: authenticated user + + Args: + category_uuid (str): + 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: + PaginatedUserTransactionList + """ + + return ( + await asyncio_detailed( + category_uuid=category_uuid, + client=client, + limit=limit, + offset=offset, + ) + ).parsed diff --git a/gooyal_wallet_client/api/wallet/wallet_api_wallet_balance_retrieve.py b/gooyal_wallet_client/api/wallet/wallet_api_wallet_balance_retrieve.py index a05375e..5a5e38d 100644 --- a/gooyal_wallet_client/api/wallet/wallet_api_wallet_balance_retrieve.py +++ b/gooyal_wallet_client/api/wallet/wallet_api_wallet_balance_retrieve.py @@ -23,6 +23,7 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt response_200 = MyWallet.from_dict(response.json()) return response_200 + if client.raise_on_unexpected_status: raise errors.UnexpectedStatus(response.status_code, response.content) else: diff --git a/gooyal_wallet_client/models/__init__.py b/gooyal_wallet_client/models/__init__.py index 30db318..06a7b4a 100644 --- a/gooyal_wallet_client/models/__init__.py +++ b/gooyal_wallet_client/models/__init__.py @@ -4,11 +4,10 @@ from .application_balance import ApplicationBalance from .application_deposit import ApplicationDeposit from .application_transaction import ApplicationTransaction from .application_withdraw import ApplicationWithdraw +from .charge import Charge from .my_wallet import MyWallet from .paginated_application_transaction_list import PaginatedApplicationTransactionList from .paginated_user_transaction_list import PaginatedUserTransactionList -from .payee_type_enum import PayeeTypeEnum -from .payer_type_enum import PayerTypeEnum from .state_enum import StateEnum from .user_transaction import UserTransaction @@ -17,11 +16,10 @@ __all__ = ( "ApplicationDeposit", "ApplicationTransaction", "ApplicationWithdraw", + "Charge", "MyWallet", "PaginatedApplicationTransactionList", "PaginatedUserTransactionList", - "PayeeTypeEnum", - "PayerTypeEnum", "StateEnum", "UserTransaction", ) diff --git a/gooyal_wallet_client/models/application_balance.py b/gooyal_wallet_client/models/application_balance.py index c094cc5..3ae824e 100644 --- a/gooyal_wallet_client/models/application_balance.py +++ b/gooyal_wallet_client/models/application_balance.py @@ -1,3 +1,4 @@ +from collections.abc import Mapping from typing import Any, TypeVar, Union from attrs import define as _attrs_define @@ -30,8 +31,8 @@ class ApplicationBalance: return field_dict @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) balance = d.pop("balance", UNSET) application_balance = cls( diff --git a/gooyal_wallet_client/models/application_deposit.py b/gooyal_wallet_client/models/application_deposit.py index 267dc45..9d1772f 100644 --- a/gooyal_wallet_client/models/application_deposit.py +++ b/gooyal_wallet_client/models/application_deposit.py @@ -1,13 +1,12 @@ import datetime -from typing import Any, TypeVar, Union, cast +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.payee_type_enum import PayeeTypeEnum -from ..models.payer_type_enum import PayerTypeEnum from ..models.state_enum import StateEnum from ..types import UNSET, Unset @@ -18,11 +17,11 @@ T = TypeVar("T", bound="ApplicationDeposit") class ApplicationDeposit: """ Attributes: - uuid (UUID): - payer_id (Union[None, UUID]): - payer_type (Union[None, PayerTypeEnum]): + payer_id (str): + payer_type (str): payee_id (UUID): - created_at (Union[None, datetime.datetime]): + payee_type (int): + created_at (datetime.datetime): state (StateEnum): * `1` - created * `2` - delayed * `3` - pending @@ -31,63 +30,43 @@ class ApplicationDeposit: * `6` - failed * `7` - expected_failure amount (int): - updated_at (Union[None, datetime.datetime]): - payee_type (Union[None, PayeeTypeEnum, Unset]): + updated_at (datetime.datetime): + uuid (Union[Unset, UUID]): details (Union[Unset, Any]): """ - uuid: UUID - payer_id: Union[None, UUID] - payer_type: Union[None, PayerTypeEnum] + payer_id: str + payer_type: str payee_id: UUID - created_at: Union[None, datetime.datetime] + payee_type: int + created_at: datetime.datetime state: StateEnum amount: int - updated_at: Union[None, datetime.datetime] - payee_type: Union[None, PayeeTypeEnum, Unset] = UNSET + 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]: - uuid = str(self.uuid) + payer_id = self.payer_id - payer_id: Union[None, str] - if isinstance(self.payer_id, UUID): - payer_id = str(self.payer_id) - else: - payer_id = self.payer_id - - payer_type: Union[None, int] - if isinstance(self.payer_type, PayerTypeEnum): - payer_type = self.payer_type.value - else: - payer_type = self.payer_type + payer_type = self.payer_type payee_id = str(self.payee_id) - created_at: Union[None, str] - if isinstance(self.created_at, datetime.datetime): - created_at = self.created_at.isoformat() - else: - created_at = self.created_at + payee_type = self.payee_type + + created_at = self.created_at.isoformat() state = self.state.value amount = self.amount - updated_at: Union[None, str] - if isinstance(self.updated_at, datetime.datetime): - updated_at = self.updated_at.isoformat() - else: - updated_at = self.updated_at + updated_at = self.updated_at.isoformat() - payee_type: Union[None, Unset, int] - if isinstance(self.payee_type, Unset): - payee_type = UNSET - elif isinstance(self.payee_type, PayeeTypeEnum): - payee_type = self.payee_type.value - else: - payee_type = self.payee_type + uuid: Union[Unset, str] = UNSET + if not isinstance(self.uuid, Unset): + uuid = str(self.uuid) details = self.details @@ -95,123 +74,61 @@ class ApplicationDeposit: field_dict.update(self.additional_properties) field_dict.update( { - "uuid": uuid, "payer_id": payer_id, "payer_type": payer_type, "payee_id": payee_id, + "payee_type": payee_type, "created_at": created_at, "state": state, "amount": amount, "updated_at": updated_at, } ) - if payee_type is not UNSET: - field_dict["payee_type"] = payee_type + 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: dict[str, Any]) -> T: - d = src_dict.copy() - uuid = UUID(d.pop("uuid")) + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + payer_id = d.pop("payer_id") - def _parse_payer_id(data: object) -> Union[None, UUID]: - if data is None: - return data - try: - if not isinstance(data, str): - raise TypeError() - payer_id_type_0 = UUID(data) - - return payer_id_type_0 - except: # noqa: E722 - pass - return cast(Union[None, UUID], data) - - payer_id = _parse_payer_id(d.pop("payer_id")) - - def _parse_payer_type(data: object) -> Union[None, PayerTypeEnum]: - if data is None: - return data - try: - if not isinstance(data, int): - raise TypeError() - payer_type_type_0 = PayerTypeEnum(data) - - return payer_type_type_0 - except: # noqa: E722 - pass - return cast(Union[None, PayerTypeEnum], data) - - payer_type = _parse_payer_type(d.pop("payer_type")) + payer_type = d.pop("payer_type") payee_id = UUID(d.pop("payee_id")) - def _parse_created_at(data: object) -> Union[None, datetime.datetime]: - if data is None: - return data - try: - if not isinstance(data, str): - raise TypeError() - created_at_type_0 = isoparse(data) + payee_type = d.pop("payee_type") - return created_at_type_0 - except: # noqa: E722 - pass - return cast(Union[None, datetime.datetime], data) - - created_at = _parse_created_at(d.pop("created_at")) + created_at = isoparse(d.pop("created_at")) state = StateEnum(d.pop("state")) amount = d.pop("amount") - def _parse_updated_at(data: object) -> Union[None, datetime.datetime]: - if data is None: - return data - try: - if not isinstance(data, str): - raise TypeError() - updated_at_type_0 = isoparse(data) + updated_at = isoparse(d.pop("updated_at")) - return updated_at_type_0 - except: # noqa: E722 - pass - return cast(Union[None, datetime.datetime], data) - - updated_at = _parse_updated_at(d.pop("updated_at")) - - def _parse_payee_type(data: object) -> Union[None, PayeeTypeEnum, Unset]: - if data is None: - return data - if isinstance(data, Unset): - return data - try: - if not isinstance(data, int): - raise TypeError() - payee_type_type_0 = PayeeTypeEnum(data) - - return payee_type_type_0 - except: # noqa: E722 - pass - return cast(Union[None, PayeeTypeEnum, Unset], data) - - payee_type = _parse_payee_type(d.pop("payee_type", UNSET)) + _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( - uuid=uuid, payer_id=payer_id, payer_type=payer_type, payee_id=payee_id, + payee_type=payee_type, created_at=created_at, state=state, amount=amount, updated_at=updated_at, - payee_type=payee_type, + uuid=uuid, details=details, ) diff --git a/gooyal_wallet_client/models/application_transaction.py b/gooyal_wallet_client/models/application_transaction.py index 0bd6ab3..f504cbc 100644 --- a/gooyal_wallet_client/models/application_transaction.py +++ b/gooyal_wallet_client/models/application_transaction.py @@ -1,12 +1,12 @@ import datetime -from typing import Any, TypeVar, Union, cast +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.payer_type_enum import PayerTypeEnum from ..models.state_enum import StateEnum from ..types import UNSET, Unset @@ -18,9 +18,11 @@ class ApplicationTransaction: """ Attributes: uuid (UUID): + payer_id (str): + payer_type (str): payee_id (UUID): payee_type (UUID): - created_at (Union[None, datetime.datetime]): + created_at (datetime.datetime): state (StateEnum): * `1` - created * `2` - delayed * `3` - pending @@ -29,71 +31,49 @@ class ApplicationTransaction: * `6` - failed * `7` - expected_failure amount (int): - updated_at (Union[None, datetime.datetime]): + updated_at (datetime.datetime): details (Any): role (str): - payer_id (Union[None, UUID, Unset]): - payer_type (Union[None, PayerTypeEnum, Unset]): delay (Union[Unset, int]): """ uuid: UUID + payer_id: str + payer_type: str payee_id: UUID payee_type: UUID - created_at: Union[None, datetime.datetime] + created_at: datetime.datetime state: StateEnum amount: int - updated_at: Union[None, datetime.datetime] + updated_at: datetime.datetime details: Any role: str - payer_id: Union[None, UUID, Unset] = UNSET - payer_type: Union[None, PayerTypeEnum, Unset] = UNSET 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_id = self.payer_id + + payer_type = self.payer_type + payee_id = str(self.payee_id) payee_type = str(self.payee_type) - created_at: Union[None, str] - if isinstance(self.created_at, datetime.datetime): - created_at = self.created_at.isoformat() - else: - created_at = self.created_at + created_at = self.created_at.isoformat() state = self.state.value amount = self.amount - updated_at: Union[None, str] - if isinstance(self.updated_at, datetime.datetime): - updated_at = self.updated_at.isoformat() - else: - updated_at = self.updated_at + updated_at = self.updated_at.isoformat() details = self.details role = self.role - payer_id: Union[None, Unset, str] - if isinstance(self.payer_id, Unset): - payer_id = UNSET - elif isinstance(self.payer_id, UUID): - payer_id = str(self.payer_id) - else: - payer_id = self.payer_id - - payer_type: Union[None, Unset, int] - if isinstance(self.payer_type, Unset): - payer_type = UNSET - elif isinstance(self.payer_type, PayerTypeEnum): - payer_type = self.payer_type.value - else: - payer_type = self.payer_type - delay = self.delay field_dict: dict[str, Any] = {} @@ -101,6 +81,8 @@ class ApplicationTransaction: field_dict.update( { "uuid": uuid, + "payer_id": payer_id, + "payer_type": payer_type, "payee_id": payee_id, "payee_type": payee_type, "created_at": created_at, @@ -111,100 +93,42 @@ class ApplicationTransaction: "role": role, } ) - if payer_id is not UNSET: - field_dict["payer_id"] = payer_id - if payer_type is not UNSET: - field_dict["payer_type"] = payer_type if delay is not UNSET: field_dict["delay"] = delay return field_dict @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) uuid = UUID(d.pop("uuid")) + payer_id = d.pop("payer_id") + + payer_type = d.pop("payer_type") + payee_id = UUID(d.pop("payee_id")) payee_type = UUID(d.pop("payee_type")) - def _parse_created_at(data: object) -> Union[None, datetime.datetime]: - if data is None: - return data - try: - if not isinstance(data, str): - raise TypeError() - created_at_type_0 = isoparse(data) - - return created_at_type_0 - except: # noqa: E722 - pass - return cast(Union[None, datetime.datetime], data) - - created_at = _parse_created_at(d.pop("created_at")) + created_at = isoparse(d.pop("created_at")) state = StateEnum(d.pop("state")) amount = d.pop("amount") - def _parse_updated_at(data: object) -> Union[None, datetime.datetime]: - if data is None: - return data - try: - if not isinstance(data, str): - raise TypeError() - updated_at_type_0 = isoparse(data) - - return updated_at_type_0 - except: # noqa: E722 - pass - return cast(Union[None, datetime.datetime], data) - - updated_at = _parse_updated_at(d.pop("updated_at")) + updated_at = isoparse(d.pop("updated_at")) details = d.pop("details") role = d.pop("role") - def _parse_payer_id(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() - payer_id_type_0 = UUID(data) - - return payer_id_type_0 - except: # noqa: E722 - pass - return cast(Union[None, UUID, Unset], data) - - payer_id = _parse_payer_id(d.pop("payer_id", UNSET)) - - def _parse_payer_type(data: object) -> Union[None, PayerTypeEnum, Unset]: - if data is None: - return data - if isinstance(data, Unset): - return data - try: - if not isinstance(data, int): - raise TypeError() - payer_type_type_0 = PayerTypeEnum(data) - - return payer_type_type_0 - except: # noqa: E722 - pass - return cast(Union[None, PayerTypeEnum, Unset], data) - - payer_type = _parse_payer_type(d.pop("payer_type", UNSET)) - delay = d.pop("delay", UNSET) application_transaction = cls( uuid=uuid, + payer_id=payer_id, + payer_type=payer_type, payee_id=payee_id, payee_type=payee_type, created_at=created_at, @@ -213,8 +137,6 @@ class ApplicationTransaction: updated_at=updated_at, details=details, role=role, - payer_id=payer_id, - payer_type=payer_type, delay=delay, ) diff --git a/gooyal_wallet_client/models/application_withdraw.py b/gooyal_wallet_client/models/application_withdraw.py index cd473a2..3470f5a 100644 --- a/gooyal_wallet_client/models/application_withdraw.py +++ b/gooyal_wallet_client/models/application_withdraw.py @@ -1,13 +1,12 @@ import datetime -from typing import Any, TypeVar, Union, cast +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.payee_type_enum import PayeeTypeEnum -from ..models.payer_type_enum import PayerTypeEnum from ..models.state_enum import StateEnum from ..types import UNSET, Unset @@ -18,10 +17,11 @@ T = TypeVar("T", bound="ApplicationWithdraw") class ApplicationWithdraw: """ Attributes: - uuid (UUID): - payee_id (UUID): - payee_type (Union[None, PayeeTypeEnum]): - created_at (Union[None, datetime.datetime]): + payer_id (UUID): + payer_type (int): + payee_id (str): + payee_type (str): + created_at (datetime.datetime): state (StateEnum): * `1` - created * `2` - delayed * `3` - pending @@ -30,193 +30,106 @@ class ApplicationWithdraw: * `6` - failed * `7` - expected_failure amount (int): - updated_at (Union[None, datetime.datetime]): - details (Any): - payer_id (Union[None, UUID, Unset]): - payer_type (Union[None, PayerTypeEnum, Unset]): + updated_at (datetime.datetime): + uuid (Union[Unset, UUID]): + details (Union[Unset, Any]): """ - uuid: UUID - payee_id: UUID - payee_type: Union[None, PayeeTypeEnum] - created_at: Union[None, datetime.datetime] + payer_id: UUID + payer_type: int + payee_id: str + payee_type: str + created_at: datetime.datetime state: StateEnum amount: int - updated_at: Union[None, datetime.datetime] - details: Any - payer_id: Union[None, UUID, Unset] = UNSET - payer_type: Union[None, PayerTypeEnum, Unset] = UNSET + 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]: - uuid = str(self.uuid) + payer_id = str(self.payer_id) - payee_id = str(self.payee_id) + payer_type = self.payer_type - payee_type: Union[None, int] - if isinstance(self.payee_type, PayeeTypeEnum): - payee_type = self.payee_type.value - else: - payee_type = self.payee_type + payee_id = self.payee_id - created_at: Union[None, str] - if isinstance(self.created_at, datetime.datetime): - created_at = self.created_at.isoformat() - else: - created_at = self.created_at + payee_type = self.payee_type + + created_at = self.created_at.isoformat() state = self.state.value amount = self.amount - updated_at: Union[None, str] - if isinstance(self.updated_at, datetime.datetime): - updated_at = self.updated_at.isoformat() - else: - updated_at = self.updated_at + updated_at = self.updated_at.isoformat() + + uuid: Union[Unset, str] = UNSET + if not isinstance(self.uuid, Unset): + uuid = str(self.uuid) details = self.details - payer_id: Union[None, Unset, str] - if isinstance(self.payer_id, Unset): - payer_id = UNSET - elif isinstance(self.payer_id, UUID): - payer_id = str(self.payer_id) - else: - payer_id = self.payer_id - - payer_type: Union[None, Unset, int] - if isinstance(self.payer_type, Unset): - payer_type = UNSET - elif isinstance(self.payer_type, PayerTypeEnum): - payer_type = self.payer_type.value - else: - payer_type = self.payer_type - field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { - "uuid": uuid, + "payer_id": payer_id, + "payer_type": payer_type, "payee_id": payee_id, "payee_type": payee_type, "created_at": created_at, "state": state, "amount": amount, "updated_at": updated_at, - "details": details, } ) - if payer_id is not UNSET: - field_dict["payer_id"] = payer_id - if payer_type is not UNSET: - field_dict["payer_type"] = payer_type + 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: dict[str, Any]) -> T: - d = src_dict.copy() - uuid = UUID(d.pop("uuid")) + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) + payer_id = UUID(d.pop("payer_id")) - payee_id = UUID(d.pop("payee_id")) + payer_type = d.pop("payer_type") - def _parse_payee_type(data: object) -> Union[None, PayeeTypeEnum]: - if data is None: - return data - try: - if not isinstance(data, int): - raise TypeError() - payee_type_type_0 = PayeeTypeEnum(data) + payee_id = d.pop("payee_id") - return payee_type_type_0 - except: # noqa: E722 - pass - return cast(Union[None, PayeeTypeEnum], data) + payee_type = d.pop("payee_type") - payee_type = _parse_payee_type(d.pop("payee_type")) - - def _parse_created_at(data: object) -> Union[None, datetime.datetime]: - if data is None: - return data - try: - if not isinstance(data, str): - raise TypeError() - created_at_type_0 = isoparse(data) - - return created_at_type_0 - except: # noqa: E722 - pass - return cast(Union[None, datetime.datetime], data) - - created_at = _parse_created_at(d.pop("created_at")) + created_at = isoparse(d.pop("created_at")) state = StateEnum(d.pop("state")) amount = d.pop("amount") - def _parse_updated_at(data: object) -> Union[None, datetime.datetime]: - if data is None: - return data - try: - if not isinstance(data, str): - raise TypeError() - updated_at_type_0 = isoparse(data) + updated_at = isoparse(d.pop("updated_at")) - return updated_at_type_0 - except: # noqa: E722 - pass - return cast(Union[None, datetime.datetime], data) + _uuid = d.pop("uuid", UNSET) + uuid: Union[Unset, UUID] + if isinstance(_uuid, Unset): + uuid = UNSET + else: + uuid = UUID(_uuid) - updated_at = _parse_updated_at(d.pop("updated_at")) - - details = d.pop("details") - - def _parse_payer_id(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() - payer_id_type_0 = UUID(data) - - return payer_id_type_0 - except: # noqa: E722 - pass - return cast(Union[None, UUID, Unset], data) - - payer_id = _parse_payer_id(d.pop("payer_id", UNSET)) - - def _parse_payer_type(data: object) -> Union[None, PayerTypeEnum, Unset]: - if data is None: - return data - if isinstance(data, Unset): - return data - try: - if not isinstance(data, int): - raise TypeError() - payer_type_type_0 = PayerTypeEnum(data) - - return payer_type_type_0 - except: # noqa: E722 - pass - return cast(Union[None, PayerTypeEnum, Unset], data) - - payer_type = _parse_payer_type(d.pop("payer_type", UNSET)) + details = d.pop("details", UNSET) application_withdraw = cls( - uuid=uuid, + payer_id=payer_id, + payer_type=payer_type, payee_id=payee_id, payee_type=payee_type, created_at=created_at, state=state, amount=amount, updated_at=updated_at, + uuid=uuid, details=details, - payer_id=payer_id, - payer_type=payer_type, ) application_withdraw.additional_properties = d diff --git a/gooyal_wallet_client/models/charge.py b/gooyal_wallet_client/models/charge.py new file mode 100644 index 0000000..25301fb --- /dev/null +++ b/gooyal_wallet_client/models/charge.py @@ -0,0 +1,150 @@ +import datetime +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 dateutil.parser import isoparse + +from ..models.state_enum import StateEnum + +T = TypeVar("T", bound="Charge") + + +@_attrs_define +class Charge: + """ + Attributes: + uuid (UUID): + user (UUID): + created_at (Union[None, datetime.datetime]): + state (StateEnum): * `1` - created + * `2` - delayed + * `3` - pending + * `4` - incomplete + * `5` - success + * `6` - failed + * `7` - expected_failure + amount (Union[None, int]): + updated_at (Union[None, datetime.datetime]): + """ + + uuid: UUID + user: UUID + created_at: Union[None, datetime.datetime] + state: StateEnum + amount: Union[None, int] + updated_at: Union[None, datetime.datetime] + additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) + + def to_dict(self) -> dict[str, Any]: + uuid = str(self.uuid) + + user = str(self.user) + + created_at: Union[None, str] + if isinstance(self.created_at, datetime.datetime): + created_at = self.created_at.isoformat() + else: + created_at = self.created_at + + state = self.state.value + + amount: Union[None, int] + amount = self.amount + + updated_at: Union[None, str] + if isinstance(self.updated_at, datetime.datetime): + updated_at = self.updated_at.isoformat() + else: + updated_at = self.updated_at + + field_dict: dict[str, Any] = {} + field_dict.update(self.additional_properties) + field_dict.update( + { + "uuid": uuid, + "user": user, + "created_at": created_at, + "state": state, + "amount": amount, + "updated_at": updated_at, + } + ) + + 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")) + + user = UUID(d.pop("user")) + + def _parse_created_at(data: object) -> Union[None, datetime.datetime]: + if data is None: + return data + try: + if not isinstance(data, str): + raise TypeError() + created_at_type_0 = isoparse(data) + + return created_at_type_0 + except: # noqa: E722 + pass + return cast(Union[None, datetime.datetime], data) + + created_at = _parse_created_at(d.pop("created_at")) + + state = StateEnum(d.pop("state")) + + def _parse_amount(data: object) -> Union[None, int]: + if data is None: + return data + return cast(Union[None, int], data) + + amount = _parse_amount(d.pop("amount")) + + def _parse_updated_at(data: object) -> Union[None, datetime.datetime]: + if data is None: + return data + try: + if not isinstance(data, str): + raise TypeError() + updated_at_type_0 = isoparse(data) + + return updated_at_type_0 + except: # noqa: E722 + pass + return cast(Union[None, datetime.datetime], data) + + updated_at = _parse_updated_at(d.pop("updated_at")) + + charge = cls( + uuid=uuid, + user=user, + created_at=created_at, + state=state, + amount=amount, + updated_at=updated_at, + ) + + charge.additional_properties = d + return charge + + @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 diff --git a/gooyal_wallet_client/models/my_wallet.py b/gooyal_wallet_client/models/my_wallet.py index 16f9ade..e76505d 100644 --- a/gooyal_wallet_client/models/my_wallet.py +++ b/gooyal_wallet_client/models/my_wallet.py @@ -1,3 +1,4 @@ +from collections.abc import Mapping from typing import Any, TypeVar, Union from attrs import define as _attrs_define @@ -30,8 +31,8 @@ class MyWallet: return field_dict @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) balance = d.pop("balance", UNSET) my_wallet = cls( diff --git a/gooyal_wallet_client/models/paginated_application_transaction_list.py b/gooyal_wallet_client/models/paginated_application_transaction_list.py index 2854f85..f72973d 100644 --- a/gooyal_wallet_client/models/paginated_application_transaction_list.py +++ b/gooyal_wallet_client/models/paginated_application_transaction_list.py @@ -1,3 +1,4 @@ +from collections.abc import Mapping from typing import TYPE_CHECKING, Any, TypeVar, Union, cast from attrs import define as _attrs_define @@ -18,8 +19,8 @@ class PaginatedApplicationTransactionList: Attributes: count (int): Example: 123. results (list['ApplicationTransaction']): - next_ (Union[None, Unset, str]): Example: http://api.example.org/accounts/?page=4. - previous (Union[None, Unset, str]): Example: http://api.example.org/accounts/?page=2. + 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 @@ -64,10 +65,10 @@ class PaginatedApplicationTransactionList: return field_dict @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: from ..models.application_transaction import ApplicationTransaction - d = src_dict.copy() + d = dict(src_dict) count = d.pop("count") results = [] diff --git a/gooyal_wallet_client/models/paginated_user_transaction_list.py b/gooyal_wallet_client/models/paginated_user_transaction_list.py index 631893f..fb90457 100644 --- a/gooyal_wallet_client/models/paginated_user_transaction_list.py +++ b/gooyal_wallet_client/models/paginated_user_transaction_list.py @@ -1,3 +1,4 @@ +from collections.abc import Mapping from typing import TYPE_CHECKING, Any, TypeVar, Union, cast from attrs import define as _attrs_define @@ -18,8 +19,8 @@ class PaginatedUserTransactionList: Attributes: count (int): Example: 123. results (list['UserTransaction']): - next_ (Union[None, Unset, str]): Example: http://api.example.org/accounts/?page=4. - previous (Union[None, Unset, str]): Example: http://api.example.org/accounts/?page=2. + 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 @@ -64,10 +65,10 @@ class PaginatedUserTransactionList: return field_dict @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: from ..models.user_transaction import UserTransaction - d = src_dict.copy() + d = dict(src_dict) count = d.pop("count") results = [] diff --git a/gooyal_wallet_client/models/payee_type_enum.py b/gooyal_wallet_client/models/payee_type_enum.py deleted file mode 100644 index 2d56dd5..0000000 --- a/gooyal_wallet_client/models/payee_type_enum.py +++ /dev/null @@ -1,9 +0,0 @@ -from enum import IntEnum - - -class PayeeTypeEnum(IntEnum): - VALUE_1 = 1 - VALUE_2 = 2 - - def __str__(self) -> str: - return str(self.value) diff --git a/gooyal_wallet_client/models/payer_type_enum.py b/gooyal_wallet_client/models/payer_type_enum.py deleted file mode 100644 index f49196c..0000000 --- a/gooyal_wallet_client/models/payer_type_enum.py +++ /dev/null @@ -1,9 +0,0 @@ -from enum import IntEnum - - -class PayerTypeEnum(IntEnum): - VALUE_1 = 1 - VALUE_2 = 2 - - def __str__(self) -> str: - return str(self.value) diff --git a/gooyal_wallet_client/models/user_transaction.py b/gooyal_wallet_client/models/user_transaction.py index fcc64cf..5b2a0a1 100644 --- a/gooyal_wallet_client/models/user_transaction.py +++ b/gooyal_wallet_client/models/user_transaction.py @@ -1,12 +1,12 @@ import datetime -from typing import Any, TypeVar, Union, cast +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.payer_type_enum import PayerTypeEnum from ..models.state_enum import StateEnum from ..types import UNSET, Unset @@ -18,9 +18,11 @@ class UserTransaction: """ Attributes: uuid (UUID): + payer_id (str): + payer_type (str): payee_id (UUID): payee_type (UUID): - created_at (Union[None, datetime.datetime]): + created_at (datetime.datetime): state (StateEnum): * `1` - created * `2` - delayed * `3` - pending @@ -29,71 +31,49 @@ class UserTransaction: * `6` - failed * `7` - expected_failure amount (int): - updated_at (Union[None, datetime.datetime]): + updated_at (datetime.datetime): details (Any): role (int): - payer_id (Union[None, UUID, Unset]): - payer_type (Union[None, PayerTypeEnum, Unset]): delay (Union[Unset, int]): """ uuid: UUID + payer_id: str + payer_type: str payee_id: UUID payee_type: UUID - created_at: Union[None, datetime.datetime] + created_at: datetime.datetime state: StateEnum amount: int - updated_at: Union[None, datetime.datetime] + updated_at: datetime.datetime details: Any role: int - payer_id: Union[None, UUID, Unset] = UNSET - payer_type: Union[None, PayerTypeEnum, Unset] = UNSET 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_id = self.payer_id + + payer_type = self.payer_type + payee_id = str(self.payee_id) payee_type = str(self.payee_type) - created_at: Union[None, str] - if isinstance(self.created_at, datetime.datetime): - created_at = self.created_at.isoformat() - else: - created_at = self.created_at + created_at = self.created_at.isoformat() state = self.state.value amount = self.amount - updated_at: Union[None, str] - if isinstance(self.updated_at, datetime.datetime): - updated_at = self.updated_at.isoformat() - else: - updated_at = self.updated_at + updated_at = self.updated_at.isoformat() details = self.details role = self.role - payer_id: Union[None, Unset, str] - if isinstance(self.payer_id, Unset): - payer_id = UNSET - elif isinstance(self.payer_id, UUID): - payer_id = str(self.payer_id) - else: - payer_id = self.payer_id - - payer_type: Union[None, Unset, int] - if isinstance(self.payer_type, Unset): - payer_type = UNSET - elif isinstance(self.payer_type, PayerTypeEnum): - payer_type = self.payer_type.value - else: - payer_type = self.payer_type - delay = self.delay field_dict: dict[str, Any] = {} @@ -101,6 +81,8 @@ class UserTransaction: field_dict.update( { "uuid": uuid, + "payer_id": payer_id, + "payer_type": payer_type, "payee_id": payee_id, "payee_type": payee_type, "created_at": created_at, @@ -111,100 +93,42 @@ class UserTransaction: "role": role, } ) - if payer_id is not UNSET: - field_dict["payer_id"] = payer_id - if payer_type is not UNSET: - field_dict["payer_type"] = payer_type if delay is not UNSET: field_dict["delay"] = delay return field_dict @classmethod - def from_dict(cls: type[T], src_dict: dict[str, Any]) -> T: - d = src_dict.copy() + def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T: + d = dict(src_dict) uuid = UUID(d.pop("uuid")) + payer_id = d.pop("payer_id") + + payer_type = d.pop("payer_type") + payee_id = UUID(d.pop("payee_id")) payee_type = UUID(d.pop("payee_type")) - def _parse_created_at(data: object) -> Union[None, datetime.datetime]: - if data is None: - return data - try: - if not isinstance(data, str): - raise TypeError() - created_at_type_0 = isoparse(data) - - return created_at_type_0 - except: # noqa: E722 - pass - return cast(Union[None, datetime.datetime], data) - - created_at = _parse_created_at(d.pop("created_at")) + created_at = isoparse(d.pop("created_at")) state = StateEnum(d.pop("state")) amount = d.pop("amount") - def _parse_updated_at(data: object) -> Union[None, datetime.datetime]: - if data is None: - return data - try: - if not isinstance(data, str): - raise TypeError() - updated_at_type_0 = isoparse(data) - - return updated_at_type_0 - except: # noqa: E722 - pass - return cast(Union[None, datetime.datetime], data) - - updated_at = _parse_updated_at(d.pop("updated_at")) + updated_at = isoparse(d.pop("updated_at")) details = d.pop("details") role = d.pop("role") - def _parse_payer_id(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() - payer_id_type_0 = UUID(data) - - return payer_id_type_0 - except: # noqa: E722 - pass - return cast(Union[None, UUID, Unset], data) - - payer_id = _parse_payer_id(d.pop("payer_id", UNSET)) - - def _parse_payer_type(data: object) -> Union[None, PayerTypeEnum, Unset]: - if data is None: - return data - if isinstance(data, Unset): - return data - try: - if not isinstance(data, int): - raise TypeError() - payer_type_type_0 = PayerTypeEnum(data) - - return payer_type_type_0 - except: # noqa: E722 - pass - return cast(Union[None, PayerTypeEnum, Unset], data) - - payer_type = _parse_payer_type(d.pop("payer_type", UNSET)) - delay = d.pop("delay", UNSET) user_transaction = cls( uuid=uuid, + payer_id=payer_id, + payer_type=payer_type, payee_id=payee_id, payee_type=payee_type, created_at=created_at, @@ -213,8 +137,6 @@ class UserTransaction: updated_at=updated_at, details=details, role=role, - payer_id=payer_id, - payer_type=payer_type, delay=delay, ) diff --git a/gooyal_wallet_client/types.py b/gooyal_wallet_client/types.py index b9ed58b..1b96ca4 100644 --- a/gooyal_wallet_client/types.py +++ b/gooyal_wallet_client/types.py @@ -1,8 +1,8 @@ """Contains some shared types for properties""" -from collections.abc import MutableMapping +from collections.abc import Mapping, MutableMapping from http import HTTPStatus -from typing import BinaryIO, Generic, Literal, Optional, TypeVar +from typing import IO, BinaryIO, Generic, Literal, Optional, TypeVar, Union from attrs import define @@ -14,7 +14,15 @@ class Unset: UNSET: Unset = Unset() -FileJsonType = tuple[Optional[str], BinaryIO, Optional[str]] +# 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 @@ -25,7 +33,7 @@ class File: file_name: Optional[str] = None mime_type: Optional[str] = None - def to_tuple(self) -> FileJsonType: + 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 @@ -43,4 +51,4 @@ class Response(Generic[T]): parsed: Optional[T] -__all__ = ["UNSET", "File", "FileJsonType", "Response", "Unset"] +__all__ = ["UNSET", "File", "FileTypes", "RequestFiles", "Response", "Unset"] diff --git a/main/settings.py b/main/settings.py index 4a5e9a1..16c1f02 100644 --- a/main/settings.py +++ b/main/settings.py @@ -255,4 +255,5 @@ CACHES = { PNA_CORPORATION_PIN = config('PNA_CORPORATION_PIN') WALLET_BASE_PUBLIC_URL = config('WALLET_BASE_PUBLIC_URL') +WALLET_CATEGORY_UUID = config('WALLET_CATEGORY_UUID') IPG_BASE_PUBLIC_URL = config('IPG_BASE_PUBLIC_URL') diff --git a/utils/wallet_client.py b/utils/wallet_client.py index 0762eaa..729ae4b 100644 --- a/utils/wallet_client.py +++ b/utils/wallet_client.py @@ -8,8 +8,8 @@ from httpx import Request from gooyal_wallet_client import AuthenticatedClient from gooyal_wallet_client.models import MyWallet, UserTransaction, ApplicationDeposit, ApplicationWithdraw -from gooyal_wallet_client.api.wallet import (wallet_api_application_deposit_create, - wallet_api_application_deposit_verify_retrieve, +from gooyal_wallet_client.api.wallet import (wallet_api_application_deposit_create_2, + wallet_api_application_deposit_verify_retrieve_2, wallet_api_application_withdraw_create, wallet_api_application_withdraw_verify_retrieve) from gooyal_wallet_client.types import Response @@ -73,22 +73,24 @@ def get_client(): return client -def deposit_to_user_wallet_submit(data): +def deposit_to_user_wallet_submit(category_uuid, data): class Tmp(): def to_dict(self): return data deposit_data = Tmp() client = get_client() - response: ApplicationDeposit = wallet_api_application_deposit_create.sync(client=client, body=deposit_data) + response: ApplicationDeposit = wallet_api_application_deposit_create_2.sync(category_uuid= category_uuid, + client=client, + body=deposit_data) print(response) return response -def deposit_to_user_wallet_verify(uuid): +def deposit_to_user_wallet_verify(category_uuid, uuid): client = get_client() - response: ApplicationDeposit = wallet_api_application_deposit_verify_retrieve.sync(uuid=uuid, client=client) + response: ApplicationDeposit = wallet_api_application_deposit_verify_retrieve_2.sync(category_uuid=category_uuid, uuid=uuid, client=client) print(response) return response