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="EventModeration") @_attrs_define class EventModeration: """Write only serializer, used by admin to validate an event. Attributes: is_valid (bool): Whether the event is deemed valid by an admin. required_changes (Union[Unset, str]): Short description of what the user should modify on his event, so we can publish it. """ is_valid: bool required_changes: Union[Unset, str] = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: is_valid = self.is_valid required_changes = self.required_changes field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { "is_valid": is_valid, } ) if required_changes is not UNSET: field_dict["required_changes"] = required_changes return field_dict def to_multipart(self) -> types.RequestFiles: files: types.RequestFiles = [] files.append(("is_valid", (None, str(self.is_valid).encode(), "text/plain"))) if not isinstance(self.required_changes, Unset): files.append(("required_changes", (None, str(self.required_changes).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) is_valid = d.pop("is_valid") required_changes = d.pop("required_changes", UNSET) event_moderation = cls( is_valid=is_valid, required_changes=required_changes, ) event_moderation.additional_properties = d return event_moderation @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