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

102 lines
3.0 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
T = TypeVar("T", bound="PaymentMethod")
@_attrs_define
class PaymentMethod:
"""A serializer returning info for a payment method
Attributes:
active_module_id (int): The id of the payment method's active module
key (str):
title (str): Title of the payment method
description (str): Description of the payment method
basket_total_amount (float): The total amount of the basket when using this payment method (e.g. surcharges)
payment_module_price_extra (float): The difference between the total of the basket with the amount added from
the payment module and the total of the basket without
"""
active_module_id: int
key: str
title: str
description: str
basket_total_amount: float
payment_module_price_extra: float
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
def to_dict(self) -> dict[str, Any]:
active_module_id = self.active_module_id
key = self.key
title = self.title
description = self.description
basket_total_amount = self.basket_total_amount
payment_module_price_extra = self.payment_module_price_extra
field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
{
"active_module_id": active_module_id,
"key": key,
"title": title,
"description": description,
"basket_total_amount": basket_total_amount,
"payment_module_price_extra": payment_module_price_extra,
}
)
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
active_module_id = d.pop("active_module_id")
key = d.pop("key")
title = d.pop("title")
description = d.pop("description")
basket_total_amount = d.pop("basket_total_amount")
payment_module_price_extra = d.pop("payment_module_price_extra")
payment_method = cls(
active_module_id=active_module_id,
key=key,
title=title,
description=description,
basket_total_amount=basket_total_amount,
payment_module_price_extra=payment_module_price_extra,
)
payment_method.additional_properties = d
return payment_method
@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