Compare commits
10 commits
a8b32a16f4
...
fb4c79c5c6
| Author | SHA1 | Date | |
|---|---|---|---|
| fb4c79c5c6 | |||
| 5b278bddd2 | |||
| 8328814dca | |||
| 5d897b0917 | |||
| 5eff037d10 | |||
|
|
d9b7dbe1b2 | ||
|
|
e6eafbd6dc | ||
| 2d8e0da6fa | |||
| 7b1e9376b4 | |||
| 615a568294 |
37 changed files with 1007 additions and 71 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -5,3 +5,4 @@ utils/delme.py
|
|||
*.pyc
|
||||
.env
|
||||
/venv/
|
||||
/.venv/
|
||||
|
|
|
|||
14
Dockerfile
14
Dockerfile
|
|
@ -1,8 +1,12 @@
|
|||
FROM debian:13
|
||||
FROM base:debian13
|
||||
ENV PYTHONUNBUFFERED 1
|
||||
WORKDIR /app
|
||||
RUN apt update
|
||||
RUN apt install gnupg2 netcat-traditional libssl-dev libcrypto++-dev lsb-release python3-pip nano htop iputils-ping -y
|
||||
COPY requirements.txt /app/requirements.txt
|
||||
RUN pip3 install --break-system-packages -r requirements.txt
|
||||
#RUN date
|
||||
#RUN apt update
|
||||
#RUN apt install gnupg2 netcat-traditional libssl-dev libcrypto++-dev lsb-release python3-pip -y
|
||||
#RUN apt install binutils libproj-dev gdal-bin -y
|
||||
#COPY requirements.txt /app/requirements.txt
|
||||
#RUN pip3 install --break-system-packages -r requirements.txt
|
||||
#RUN pip3 install --break-system-packages django-admin-rangefilter==0.13.5
|
||||
#RUN pip3 install --break-system-packages setuptools
|
||||
#ENTRYPOINT ["./run.sh"]
|
||||
|
|
|
|||
|
|
@ -1,15 +1,107 @@
|
|||
from django.contrib import admin
|
||||
from .models import Transaction, Account, Wallet
|
||||
from django.http import HttpResponse
|
||||
import io
|
||||
import xlsxwriter
|
||||
import jdatetime
|
||||
from django.utils import timezone
|
||||
from rangefilter.filters import DateTimeRangeFilter
|
||||
# from utils.accounts_client import get_user_detailed_info
|
||||
|
||||
@admin.action(description="export excel")
|
||||
def export_excel(modeladmin, request, queryset):
|
||||
output = io.BytesIO()
|
||||
workbook = xlsxwriter.Workbook(output)
|
||||
worksheet = workbook.add_worksheet()
|
||||
|
||||
for col, header in enumerate(['uuid',
|
||||
'application',
|
||||
'amount',
|
||||
'jalali_datetime',
|
||||
'payer',
|
||||
'payer_type',
|
||||
'payee',
|
||||
'payee_type',
|
||||
'state',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'details',
|
||||
]):
|
||||
worksheet.write(0, col, header)
|
||||
|
||||
for row, tranaction in enumerate(queryset, 1):
|
||||
worksheet.write(row, 0, str(tranaction.uuid))
|
||||
worksheet.write(row, 1, str(tranaction.application))
|
||||
worksheet.write(row, 2, tranaction.amount)
|
||||
worksheet.write(row, 3, str(tranaction.jalali_datetime))
|
||||
worksheet.write(row, 4, str(tranaction.payer))
|
||||
worksheet.write(row, 5, str(tranaction.payer_type))
|
||||
worksheet.write(row, 6, str(tranaction.payee))
|
||||
worksheet.write(row, 7, str(tranaction.payee_type))
|
||||
worksheet.write(row, 8, str(tranaction.state))
|
||||
worksheet.write(row, 9, str(tranaction.created_at))
|
||||
worksheet.write(row, 10, str(tranaction.updated_at))
|
||||
worksheet.write(row, 11, str(tranaction.details))
|
||||
workbook.close()
|
||||
|
||||
# create a response
|
||||
response = HttpResponse(content_type='application/vnd.ms-excel')
|
||||
|
||||
# tell the browser what the file is named
|
||||
file_name = jdatetime.date.fromgregorian(date=timezone.now(), locale='fa_IR').strftime("%Y/%m/%d")
|
||||
response['Content-Disposition'] = f'attachment;filename="{file_name}.xlsx"'
|
||||
|
||||
# put the spreadsheet data into the response
|
||||
response.write(output.getvalue())
|
||||
|
||||
# return the response
|
||||
return response
|
||||
|
||||
@admin.action(description="export excel")
|
||||
def export_accounts_as_excel(modeladmin, request, queryset):
|
||||
output = io.BytesIO()
|
||||
workbook = xlsxwriter.Workbook(output)
|
||||
worksheet = workbook.add_worksheet()
|
||||
for col, header in enumerate(['uuid',
|
||||
'owner_uuid',
|
||||
'owner_type',
|
||||
'wallet',
|
||||
'balance',
|
||||
]):
|
||||
worksheet.write(0, col, header)
|
||||
|
||||
for row, account in enumerate(queryset, 1):
|
||||
worksheet.write(row, 0, str(account.uuid))
|
||||
worksheet.write(row, 1, str(account.owner_uuid))
|
||||
worksheet.write(row, 2, account.owner_type)
|
||||
worksheet.write(row, 3, str(account.wallet))
|
||||
worksheet.write(row, 4, str(account.balance))
|
||||
workbook.close()
|
||||
|
||||
# create a response
|
||||
response = HttpResponse(content_type='application/vnd.ms-excel')
|
||||
|
||||
# tell the browser what the file is named
|
||||
file_name = jdatetime.date.fromgregorian(date=timezone.now(), locale='fa_IR').strftime("%Y/%m/%d")
|
||||
response['Content-Disposition'] = f'attachment;filename="{file_name}.xlsx"'
|
||||
|
||||
# put the spreadsheet data into the response
|
||||
response.write(output.getvalue())
|
||||
|
||||
# return the response
|
||||
return response
|
||||
|
||||
class TransactionAdmin(admin.ModelAdmin):
|
||||
list_display = ['uuid', 'amount', 'created_at', 'updated_at', 'payer', 'payer_type', 'payee', 'payee_type', 'state', 'application']
|
||||
list_display = ['uuid', 'application', 'splited_amount', 'jalali_datetime', 'payer', 'payer_type', 'payee', 'payee_type', 'state', 'amount', 'created_at', 'updated_at']
|
||||
search_fields = ['uuid', 'created_at', 'updated_at', 'payer_account__owner_uuid', 'payee_account__owner_uuid', 'application__uuid']
|
||||
list_filter = ['state']
|
||||
list_filter = ['application', 'state', ('created_at', DateTimeRangeFilter), ('updated_at', DateTimeRangeFilter),]
|
||||
actions = [export_excel]
|
||||
|
||||
class AccountAdmin(admin.ModelAdmin):
|
||||
list_display = ['uuid', 'owner_uuid', 'wallet', 'owner_type', 'balance', 'get_name']
|
||||
search_fields = ['uuid', 'owner_uuid']
|
||||
list_filter = ['wallet__label', 'owner_type']
|
||||
actions = [export_accounts_as_excel]
|
||||
|
||||
admin.site.register(Transaction, TransactionAdmin)
|
||||
admin.site.register(Account, AccountAdmin)
|
||||
|
|
|
|||
|
|
@ -9,8 +9,7 @@ from django.db.models import F
|
|||
from django.utils import timezone
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from collections import defaultdict
|
||||
from django.db.models import Count, Sum
|
||||
import jdatetime
|
||||
|
||||
from rest_framework.exceptions import APIException
|
||||
from django.conf import settings
|
||||
|
|
@ -182,6 +181,27 @@ class Transaction(BaseModel):
|
|||
|
||||
# unique_together = ('application', 'detail_id',)
|
||||
|
||||
@property
|
||||
def jalali_datetime(self):
|
||||
def to_jalali(value):
|
||||
if value:
|
||||
return jdatetime.datetime.fromgregorian(date=value, locale='fa_IR').strftime("%Y/%m/%d-%H:%M:%S")
|
||||
else:
|
||||
return value
|
||||
|
||||
return to_jalali(self.created_at)
|
||||
|
||||
@property
|
||||
def splited_amount(self):
|
||||
def amount_split_3digit(value):
|
||||
text = str(value)[::-1]
|
||||
return ','.join([l[::-1] for l in [text[i:i + 3] for i in range(0, len(text), 3)][::-1]])
|
||||
|
||||
if self.amount:
|
||||
amount_str = amount_split_3digit(str(self.amount))
|
||||
return amount_str
|
||||
return
|
||||
|
||||
def get_payer(self):
|
||||
return self.payer_account.get_owner()
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
"""Contains endpoint functions for accessing the API"""
|
||||
|
|
@ -0,0 +1 @@
|
|||
"""Contains endpoint functions for accessing the API"""
|
||||
151
gooyal_accounts_client/api/users/users_api_inquiry_create.py
Normal file
151
gooyal_accounts_client/api/users/users_api_inquiry_create.py
Normal file
|
|
@ -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.user_inquiry import UserInquiry
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
*,
|
||||
body: UserInquiry,
|
||||
) -> dict[str, Any]:
|
||||
headers: dict[str, Any] = {}
|
||||
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "post",
|
||||
"url": "/users/api/inquiry/",
|
||||
}
|
||||
|
||||
_body = body.to_dict()
|
||||
|
||||
_kwargs["json"] = _body
|
||||
headers["Content-Type"] = "application/json"
|
||||
|
||||
_kwargs["headers"] = headers
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[UserInquiry]:
|
||||
if response.status_code == 201:
|
||||
response_201 = UserInquiry.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[UserInquiry]:
|
||||
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: UserInquiry,
|
||||
) -> Response[UserInquiry]:
|
||||
"""
|
||||
Args:
|
||||
body (UserInquiry):
|
||||
|
||||
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[UserInquiry]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
body=body,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: UserInquiry,
|
||||
) -> Optional[UserInquiry]:
|
||||
"""
|
||||
Args:
|
||||
body (UserInquiry):
|
||||
|
||||
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:
|
||||
UserInquiry
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
client=client,
|
||||
body=body,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
body: UserInquiry,
|
||||
) -> Response[UserInquiry]:
|
||||
"""
|
||||
Args:
|
||||
body (UserInquiry):
|
||||
|
||||
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[UserInquiry]
|
||||
"""
|
||||
|
||||
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: UserInquiry,
|
||||
) -> Optional[UserInquiry]:
|
||||
"""
|
||||
Args:
|
||||
body (UserInquiry):
|
||||
|
||||
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:
|
||||
UserInquiry
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
client=client,
|
||||
body=body,
|
||||
)
|
||||
).parsed
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
from http import HTTPStatus
|
||||
from typing import Any, Optional, Union
|
||||
from uuid import UUID
|
||||
|
||||
import httpx
|
||||
|
||||
from ... import errors
|
||||
from ...client import AuthenticatedClient, Client
|
||||
from ...models.account import Account
|
||||
from ...types import Response
|
||||
|
||||
|
||||
def _get_kwargs(
|
||||
uuid: UUID,
|
||||
) -> dict[str, Any]:
|
||||
_kwargs: dict[str, Any] = {
|
||||
"method": "get",
|
||||
"url": f"/users/api/users/{uuid}/details",
|
||||
}
|
||||
|
||||
return _kwargs
|
||||
|
||||
|
||||
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Account]:
|
||||
if response.status_code == 200:
|
||||
response_200 = Account.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[Account]:
|
||||
return Response(
|
||||
status_code=HTTPStatus(response.status_code),
|
||||
content=response.content,
|
||||
headers=response.headers,
|
||||
parsed=_parse_response(client=client, response=response),
|
||||
)
|
||||
|
||||
|
||||
def sync_detailed(
|
||||
uuid: UUID,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Account]:
|
||||
"""
|
||||
Args:
|
||||
uuid (UUID):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Account]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
uuid=uuid,
|
||||
)
|
||||
|
||||
response = client.get_httpx_client().request(
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
def sync(
|
||||
uuid: UUID,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Account]:
|
||||
"""
|
||||
Args:
|
||||
uuid (UUID):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Account
|
||||
"""
|
||||
|
||||
return sync_detailed(
|
||||
uuid=uuid,
|
||||
client=client,
|
||||
).parsed
|
||||
|
||||
|
||||
async def asyncio_detailed(
|
||||
uuid: UUID,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Response[Account]:
|
||||
"""
|
||||
Args:
|
||||
uuid (UUID):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Response[Account]
|
||||
"""
|
||||
|
||||
kwargs = _get_kwargs(
|
||||
uuid=uuid,
|
||||
)
|
||||
|
||||
response = await client.get_async_httpx_client().request(**kwargs)
|
||||
|
||||
return _build_response(client=client, response=response)
|
||||
|
||||
|
||||
async def asyncio(
|
||||
uuid: UUID,
|
||||
*,
|
||||
client: AuthenticatedClient,
|
||||
) -> Optional[Account]:
|
||||
"""
|
||||
Args:
|
||||
uuid (UUID):
|
||||
|
||||
Raises:
|
||||
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
|
||||
httpx.TimeoutException: If the request takes longer than Client.timeout.
|
||||
|
||||
Returns:
|
||||
Account
|
||||
"""
|
||||
|
||||
return (
|
||||
await asyncio_detailed(
|
||||
uuid=uuid,
|
||||
client=client,
|
||||
)
|
||||
).parsed
|
||||
|
|
@ -2,7 +2,10 @@
|
|||
|
||||
from .account import Account
|
||||
from .application import Application
|
||||
from .blank_enum import BlankEnum
|
||||
from .change_password import ChangePassword
|
||||
from .education_degree_enum import EducationDegreeEnum
|
||||
from .gender_enum import GenderEnum
|
||||
from .paginated_application_list import PaginatedApplicationList
|
||||
from .paginated_public_user_list import PaginatedPublicUserList
|
||||
from .patched_account import PatchedAccount
|
||||
|
|
@ -10,11 +13,15 @@ from .patched_change_password import PatchedChangePassword
|
|||
from .public_user import PublicUser
|
||||
from .request_otp import RequestOTP
|
||||
from .request_ott import RequestOTT
|
||||
from .user_inquiry import UserInquiry
|
||||
|
||||
__all__ = (
|
||||
"Account",
|
||||
"Application",
|
||||
"BlankEnum",
|
||||
"ChangePassword",
|
||||
"EducationDegreeEnum",
|
||||
"GenderEnum",
|
||||
"PaginatedApplicationList",
|
||||
"PaginatedPublicUserList",
|
||||
"PatchedAccount",
|
||||
|
|
@ -22,4 +29,5 @@ __all__ = (
|
|||
"PublicUser",
|
||||
"RequestOTP",
|
||||
"RequestOTT",
|
||||
"UserInquiry",
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,15 @@
|
|||
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.blank_enum import BlankEnum
|
||||
from ..models.education_degree_enum import EducationDegreeEnum
|
||||
from ..models.gender_enum import GenderEnum
|
||||
from ..types import UNSET, Unset
|
||||
|
||||
T = TypeVar("T", bound="Account")
|
||||
|
|
@ -24,6 +30,10 @@ class Account:
|
|||
last_name (Union[Unset, str]):
|
||||
name (Union[Unset, str]):
|
||||
avatar (Union[None, Unset, str]):
|
||||
gender (Union[BlankEnum, GenderEnum, None, Unset]):
|
||||
education_degree (Union[BlankEnum, EducationDegreeEnum, None, Unset]):
|
||||
education_field (Union[None, Unset, str]):
|
||||
birthdate (Union[None, Unset, datetime.date]):
|
||||
iban (Union[None, Unset, str]):
|
||||
province (Union[None, Unset, int]):
|
||||
city (Union[None, Unset, int]):
|
||||
|
|
@ -42,6 +52,10 @@ class Account:
|
|||
last_name: Union[Unset, str] = UNSET
|
||||
name: Union[Unset, str] = UNSET
|
||||
avatar: Union[None, Unset, str] = UNSET
|
||||
gender: Union[BlankEnum, GenderEnum, None, Unset] = UNSET
|
||||
education_degree: Union[BlankEnum, EducationDegreeEnum, None, Unset] = UNSET
|
||||
education_field: Union[None, Unset, str] = UNSET
|
||||
birthdate: Union[None, Unset, datetime.date] = UNSET
|
||||
iban: Union[None, Unset, str] = UNSET
|
||||
province: Union[None, Unset, int] = UNSET
|
||||
city: Union[None, Unset, int] = UNSET
|
||||
|
|
@ -81,6 +95,40 @@ class Account:
|
|||
else:
|
||||
avatar = self.avatar
|
||||
|
||||
gender: Union[None, Unset, str]
|
||||
if isinstance(self.gender, Unset):
|
||||
gender = UNSET
|
||||
elif isinstance(self.gender, GenderEnum):
|
||||
gender = self.gender.value
|
||||
elif isinstance(self.gender, BlankEnum):
|
||||
gender = self.gender.value
|
||||
else:
|
||||
gender = self.gender
|
||||
|
||||
education_degree: Union[None, Unset, str]
|
||||
if isinstance(self.education_degree, Unset):
|
||||
education_degree = UNSET
|
||||
elif isinstance(self.education_degree, EducationDegreeEnum):
|
||||
education_degree = self.education_degree.value
|
||||
elif isinstance(self.education_degree, BlankEnum):
|
||||
education_degree = self.education_degree.value
|
||||
else:
|
||||
education_degree = self.education_degree
|
||||
|
||||
education_field: Union[None, Unset, str]
|
||||
if isinstance(self.education_field, Unset):
|
||||
education_field = UNSET
|
||||
else:
|
||||
education_field = self.education_field
|
||||
|
||||
birthdate: Union[None, Unset, str]
|
||||
if isinstance(self.birthdate, Unset):
|
||||
birthdate = UNSET
|
||||
elif isinstance(self.birthdate, datetime.date):
|
||||
birthdate = self.birthdate.isoformat()
|
||||
else:
|
||||
birthdate = self.birthdate
|
||||
|
||||
iban: Union[None, Unset, str]
|
||||
if isinstance(self.iban, Unset):
|
||||
iban = UNSET
|
||||
|
|
@ -133,6 +181,14 @@ class Account:
|
|||
field_dict["name"] = name
|
||||
if avatar is not UNSET:
|
||||
field_dict["avatar"] = avatar
|
||||
if gender is not UNSET:
|
||||
field_dict["gender"] = gender
|
||||
if education_degree is not UNSET:
|
||||
field_dict["education_degree"] = education_degree
|
||||
if education_field is not UNSET:
|
||||
field_dict["education_field"] = education_field
|
||||
if birthdate is not UNSET:
|
||||
field_dict["birthdate"] = birthdate
|
||||
if iban is not UNSET:
|
||||
field_dict["iban"] = iban
|
||||
if province is not UNSET:
|
||||
|
|
@ -147,8 +203,8 @@ class Account:
|
|||
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"))
|
||||
|
||||
email = d.pop("email")
|
||||
|
|
@ -190,6 +246,82 @@ class Account:
|
|||
|
||||
avatar = _parse_avatar(d.pop("avatar", UNSET))
|
||||
|
||||
def _parse_gender(data: object) -> Union[BlankEnum, GenderEnum, None, Unset]:
|
||||
if data is None:
|
||||
return data
|
||||
if isinstance(data, Unset):
|
||||
return data
|
||||
try:
|
||||
if not isinstance(data, str):
|
||||
raise TypeError()
|
||||
gender_type_0 = GenderEnum(data)
|
||||
|
||||
return gender_type_0
|
||||
except: # noqa: E722
|
||||
pass
|
||||
try:
|
||||
if not isinstance(data, str):
|
||||
raise TypeError()
|
||||
gender_type_1 = BlankEnum(data)
|
||||
|
||||
return gender_type_1
|
||||
except: # noqa: E722
|
||||
pass
|
||||
return cast(Union[BlankEnum, GenderEnum, None, Unset], data)
|
||||
|
||||
gender = _parse_gender(d.pop("gender", UNSET))
|
||||
|
||||
def _parse_education_degree(data: object) -> Union[BlankEnum, EducationDegreeEnum, None, Unset]:
|
||||
if data is None:
|
||||
return data
|
||||
if isinstance(data, Unset):
|
||||
return data
|
||||
try:
|
||||
if not isinstance(data, str):
|
||||
raise TypeError()
|
||||
education_degree_type_0 = EducationDegreeEnum(data)
|
||||
|
||||
return education_degree_type_0
|
||||
except: # noqa: E722
|
||||
pass
|
||||
try:
|
||||
if not isinstance(data, str):
|
||||
raise TypeError()
|
||||
education_degree_type_1 = BlankEnum(data)
|
||||
|
||||
return education_degree_type_1
|
||||
except: # noqa: E722
|
||||
pass
|
||||
return cast(Union[BlankEnum, EducationDegreeEnum, None, Unset], data)
|
||||
|
||||
education_degree = _parse_education_degree(d.pop("education_degree", UNSET))
|
||||
|
||||
def _parse_education_field(data: object) -> Union[None, Unset, str]:
|
||||
if data is None:
|
||||
return data
|
||||
if isinstance(data, Unset):
|
||||
return data
|
||||
return cast(Union[None, Unset, str], data)
|
||||
|
||||
education_field = _parse_education_field(d.pop("education_field", UNSET))
|
||||
|
||||
def _parse_birthdate(data: object) -> Union[None, Unset, datetime.date]:
|
||||
if data is None:
|
||||
return data
|
||||
if isinstance(data, Unset):
|
||||
return data
|
||||
try:
|
||||
if not isinstance(data, str):
|
||||
raise TypeError()
|
||||
birthdate_type_0 = isoparse(data).date()
|
||||
|
||||
return birthdate_type_0
|
||||
except: # noqa: E722
|
||||
pass
|
||||
return cast(Union[None, Unset, datetime.date], data)
|
||||
|
||||
birthdate = _parse_birthdate(d.pop("birthdate", UNSET))
|
||||
|
||||
def _parse_iban(data: object) -> Union[None, Unset, str]:
|
||||
if data is None:
|
||||
return data
|
||||
|
|
@ -247,6 +379,10 @@ class Account:
|
|||
last_name=last_name,
|
||||
name=name,
|
||||
avatar=avatar,
|
||||
gender=gender,
|
||||
education_degree=education_degree,
|
||||
education_field=education_field,
|
||||
birthdate=birthdate,
|
||||
iban=iban,
|
||||
province=province,
|
||||
city=city,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
from typing import Any, TypeVar
|
||||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar, Union, cast
|
||||
from uuid import UUID
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
|
|
@ -13,6 +14,7 @@ class Application:
|
|||
Attributes:
|
||||
uuid (UUID):
|
||||
name (str):
|
||||
avatar (Union[None, str]):
|
||||
client_id (str):
|
||||
user (UUID):
|
||||
allowed_scope (str):
|
||||
|
|
@ -20,6 +22,7 @@ class Application:
|
|||
|
||||
uuid: UUID
|
||||
name: str
|
||||
avatar: Union[None, str]
|
||||
client_id: str
|
||||
user: UUID
|
||||
allowed_scope: str
|
||||
|
|
@ -30,6 +33,9 @@ class Application:
|
|||
|
||||
name = self.name
|
||||
|
||||
avatar: Union[None, str]
|
||||
avatar = self.avatar
|
||||
|
||||
client_id = self.client_id
|
||||
|
||||
user = str(self.user)
|
||||
|
|
@ -42,6 +48,7 @@ class Application:
|
|||
{
|
||||
"uuid": uuid,
|
||||
"name": name,
|
||||
"avatar": avatar,
|
||||
"client_id": client_id,
|
||||
"user": user,
|
||||
"allowed_scope": allowed_scope,
|
||||
|
|
@ -51,12 +58,19 @@ class Application:
|
|||
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"))
|
||||
|
||||
name = d.pop("name")
|
||||
|
||||
def _parse_avatar(data: object) -> Union[None, str]:
|
||||
if data is None:
|
||||
return data
|
||||
return cast(Union[None, str], data)
|
||||
|
||||
avatar = _parse_avatar(d.pop("avatar"))
|
||||
|
||||
client_id = d.pop("client_id")
|
||||
|
||||
user = UUID(d.pop("user"))
|
||||
|
|
@ -66,6 +80,7 @@ class Application:
|
|||
application = cls(
|
||||
uuid=uuid,
|
||||
name=name,
|
||||
avatar=avatar,
|
||||
client_id=client_id,
|
||||
user=user,
|
||||
allowed_scope=allowed_scope,
|
||||
|
|
|
|||
8
gooyal_accounts_client/models/blank_enum.py
Normal file
8
gooyal_accounts_client/models/blank_enum.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
from enum import Enum
|
||||
|
||||
|
||||
class BlankEnum(str, Enum):
|
||||
VALUE_0 = ""
|
||||
|
||||
def __str__(self) -> str:
|
||||
return str(self.value)
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar, Union
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
|
|
@ -43,8 +44,8 @@ class ChangePassword:
|
|||
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)
|
||||
old_password = d.pop("old_password")
|
||||
|
||||
new_password = d.pop("new_password")
|
||||
|
|
|
|||
14
gooyal_accounts_client/models/education_degree_enum.py
Normal file
14
gooyal_accounts_client/models/education_degree_enum.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
from enum import Enum
|
||||
|
||||
|
||||
class EducationDegreeEnum(str, Enum):
|
||||
ASSOCIATE = "associate"
|
||||
BACHELORS = "bachelors"
|
||||
DOCTORATE = "doctorate"
|
||||
HIGH = "high"
|
||||
MASTERS = "masters"
|
||||
MIDDLE = "middle"
|
||||
PRIMARY = "primary"
|
||||
|
||||
def __str__(self) -> str:
|
||||
return str(self.value)
|
||||
9
gooyal_accounts_client/models/gender_enum.py
Normal file
9
gooyal_accounts_client/models/gender_enum.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
from enum import Enum
|
||||
|
||||
|
||||
class GenderEnum(str, Enum):
|
||||
F = "f"
|
||||
M = "m"
|
||||
|
||||
def __str__(self) -> str:
|
||||
return str(self.value)
|
||||
|
|
@ -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
|
||||
|
|
@ -64,10 +65,10 @@ class PaginatedApplicationList:
|
|||
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 import Application
|
||||
|
||||
d = src_dict.copy()
|
||||
d = dict(src_dict)
|
||||
count = d.pop("count")
|
||||
|
||||
results = []
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -64,10 +65,10 @@ class PaginatedPublicUserList:
|
|||
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.public_user import PublicUser
|
||||
|
||||
d = src_dict.copy()
|
||||
d = dict(src_dict)
|
||||
count = d.pop("count")
|
||||
|
||||
results = []
|
||||
|
|
|
|||
|
|
@ -1,9 +1,15 @@
|
|||
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.blank_enum import BlankEnum
|
||||
from ..models.education_degree_enum import EducationDegreeEnum
|
||||
from ..models.gender_enum import GenderEnum
|
||||
from ..types import UNSET, Unset
|
||||
|
||||
T = TypeVar("T", bound="PatchedAccount")
|
||||
|
|
@ -21,6 +27,10 @@ class PatchedAccount:
|
|||
last_name (Union[Unset, str]):
|
||||
name (Union[Unset, str]):
|
||||
avatar (Union[None, Unset, str]):
|
||||
gender (Union[BlankEnum, GenderEnum, None, Unset]):
|
||||
education_degree (Union[BlankEnum, EducationDegreeEnum, None, Unset]):
|
||||
education_field (Union[None, Unset, str]):
|
||||
birthdate (Union[None, Unset, datetime.date]):
|
||||
iban (Union[None, Unset, str]):
|
||||
iban_verified (Union[None, Unset, bool]):
|
||||
province (Union[None, Unset, int]):
|
||||
|
|
@ -39,6 +49,10 @@ class PatchedAccount:
|
|||
last_name: Union[Unset, str] = UNSET
|
||||
name: Union[Unset, str] = UNSET
|
||||
avatar: Union[None, Unset, str] = UNSET
|
||||
gender: Union[BlankEnum, GenderEnum, None, Unset] = UNSET
|
||||
education_degree: Union[BlankEnum, EducationDegreeEnum, None, Unset] = UNSET
|
||||
education_field: Union[None, Unset, str] = UNSET
|
||||
birthdate: Union[None, Unset, datetime.date] = UNSET
|
||||
iban: Union[None, Unset, str] = UNSET
|
||||
iban_verified: Union[None, Unset, bool] = UNSET
|
||||
province: Union[None, Unset, int] = UNSET
|
||||
|
|
@ -76,6 +90,40 @@ class PatchedAccount:
|
|||
else:
|
||||
avatar = self.avatar
|
||||
|
||||
gender: Union[None, Unset, str]
|
||||
if isinstance(self.gender, Unset):
|
||||
gender = UNSET
|
||||
elif isinstance(self.gender, GenderEnum):
|
||||
gender = self.gender.value
|
||||
elif isinstance(self.gender, BlankEnum):
|
||||
gender = self.gender.value
|
||||
else:
|
||||
gender = self.gender
|
||||
|
||||
education_degree: Union[None, Unset, str]
|
||||
if isinstance(self.education_degree, Unset):
|
||||
education_degree = UNSET
|
||||
elif isinstance(self.education_degree, EducationDegreeEnum):
|
||||
education_degree = self.education_degree.value
|
||||
elif isinstance(self.education_degree, BlankEnum):
|
||||
education_degree = self.education_degree.value
|
||||
else:
|
||||
education_degree = self.education_degree
|
||||
|
||||
education_field: Union[None, Unset, str]
|
||||
if isinstance(self.education_field, Unset):
|
||||
education_field = UNSET
|
||||
else:
|
||||
education_field = self.education_field
|
||||
|
||||
birthdate: Union[None, Unset, str]
|
||||
if isinstance(self.birthdate, Unset):
|
||||
birthdate = UNSET
|
||||
elif isinstance(self.birthdate, datetime.date):
|
||||
birthdate = self.birthdate.isoformat()
|
||||
else:
|
||||
birthdate = self.birthdate
|
||||
|
||||
iban: Union[None, Unset, str]
|
||||
if isinstance(self.iban, Unset):
|
||||
iban = UNSET
|
||||
|
|
@ -135,6 +183,14 @@ class PatchedAccount:
|
|||
field_dict["name"] = name
|
||||
if avatar is not UNSET:
|
||||
field_dict["avatar"] = avatar
|
||||
if gender is not UNSET:
|
||||
field_dict["gender"] = gender
|
||||
if education_degree is not UNSET:
|
||||
field_dict["education_degree"] = education_degree
|
||||
if education_field is not UNSET:
|
||||
field_dict["education_field"] = education_field
|
||||
if birthdate is not UNSET:
|
||||
field_dict["birthdate"] = birthdate
|
||||
if iban is not UNSET:
|
||||
field_dict["iban"] = iban
|
||||
if iban_verified is not UNSET:
|
||||
|
|
@ -155,8 +211,8 @@ class PatchedAccount:
|
|||
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 = d.pop("uuid", UNSET)
|
||||
uuid: Union[Unset, UUID]
|
||||
if isinstance(_uuid, Unset):
|
||||
|
|
@ -192,6 +248,82 @@ class PatchedAccount:
|
|||
|
||||
avatar = _parse_avatar(d.pop("avatar", UNSET))
|
||||
|
||||
def _parse_gender(data: object) -> Union[BlankEnum, GenderEnum, None, Unset]:
|
||||
if data is None:
|
||||
return data
|
||||
if isinstance(data, Unset):
|
||||
return data
|
||||
try:
|
||||
if not isinstance(data, str):
|
||||
raise TypeError()
|
||||
gender_type_0 = GenderEnum(data)
|
||||
|
||||
return gender_type_0
|
||||
except: # noqa: E722
|
||||
pass
|
||||
try:
|
||||
if not isinstance(data, str):
|
||||
raise TypeError()
|
||||
gender_type_1 = BlankEnum(data)
|
||||
|
||||
return gender_type_1
|
||||
except: # noqa: E722
|
||||
pass
|
||||
return cast(Union[BlankEnum, GenderEnum, None, Unset], data)
|
||||
|
||||
gender = _parse_gender(d.pop("gender", UNSET))
|
||||
|
||||
def _parse_education_degree(data: object) -> Union[BlankEnum, EducationDegreeEnum, None, Unset]:
|
||||
if data is None:
|
||||
return data
|
||||
if isinstance(data, Unset):
|
||||
return data
|
||||
try:
|
||||
if not isinstance(data, str):
|
||||
raise TypeError()
|
||||
education_degree_type_0 = EducationDegreeEnum(data)
|
||||
|
||||
return education_degree_type_0
|
||||
except: # noqa: E722
|
||||
pass
|
||||
try:
|
||||
if not isinstance(data, str):
|
||||
raise TypeError()
|
||||
education_degree_type_1 = BlankEnum(data)
|
||||
|
||||
return education_degree_type_1
|
||||
except: # noqa: E722
|
||||
pass
|
||||
return cast(Union[BlankEnum, EducationDegreeEnum, None, Unset], data)
|
||||
|
||||
education_degree = _parse_education_degree(d.pop("education_degree", UNSET))
|
||||
|
||||
def _parse_education_field(data: object) -> Union[None, Unset, str]:
|
||||
if data is None:
|
||||
return data
|
||||
if isinstance(data, Unset):
|
||||
return data
|
||||
return cast(Union[None, Unset, str], data)
|
||||
|
||||
education_field = _parse_education_field(d.pop("education_field", UNSET))
|
||||
|
||||
def _parse_birthdate(data: object) -> Union[None, Unset, datetime.date]:
|
||||
if data is None:
|
||||
return data
|
||||
if isinstance(data, Unset):
|
||||
return data
|
||||
try:
|
||||
if not isinstance(data, str):
|
||||
raise TypeError()
|
||||
birthdate_type_0 = isoparse(data).date()
|
||||
|
||||
return birthdate_type_0
|
||||
except: # noqa: E722
|
||||
pass
|
||||
return cast(Union[None, Unset, datetime.date], data)
|
||||
|
||||
birthdate = _parse_birthdate(d.pop("birthdate", UNSET))
|
||||
|
||||
def _parse_iban(data: object) -> Union[None, Unset, str]:
|
||||
if data is None:
|
||||
return data
|
||||
|
|
@ -259,6 +391,10 @@ class PatchedAccount:
|
|||
last_name=last_name,
|
||||
name=name,
|
||||
avatar=avatar,
|
||||
gender=gender,
|
||||
education_degree=education_degree,
|
||||
education_field=education_field,
|
||||
birthdate=birthdate,
|
||||
iban=iban,
|
||||
iban_verified=iban_verified,
|
||||
province=province,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar, Union
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
|
|
@ -42,8 +43,8 @@ class PatchedChangePassword:
|
|||
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)
|
||||
old_password = d.pop("old_password", UNSET)
|
||||
|
||||
old_password_field = d.pop("old_password_field", UNSET)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar, Union, cast
|
||||
from uuid import UUID
|
||||
|
||||
|
|
@ -58,8 +59,8 @@ class PublicUser:
|
|||
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)
|
||||
|
||||
def _parse_avatar(data: object) -> Union[None, str]:
|
||||
if data is None:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import datetime
|
||||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar, Union, cast
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
|
|
@ -46,8 +47,8 @@ class RequestOTP:
|
|||
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)
|
||||
phone_number = d.pop("phone_number")
|
||||
|
||||
def _parse_otp_expire(data: object) -> Union[None, datetime.datetime]:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import datetime
|
||||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar, Union, cast
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
|
|
@ -47,8 +48,8 @@ class RequestOTT:
|
|||
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)
|
||||
application = d.pop("application")
|
||||
|
||||
def _parse_ott(data: object) -> Union[None, str]:
|
||||
|
|
|
|||
68
gooyal_accounts_client/models/user_inquiry.py
Normal file
68
gooyal_accounts_client/models/user_inquiry.py
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
from collections.abc import Mapping
|
||||
from typing import Any, TypeVar
|
||||
from uuid import UUID
|
||||
|
||||
from attrs import define as _attrs_define
|
||||
from attrs import field as _attrs_field
|
||||
|
||||
T = TypeVar("T", bound="UserInquiry")
|
||||
|
||||
|
||||
@_attrs_define
|
||||
class UserInquiry:
|
||||
"""
|
||||
Attributes:
|
||||
uuid (UUID):
|
||||
phone_number (str):
|
||||
"""
|
||||
|
||||
uuid: UUID
|
||||
phone_number: str
|
||||
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
||||
|
||||
def to_dict(self) -> dict[str, Any]:
|
||||
uuid = str(self.uuid)
|
||||
|
||||
phone_number = self.phone_number
|
||||
|
||||
field_dict: dict[str, Any] = {}
|
||||
field_dict.update(self.additional_properties)
|
||||
field_dict.update(
|
||||
{
|
||||
"uuid": uuid,
|
||||
"phone_number": phone_number,
|
||||
}
|
||||
)
|
||||
|
||||
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"))
|
||||
|
||||
phone_number = d.pop("phone_number")
|
||||
|
||||
user_inquiry = cls(
|
||||
uuid=uuid,
|
||||
phone_number=phone_number,
|
||||
)
|
||||
|
||||
user_inquiry.additional_properties = d
|
||||
return user_inquiry
|
||||
|
||||
@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
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
import os
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'wallet.settings')
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'main.settings')
|
||||
|
||||
from utils.broker import get_rpc_broker_consumer
|
||||
|
||||
0
main/other_settings/__init__.py
Normal file
0
main/other_settings/__init__.py
Normal file
141
main/other_settings/logging.py
Normal file
141
main/other_settings/logging.py
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
import os
|
||||
|
||||
def get_settings(key):
|
||||
from django.conf import settings
|
||||
return getattr(settings, 'BASE_DIR')
|
||||
|
||||
BASE_DIR = get_settings('BASE_DIR')
|
||||
|
||||
LOG_DIR = BASE_DIR / 'log'
|
||||
if not os.path.exists(LOG_DIR):
|
||||
os.makedirs(LOG_DIR)
|
||||
|
||||
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'formatters': {
|
||||
'verbose': {
|
||||
'format': '{asctime} [{levelname}] {name} {module} {process:d} {thread:d} {message}',
|
||||
'style': '{',
|
||||
},
|
||||
'standard': {
|
||||
'format': '{asctime} [{levelname}] {name}: {message}',
|
||||
'style': '{',
|
||||
},
|
||||
'simple': {
|
||||
'format': '{levelname} {message}',
|
||||
'style': '{',
|
||||
},
|
||||
},
|
||||
'filters': {
|
||||
'require_debug_true': {
|
||||
'()': 'django.utils.log.RequireDebugTrue',
|
||||
},
|
||||
'require_debug_false': {
|
||||
'()': 'django.utils.log.RequireDebugFalse',
|
||||
},
|
||||
},
|
||||
'handlers': {
|
||||
# هندلر برای نوشتن در فایل
|
||||
'file': {
|
||||
'level': 'INFO',
|
||||
'class': 'logging.handlers.TimedRotatingFileHandler',
|
||||
'filename': os.path.join(LOG_DIR, 'accounts.log'),
|
||||
# 'maxBytes': 1024 * 1024 * 10, # 10 MB
|
||||
'when': 'midnight',
|
||||
'interval': 5,
|
||||
'backupCount': 30,
|
||||
'formatter': 'verbose',
|
||||
'encoding': 'utf-8',
|
||||
},
|
||||
# هندلر برای خطاها در فایل جداگانه
|
||||
'error_file': {
|
||||
'level': 'ERROR',
|
||||
'class': 'logging.handlers.TimedRotatingFileHandler',
|
||||
'filename': os.path.join(LOG_DIR, 'errors.log'),
|
||||
# 'maxBytes': 1024 * 1024 * 10,
|
||||
'when': 'midnight',
|
||||
'interval': 5,
|
||||
'backupCount': 30,
|
||||
'formatter': 'verbose',
|
||||
'encoding': 'utf-8',
|
||||
},
|
||||
# هندلر برای کنسول (فقط در حالت DEBUG)
|
||||
'console': {
|
||||
'level': 'DEBUG',
|
||||
'filters': ['require_debug_true'],
|
||||
'class': 'logging.StreamHandler',
|
||||
'formatter': 'simple',
|
||||
},
|
||||
# هندلر برای کنسول همیشه فعال (حتی در production)
|
||||
'console_always': {
|
||||
'level': 'INFO',
|
||||
'class': 'logging.StreamHandler',
|
||||
'formatter': 'standard',
|
||||
},
|
||||
},
|
||||
'loggers': {
|
||||
# لاگر ریشه
|
||||
'': { # empty string = root logger
|
||||
'handlers': ['console', 'file', 'error_file'],
|
||||
'level': 'INFO',
|
||||
'propagate': True,
|
||||
},
|
||||
# لاگر اختصاصی برای Django
|
||||
'django': {
|
||||
'handlers': ['console', 'file'],
|
||||
'level': 'INFO',
|
||||
'propagate': False,
|
||||
},
|
||||
# لاگر اختصاصی برای درخواستها
|
||||
'django.request': {
|
||||
'handlers': ['file', 'error_file', 'console'],
|
||||
'level': 'ERROR',
|
||||
'propagate': False,
|
||||
},
|
||||
# # لاگر اختصاصی برای برنامه خودتان
|
||||
# 'root': {
|
||||
# 'handlers': ['console', 'file', 'error_file'],
|
||||
# 'level': 'DEBUG',
|
||||
# 'propagate': False,
|
||||
# },
|
||||
},
|
||||
}
|
||||
|
||||
# LOKI_BASE_PUBLIC_URL = config('LOKI_BASE_PUBLIC_URL', default=None, cast=str)
|
||||
# {
|
||||
# 'version': 1,
|
||||
# 'disable_existing_loggers': False,
|
||||
# 'formatters': {
|
||||
# 'loki': {
|
||||
# 'class': 'utils.logs.LokiFormatter', # required
|
||||
# },
|
||||
# },
|
||||
#
|
||||
# 'handlers': {
|
||||
# 'loki': {
|
||||
# 'level': 'DEBUG', # Log level. Required
|
||||
# 'class': 'utils.logs.LokiHandler', # Required
|
||||
# 'formatter': 'loki', # Loki formatter. Required
|
||||
# 'timeout': 2, # Post request timeout, default is 0.5. Optional
|
||||
# 'url': f'{LOKI_BASE_PUBLIC_URL}/loki/api/v1/push', # Loki url. Defaults to localhost. Optional.
|
||||
# # 'auth': ("user", "password"), # Basic auth to authenticate with loki. Default is None (i.e. no auth). Optional
|
||||
# 'tags': {"app": "accounts"}, # Tags / Labels to attach to the log. Optional, but strongly encoraged to use.
|
||||
# 'mode': 'thread',
|
||||
# # Push mode. Can be 'sync' or 'thread'. Sync is blocking, thread is non-blocking. Defaults to sync. Optional.
|
||||
# },
|
||||
# 'console': {
|
||||
# 'level': 'DEBUG',
|
||||
# 'class': 'logging.StreamHandler',
|
||||
# # 'formatter': 'verbose',
|
||||
# },
|
||||
# },
|
||||
# 'loggers': {
|
||||
# '': {
|
||||
# 'handlers': ['console', 'loki'],
|
||||
# 'level': 'INFO',
|
||||
# 'propagate': True,
|
||||
# },
|
||||
# },
|
||||
# }
|
||||
|
|
@ -47,6 +47,7 @@ INSTALLED_APPS = [
|
|||
'crispy_forms',
|
||||
'crispy_bootstrap5',
|
||||
'django_filters',
|
||||
'rangefilter',
|
||||
# 'jalali_date',
|
||||
|
||||
# local apps
|
||||
|
|
@ -125,7 +126,7 @@ SPECTACULAR_SETTINGS = {
|
|||
# https://spec.openapis.org/oas/v3.0.3#oauth-flows-object
|
||||
}
|
||||
|
||||
ROOT_URLCONF = 'wallet.urls'
|
||||
ROOT_URLCONF = 'main.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
|
|
@ -148,7 +149,7 @@ AUTHENTICATION_BACKENDS = (
|
|||
'django.contrib.auth.backends.ModelBackend',
|
||||
)
|
||||
|
||||
WSGI_APPLICATION = 'wallet.wsgi.application'
|
||||
WSGI_APPLICATION = 'main.wsgi.application'
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
|
||||
|
|
@ -256,39 +257,6 @@ CACHES = {
|
|||
|
||||
LOKI_BASE_PUBLIC_URL = config('LOKI_BASE_PUBLIC_URL', default=None, cast=str)
|
||||
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'formatters': {
|
||||
'loki': {
|
||||
'class': 'utils.logs.LokiFormatter', # required
|
||||
},
|
||||
},
|
||||
|
||||
'handlers': {
|
||||
'loki': {
|
||||
'level': 'DEBUG', # Log level. Required
|
||||
'class': 'utils.logs.LokiHandler', # Required
|
||||
'formatter': 'loki', # Loki formatter. Required
|
||||
'timeout': 2, # Post request timeout, default is 0.5. Optional
|
||||
'url': f'{LOKI_BASE_PUBLIC_URL}/loki/api/v1/push', # Loki url. Defaults to localhost. Optional.
|
||||
# 'auth': ("user", "password"), # Basic auth to authenticate with loki. Default is None (i.e. no auth). Optional
|
||||
'tags': {"app": "wallet"}, # Tags / Labels to attach to the log. Optional, but strongly encoraged to use.
|
||||
'mode': 'thread', # Push mode. Can be 'sync' or 'thread'. Sync is blocking, thread is non-blocking. Defaults to sync. Optional.
|
||||
},
|
||||
'console': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.StreamHandler',
|
||||
# 'formatter': 'verbose',
|
||||
},
|
||||
},
|
||||
'loggers': {
|
||||
'': {
|
||||
'handlers': ['console', 'loki'],
|
||||
'level': 'INFO',
|
||||
'propagate': True,
|
||||
},
|
||||
},
|
||||
}
|
||||
from main.other_settings.logging import LOGGING
|
||||
|
||||
ALLOWED_NEGATIVE_BALANCE_APPLICATIONS = config('ALLOWED_NEGATIVE_BALANCE_APPLICATIONS', cast=lambda v: [s.strip() for s in v.split(',')])
|
||||
|
|
@ -11,6 +11,6 @@ import os
|
|||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'wallet.settings')
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'main.settings')
|
||||
|
||||
application = get_wsgi_application()
|
||||
|
|
@ -5,7 +5,7 @@ import sys
|
|||
|
||||
|
||||
def main():
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'wallet.settings')
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'main.settings')
|
||||
try:
|
||||
from django.core.management import execute_from_command_line
|
||||
except ImportError as exc:
|
||||
|
|
|
|||
|
|
@ -22,3 +22,5 @@ psycopg[binary,pool]
|
|||
django-redis
|
||||
httpx
|
||||
packaging==25.0
|
||||
xlsxwriter
|
||||
django-admin-rangefilter
|
||||
|
|
@ -179,3 +179,6 @@ zope-event==6.1
|
|||
# via gevent
|
||||
zope-interface==8.2
|
||||
# via gevent
|
||||
xlsxwriter==3.2.3
|
||||
# via -r requirements.in
|
||||
django-admin-rangefilter==0.13.5
|
||||
|
|
|
|||
2
run.sh
2
run.sh
|
|
@ -5,4 +5,4 @@ while ! nc -z $DB_HOST 5432 ; do
|
|||
done
|
||||
#python3 manage.py collectstatic --noinput
|
||||
python3 manage.py migrate
|
||||
gunicorn wallet.wsgi:application --bind 0.0.0.0:8000 -w 4
|
||||
gunicorn main.wsgi:application --bind 0.0.0.0:8000 -w 4
|
||||
|
|
@ -8,7 +8,8 @@ from gooyal_accounts_client import AuthenticatedClient
|
|||
from gooyal_accounts_client.models import PublicUser, Application
|
||||
from gooyal_accounts_client.api.users import users_api_users_retrieve
|
||||
from gooyal_accounts_client.api.oauth2 import oauth2_apis_applications_retrieve
|
||||
from gooyal_accounts_client.types import Response
|
||||
from gooyal_accounts_client.models import Account
|
||||
from gooyal_accounts_client.api.users import (users_api_users_details_retrieve)
|
||||
|
||||
|
||||
def login_as_client_credentials():
|
||||
|
|
@ -60,6 +61,13 @@ def get_user_details(uuid):
|
|||
|
||||
return data
|
||||
|
||||
def get_user_detailed_info(uuid):
|
||||
client = get_client()
|
||||
response: Account = users_api_users_details_retrieve.sync(uuid=uuid, client=client)
|
||||
print(response)
|
||||
|
||||
return response
|
||||
|
||||
def get_application_details(uuid):
|
||||
client = get_client()
|
||||
data: Application = oauth2_apis_applications_retrieve.sync(client=client, id=uuid)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue