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