144 lines
4.2 KiB
Python
144 lines
4.2 KiB
Python
from collections.abc import Mapping
|
|
from typing import Any, TypeVar, Union
|
|
|
|
from attrs import define as _attrs_define
|
|
from attrs import field as _attrs_field
|
|
|
|
from .. import types
|
|
from ..types import UNSET, Unset
|
|
|
|
T = TypeVar("T", bound="Unit")
|
|
|
|
|
|
@_attrs_define
|
|
class Unit:
|
|
"""Serializer for Unit model
|
|
|
|
Attributes:
|
|
id (int):
|
|
name (str):
|
|
description (str): Description of the Unit. Some restricted HTML markup is allowed, everything else is filtered
|
|
out automatically.
|
|
iban (Union[Unset, str]):
|
|
address (Union[Unset, str]):
|
|
payout_account_holder (Union[Unset, str]):
|
|
email (Union[Unset, str]): This field will be used as a main contact point for the unit, e.g. for sending them
|
|
statements, or to show to ticket buyers on how they can contact the organizer.
|
|
"""
|
|
|
|
id: int
|
|
name: str
|
|
description: str
|
|
iban: Union[Unset, str] = UNSET
|
|
address: Union[Unset, str] = UNSET
|
|
payout_account_holder: Union[Unset, str] = UNSET
|
|
email: Union[Unset, str] = UNSET
|
|
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
|
|
def to_dict(self) -> dict[str, Any]:
|
|
id = self.id
|
|
|
|
name = self.name
|
|
|
|
description = self.description
|
|
|
|
iban = self.iban
|
|
|
|
address = self.address
|
|
|
|
payout_account_holder = self.payout_account_holder
|
|
|
|
email = self.email
|
|
|
|
field_dict: dict[str, Any] = {}
|
|
field_dict.update(self.additional_properties)
|
|
field_dict.update(
|
|
{
|
|
"id": id,
|
|
"name": name,
|
|
"description": description,
|
|
}
|
|
)
|
|
if iban is not UNSET:
|
|
field_dict["iban"] = iban
|
|
if address is not UNSET:
|
|
field_dict["address"] = address
|
|
if payout_account_holder is not UNSET:
|
|
field_dict["payout_account_holder"] = payout_account_holder
|
|
if email is not UNSET:
|
|
field_dict["email"] = email
|
|
|
|
return field_dict
|
|
|
|
def to_multipart(self) -> types.RequestFiles:
|
|
files: types.RequestFiles = []
|
|
|
|
files.append(("id", (None, str(self.id).encode(), "text/plain")))
|
|
|
|
files.append(("name", (None, str(self.name).encode(), "text/plain")))
|
|
|
|
files.append(("description", (None, str(self.description).encode(), "text/plain")))
|
|
|
|
if not isinstance(self.iban, Unset):
|
|
files.append(("iban", (None, str(self.iban).encode(), "text/plain")))
|
|
|
|
if not isinstance(self.address, Unset):
|
|
files.append(("address", (None, str(self.address).encode(), "text/plain")))
|
|
|
|
if not isinstance(self.payout_account_holder, Unset):
|
|
files.append(("payout_account_holder", (None, str(self.payout_account_holder).encode(), "text/plain")))
|
|
|
|
if not isinstance(self.email, Unset):
|
|
files.append(("email", (None, str(self.email).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)
|
|
id = d.pop("id")
|
|
|
|
name = d.pop("name")
|
|
|
|
description = d.pop("description")
|
|
|
|
iban = d.pop("iban", UNSET)
|
|
|
|
address = d.pop("address", UNSET)
|
|
|
|
payout_account_holder = d.pop("payout_account_holder", UNSET)
|
|
|
|
email = d.pop("email", UNSET)
|
|
|
|
unit = cls(
|
|
id=id,
|
|
name=name,
|
|
description=description,
|
|
iban=iban,
|
|
address=address,
|
|
payout_account_holder=payout_account_holder,
|
|
email=email,
|
|
)
|
|
|
|
unit.additional_properties = d
|
|
return unit
|
|
|
|
@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
|