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="PatchedUnit") @_attrs_define class PatchedUnit: """Serializer for Unit model Attributes: id (Union[Unset, int]): name (Union[Unset, str]): description (Union[Unset, 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: Union[Unset, int] = UNSET name: Union[Unset, str] = UNSET description: Union[Unset, str] = UNSET 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({}) if id is not UNSET: field_dict["id"] = id if name is not UNSET: field_dict["name"] = name if description is not UNSET: field_dict["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 = [] if not isinstance(self.id, Unset): files.append(("id", (None, str(self.id).encode(), "text/plain"))) if not isinstance(self.name, Unset): files.append(("name", (None, str(self.name).encode(), "text/plain"))) if not isinstance(self.description, Unset): 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", UNSET) name = d.pop("name", UNSET) description = d.pop("description", UNSET) iban = d.pop("iban", UNSET) address = d.pop("address", UNSET) payout_account_holder = d.pop("payout_account_holder", UNSET) email = d.pop("email", UNSET) patched_unit = cls( id=id, name=name, description=description, iban=iban, address=address, payout_account_holder=payout_account_holder, email=email, ) patched_unit.additional_properties = d return patched_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