polyticket-api/poly-ticket-api-client/poly_ticket_api_client/models/payrexx_transaction.py

119 lines
3.2 KiB
Python

from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, TypeVar, Union
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from ..types import UNSET, Unset
if TYPE_CHECKING:
from ..models.payrexx_payment import PayrexxPayment
T = TypeVar("T", bound="PayrexxTransaction")
@_attrs_define
class PayrexxTransaction:
"""Transaction containing info for the webhook.
referenceId can't be snake_case because the data is provided from Payrexx.
Attributes:
id (int): The ID of the transaction.
uuid (str): The UUID of the transaction.
status (str): The status of the transaction.
reference_id (str): The reference containing PolyTicket env and Payment intent id.
amount (int): The amount of the transaction in cents.
payment (Union[Unset, PayrexxPayment]): Payment info related to the transaction
"""
id: int
uuid: str
status: str
reference_id: str
amount: int
payment: Union[Unset, "PayrexxPayment"] = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
id = self.id
uuid = self.uuid
status = self.status
reference_id = self.reference_id
amount = self.amount
payment: Union[Unset, dict[str, Any]] = UNSET
if not isinstance(self.payment, Unset):
payment = self.payment.to_dict()
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"id": id,
"uuid": uuid,
"status": status,
"referenceId": reference_id,
"amount": amount,
}
)
if payment is not UNSET:
field_dict["payment"] = payment
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
from ..models.payrexx_payment import PayrexxPayment
d = dict(src_dict)
id = d.pop("id")
uuid = d.pop("uuid")
status = d.pop("status")
reference_id = d.pop("referenceId")
amount = d.pop("amount")
_payment = d.pop("payment", UNSET)
payment: Union[Unset, PayrexxPayment]
if isinstance(_payment, Unset):
payment = UNSET
else:
payment = PayrexxPayment.from_dict(_payment)
payrexx_transaction = cls(
id=id,
uuid=uuid,
status=status,
reference_id=reference_id,
amount=amount,
payment=payment,
)
payrexx_transaction.additional_properties = d
return payrexx_transaction
@property
def additional_keys(self) -> list[str]:
return list(self.additional_properties.keys())
def __getitem__(self, key: str) -> Any:
return self.additional_properties[key]
def __setitem__(self, key: str, value: Any) -> None:
self.additional_properties[key] = value
def __delitem__(self, key: str) -> None:
del self.additional_properties[key]
def __contains__(self, key: str) -> bool:
return key in self.additional_properties