138 lines
4 KiB
Python
138 lines
4 KiB
Python
from collections.abc import Mapping
|
|
from typing import Any, TypeVar, Union, cast
|
|
from uuid import UUID
|
|
|
|
from attrs import define as _attrs_define
|
|
from attrs import field as _attrs_field
|
|
|
|
from .content_type_enum import ContentTypeEnum
|
|
from .state_634_enum import State634Enum
|
|
from ..types import UNSET, Unset
|
|
|
|
T = TypeVar("T", bound="AdContent")
|
|
|
|
|
|
@_attrs_define
|
|
class AdContent:
|
|
"""
|
|
Attributes:
|
|
uuid (UUID):
|
|
file (Union[None, Unset, str]):
|
|
content_type (Union[Unset, ContentTypeEnum]): * `1` - image
|
|
* `2` - voice
|
|
* `3` - video
|
|
* `4` - document
|
|
order (Union[Unset, int]):
|
|
state (Union[Unset, State634Enum]): * `0` - draft
|
|
* `1` - ready_for_check
|
|
* `2` - Checking
|
|
* `9` - Rejected
|
|
* `10` - Modified
|
|
* `11` - modification_checking
|
|
* `12` - modification_rejected
|
|
* `18` - stoped
|
|
* `19` - unpublished
|
|
* `20` - published
|
|
* `100` - deleted
|
|
"""
|
|
|
|
uuid: UUID
|
|
file: Union[None, Unset, str] = UNSET
|
|
content_type: Union[Unset, ContentTypeEnum] = UNSET
|
|
order: Union[Unset, int] = UNSET
|
|
state: Union[Unset, State634Enum] = UNSET
|
|
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
|
|
def to_dict(self) -> dict[str, Any]:
|
|
uuid = str(self.uuid)
|
|
|
|
file: Union[None, Unset, str]
|
|
if isinstance(self.file, Unset):
|
|
file = UNSET
|
|
else:
|
|
file = self.file
|
|
|
|
content_type: Union[Unset, int] = UNSET
|
|
if not isinstance(self.content_type, Unset):
|
|
content_type = self.content_type.value
|
|
|
|
order = self.order
|
|
|
|
state: Union[Unset, int] = UNSET
|
|
if not isinstance(self.state, Unset):
|
|
state = self.state.value
|
|
|
|
field_dict: dict[str, Any] = {}
|
|
field_dict.update(self.additional_properties)
|
|
field_dict.update(
|
|
{
|
|
"uuid": uuid,
|
|
}
|
|
)
|
|
if file is not UNSET:
|
|
field_dict["file"] = file
|
|
if content_type is not UNSET:
|
|
field_dict["content_type"] = content_type
|
|
if order is not UNSET:
|
|
field_dict["order"] = order
|
|
if state is not UNSET:
|
|
field_dict["state"] = state
|
|
|
|
return field_dict
|
|
|
|
@classmethod
|
|
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
d = dict(src_dict)
|
|
uuid = UUID(d.pop("uuid"))
|
|
|
|
def _parse_file(data: object) -> Union[None, Unset, str]:
|
|
if data is None:
|
|
return data
|
|
if isinstance(data, Unset):
|
|
return data
|
|
return cast(Union[None, Unset, str], data)
|
|
|
|
file = _parse_file(d.pop("file", UNSET))
|
|
|
|
_content_type = d.pop("content_type", UNSET)
|
|
content_type: Union[Unset, ContentTypeEnum]
|
|
if isinstance(_content_type, Unset):
|
|
content_type = UNSET
|
|
else:
|
|
content_type = ContentTypeEnum(_content_type)
|
|
|
|
order = d.pop("order", UNSET)
|
|
|
|
_state = d.pop("state", UNSET)
|
|
state: Union[Unset, State634Enum]
|
|
if isinstance(_state, Unset):
|
|
state = UNSET
|
|
else:
|
|
state = State634Enum(_state)
|
|
|
|
ad_content = cls(
|
|
uuid=uuid,
|
|
file=file,
|
|
content_type=content_type,
|
|
order=order,
|
|
state=state,
|
|
)
|
|
|
|
ad_content.additional_properties = d
|
|
return ad_content
|
|
|
|
@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
|