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="PromotionCode") @_attrs_define class PromotionCode: """Serializer for PromotionCode model Attributes: event (int): event_id (int): id (int): name (str): name of the promotion that will be shown value (str): value of the code that users will have to enter to get the promotion """ event: int event_id: int id: int name: str value: str additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: event = self.event event_id = self.event_id id = self.id name = self.name value = self.value field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { "event": event, "event_id": event_id, "id": id, "name": name, "value": value, } ) return field_dict def to_multipart(self) -> types.RequestFiles: files: types.RequestFiles = [] files.append(("event", (None, str(self.event).encode(), "text/plain"))) files.append(("event_id", (None, str(self.event_id).encode(), "text/plain"))) files.append(("id", (None, str(self.id).encode(), "text/plain"))) files.append(("name", (None, str(self.name).encode(), "text/plain"))) files.append(("value", (None, str(self.value).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) event = d.pop("event") event_id = d.pop("event_id") id = d.pop("id") name = d.pop("name") value = d.pop("value") promotion_code = cls( event=event, event_id=event_id, id=id, name=name, value=value, ) promotion_code.additional_properties = d return promotion_code @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