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

86 lines
2.6 KiB
Python

from collections.abc import Mapping
from typing import Any, TypeVar
from attrs import define as _attrs_define
from attrs import field as _attrs_field
from .. import types
T = TypeVar("T", bound="Refund")
@_attrs_define
class Refund:
"""Write only serializer used to provide `refund_amount` and `payment_intent` to the action `refund` on
`InvoiceViewSet`.
A model serializer is used to give access to the targeted invoice, even though the fields are not part of the
invoice model.
Attributes:
refund_amount (str): Amount to be refunded on the invoice.
payment_intent_id (int): The original payment intent linked to the invoice to be refunded.
"""
refund_amount: str
payment_intent_id: int
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
refund_amount = self.refund_amount
payment_intent_id = self.payment_intent_id
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"refund_amount": refund_amount,
"payment_intent_id": payment_intent_id,
}
)
return field_dict
def to_multipart(self) -> types.RequestFiles:
files: types.RequestFiles = []
files.append(("refund_amount", (None, str(self.refund_amount).encode(), "text/plain")))
files.append(("payment_intent_id", (None, str(self.payment_intent_id).encode(), "text/plain")))
for prop_name, prop in self.additional_properties.items():
files.append((prop_name, (None, str(prop).encode(), "text/plain")))
return files
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
refund_amount = d.pop("refund_amount")
payment_intent_id = d.pop("payment_intent_id")
refund = cls(
refund_amount=refund_amount,
payment_intent_id=payment_intent_id,
)
refund.additional_properties = d
return refund
@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