588 lines
19 KiB
Python
588 lines
19 KiB
Python
import datetime
|
|
from collections.abc import Mapping
|
|
from typing import TYPE_CHECKING, Any, TypeVar, Union, cast
|
|
from uuid import UUID
|
|
|
|
from attrs import define as _attrs_define
|
|
from attrs import field as _attrs_field
|
|
from dateutil.parser import isoparse
|
|
|
|
from .rejection_reason_enum import RejectionReasonEnum
|
|
from .state_634_enum import State634Enum
|
|
from .type_0d9_enum import Type0D9Enum
|
|
from ..types import UNSET, Unset
|
|
|
|
if TYPE_CHECKING:
|
|
from .ad_content import AdContent
|
|
from .ad_statistic import AdStatistic
|
|
from .capture_location_type_0 import CaptureLocationType0
|
|
from .refined_ad_banner import RefinedAdBanner
|
|
from .refined_ad_content import RefinedAdContent
|
|
|
|
|
|
T = TypeVar("T", bound="Capture")
|
|
|
|
|
|
@_attrs_define
|
|
class Capture:
|
|
"""
|
|
Attributes:
|
|
uuid (UUID):
|
|
title (Union[None, str]):
|
|
type_ (Type0D9Enum): * `1` - BILLBOARD
|
|
* `2` - CAPTURED_BILLBOARD
|
|
* `99` - PROMOTION
|
|
* `100` - CONSTANT
|
|
contents (list['AdContent']):
|
|
refined_contents (list['RefinedAdContent']):
|
|
description (Union[None, str]):
|
|
banner (Union[None, str]):
|
|
reward_amount (int):
|
|
reward_count (int):
|
|
balance (Union[None, int]):
|
|
address (Union[None, str]):
|
|
url (Union[None, str]):
|
|
tags (Union[None, list[str]]):
|
|
state (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
|
|
get_state_display (str):
|
|
rejection_reason (Union[None, RejectionReasonEnum]):
|
|
created_at (datetime.datetime):
|
|
updated_at (datetime.datetime):
|
|
display_time (str):
|
|
status (str):
|
|
user_uuid (UUID):
|
|
comments_count (str):
|
|
likes_count (str):
|
|
state_ordering (str):
|
|
statistics (AdStatistic):
|
|
details (Union[Unset, Any]):
|
|
location (Union['CaptureLocationType0', None, Unset]):
|
|
location_is_approximate (Union[Unset, bool]):
|
|
refined_banner (Union[Unset, RefinedAdBanner]):
|
|
new_title (Union[None, Unset, str]):
|
|
new_description (Union[None, Unset, str]):
|
|
new_banner (Union[None, Unset, str]):
|
|
new_url (Union[None, Unset, str]):
|
|
new_tags (Union[Unset, Any]):
|
|
new_address (Union[None, Unset, str]):
|
|
new_reward_amount (Union[None, Unset, int]):
|
|
new_reward_count (Union[None, Unset, int]):
|
|
"""
|
|
|
|
uuid: UUID
|
|
title: Union[None, str]
|
|
type_: Type0D9Enum
|
|
contents: list["AdContent"]
|
|
refined_contents: list["RefinedAdContent"]
|
|
description: Union[None, str]
|
|
banner: Union[None, str]
|
|
reward_amount: int
|
|
reward_count: int
|
|
balance: Union[None, int]
|
|
address: Union[None, str]
|
|
url: Union[None, str]
|
|
tags: Union[None, list[str]]
|
|
state: State634Enum
|
|
get_state_display: str
|
|
rejection_reason: Union[None, RejectionReasonEnum]
|
|
created_at: datetime.datetime
|
|
updated_at: datetime.datetime
|
|
display_time: str
|
|
status: str
|
|
user_uuid: UUID
|
|
comments_count: str
|
|
likes_count: str
|
|
state_ordering: str
|
|
statistics: "AdStatistic"
|
|
details: Union[Unset, Any] = UNSET
|
|
location: Union["CaptureLocationType0", None, Unset] = UNSET
|
|
location_is_approximate: Union[Unset, bool] = UNSET
|
|
refined_banner: Union[Unset, "RefinedAdBanner"] = UNSET
|
|
new_title: Union[None, Unset, str] = UNSET
|
|
new_description: Union[None, Unset, str] = UNSET
|
|
new_banner: Union[None, Unset, str] = UNSET
|
|
new_url: Union[None, Unset, str] = UNSET
|
|
new_tags: Union[Unset, Any] = UNSET
|
|
new_address: Union[None, Unset, str] = UNSET
|
|
new_reward_amount: Union[None, Unset, int] = UNSET
|
|
new_reward_count: Union[None, Unset, int] = UNSET
|
|
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
|
|
|
|
def to_dict(self) -> dict[str, Any]:
|
|
from .capture_location_type_0 import CaptureLocationType0
|
|
|
|
uuid = str(self.uuid)
|
|
|
|
title: Union[None, str]
|
|
title = self.title
|
|
|
|
type_ = self.type_.value
|
|
|
|
contents = []
|
|
for contents_item_data in self.contents:
|
|
contents_item = contents_item_data.to_dict()
|
|
contents.append(contents_item)
|
|
|
|
refined_contents = []
|
|
for refined_contents_item_data in self.refined_contents:
|
|
refined_contents_item = refined_contents_item_data.to_dict()
|
|
refined_contents.append(refined_contents_item)
|
|
|
|
description: Union[None, str]
|
|
description = self.description
|
|
|
|
banner: Union[None, str]
|
|
banner = self.banner
|
|
|
|
reward_amount = self.reward_amount
|
|
|
|
reward_count = self.reward_count
|
|
|
|
balance: Union[None, int]
|
|
balance = self.balance
|
|
|
|
address: Union[None, str]
|
|
address = self.address
|
|
|
|
url: Union[None, str]
|
|
url = self.url
|
|
|
|
tags: Union[None, list[str]]
|
|
if isinstance(self.tags, list):
|
|
tags = self.tags
|
|
|
|
else:
|
|
tags = self.tags
|
|
|
|
state = self.state.value
|
|
|
|
get_state_display = self.get_state_display
|
|
|
|
rejection_reason: Union[None, str]
|
|
if isinstance(self.rejection_reason, RejectionReasonEnum):
|
|
rejection_reason = self.rejection_reason.value
|
|
else:
|
|
rejection_reason = self.rejection_reason
|
|
|
|
created_at = self.created_at.isoformat()
|
|
|
|
updated_at = self.updated_at.isoformat()
|
|
|
|
display_time = self.display_time
|
|
|
|
status = self.status
|
|
|
|
user_uuid = str(self.user_uuid)
|
|
|
|
comments_count = self.comments_count
|
|
|
|
likes_count = self.likes_count
|
|
|
|
state_ordering = self.state_ordering
|
|
|
|
statistics = self.statistics.to_dict()
|
|
|
|
details = self.details
|
|
|
|
location: Union[None, Unset, dict[str, Any]]
|
|
if isinstance(self.location, Unset):
|
|
location = UNSET
|
|
elif isinstance(self.location, CaptureLocationType0):
|
|
location = self.location.to_dict()
|
|
else:
|
|
location = self.location
|
|
|
|
location_is_approximate = self.location_is_approximate
|
|
|
|
refined_banner: Union[Unset, dict[str, Any]] = UNSET
|
|
if not isinstance(self.refined_banner, Unset):
|
|
refined_banner = self.refined_banner.to_dict()
|
|
|
|
new_title: Union[None, Unset, str]
|
|
if isinstance(self.new_title, Unset):
|
|
new_title = UNSET
|
|
else:
|
|
new_title = self.new_title
|
|
|
|
new_description: Union[None, Unset, str]
|
|
if isinstance(self.new_description, Unset):
|
|
new_description = UNSET
|
|
else:
|
|
new_description = self.new_description
|
|
|
|
new_banner: Union[None, Unset, str]
|
|
if isinstance(self.new_banner, Unset):
|
|
new_banner = UNSET
|
|
else:
|
|
new_banner = self.new_banner
|
|
|
|
new_url: Union[None, Unset, str]
|
|
if isinstance(self.new_url, Unset):
|
|
new_url = UNSET
|
|
else:
|
|
new_url = self.new_url
|
|
|
|
new_tags = self.new_tags
|
|
|
|
new_address: Union[None, Unset, str]
|
|
if isinstance(self.new_address, Unset):
|
|
new_address = UNSET
|
|
else:
|
|
new_address = self.new_address
|
|
|
|
new_reward_amount: Union[None, Unset, int]
|
|
if isinstance(self.new_reward_amount, Unset):
|
|
new_reward_amount = UNSET
|
|
else:
|
|
new_reward_amount = self.new_reward_amount
|
|
|
|
new_reward_count: Union[None, Unset, int]
|
|
if isinstance(self.new_reward_count, Unset):
|
|
new_reward_count = UNSET
|
|
else:
|
|
new_reward_count = self.new_reward_count
|
|
|
|
field_dict: dict[str, Any] = {}
|
|
field_dict.update(self.additional_properties)
|
|
field_dict.update(
|
|
{
|
|
"uuid": uuid,
|
|
"title": title,
|
|
"type": type_,
|
|
"contents": contents,
|
|
"refined_contents": refined_contents,
|
|
"description": description,
|
|
"banner": banner,
|
|
"reward_amount": reward_amount,
|
|
"reward_count": reward_count,
|
|
"balance": balance,
|
|
"address": address,
|
|
"url": url,
|
|
"tags": tags,
|
|
"state": state,
|
|
"get_state_display": get_state_display,
|
|
"rejection_reason": rejection_reason,
|
|
"created_at": created_at,
|
|
"updated_at": updated_at,
|
|
"display_time": display_time,
|
|
"status": status,
|
|
"user_uuid": user_uuid,
|
|
"comments_count": comments_count,
|
|
"likes_count": likes_count,
|
|
"state_ordering": state_ordering,
|
|
"statistics": statistics,
|
|
}
|
|
)
|
|
if details is not UNSET:
|
|
field_dict["details"] = details
|
|
if location is not UNSET:
|
|
field_dict["location"] = location
|
|
if location_is_approximate is not UNSET:
|
|
field_dict["location_is_approximate"] = location_is_approximate
|
|
if refined_banner is not UNSET:
|
|
field_dict["refined_banner"] = refined_banner
|
|
if new_title is not UNSET:
|
|
field_dict["new_title"] = new_title
|
|
if new_description is not UNSET:
|
|
field_dict["new_description"] = new_description
|
|
if new_banner is not UNSET:
|
|
field_dict["new_banner"] = new_banner
|
|
if new_url is not UNSET:
|
|
field_dict["new_url"] = new_url
|
|
if new_tags is not UNSET:
|
|
field_dict["new_tags"] = new_tags
|
|
if new_address is not UNSET:
|
|
field_dict["new_address"] = new_address
|
|
if new_reward_amount is not UNSET:
|
|
field_dict["new_reward_amount"] = new_reward_amount
|
|
if new_reward_count is not UNSET:
|
|
field_dict["new_reward_count"] = new_reward_count
|
|
|
|
return field_dict
|
|
|
|
@classmethod
|
|
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
|
|
from .ad_content import AdContent
|
|
from .ad_statistic import AdStatistic
|
|
from .capture_location_type_0 import CaptureLocationType0
|
|
from .refined_ad_banner import RefinedAdBanner
|
|
from .refined_ad_content import RefinedAdContent
|
|
|
|
d = dict(src_dict)
|
|
uuid = UUID(d.pop("uuid"))
|
|
|
|
def _parse_title(data: object) -> Union[None, str]:
|
|
if data is None:
|
|
return data
|
|
return cast(Union[None, str], data)
|
|
|
|
title = _parse_title(d.pop("title"))
|
|
|
|
type_ = Type0D9Enum(d.pop("type"))
|
|
|
|
contents = []
|
|
_contents = d.pop("contents")
|
|
for contents_item_data in _contents:
|
|
contents_item = AdContent.from_dict(contents_item_data)
|
|
|
|
contents.append(contents_item)
|
|
|
|
refined_contents = []
|
|
_refined_contents = d.pop("refined_contents")
|
|
for refined_contents_item_data in _refined_contents:
|
|
refined_contents_item = RefinedAdContent.from_dict(refined_contents_item_data)
|
|
|
|
refined_contents.append(refined_contents_item)
|
|
|
|
def _parse_description(data: object) -> Union[None, str]:
|
|
if data is None:
|
|
return data
|
|
return cast(Union[None, str], data)
|
|
|
|
description = _parse_description(d.pop("description"))
|
|
|
|
def _parse_banner(data: object) -> Union[None, str]:
|
|
if data is None:
|
|
return data
|
|
return cast(Union[None, str], data)
|
|
|
|
banner = _parse_banner(d.pop("banner"))
|
|
|
|
reward_amount = d.pop("reward_amount")
|
|
|
|
reward_count = d.pop("reward_count")
|
|
|
|
def _parse_balance(data: object) -> Union[None, int]:
|
|
if data is None:
|
|
return data
|
|
return cast(Union[None, int], data)
|
|
|
|
balance = _parse_balance(d.pop("balance"))
|
|
|
|
def _parse_address(data: object) -> Union[None, str]:
|
|
if data is None:
|
|
return data
|
|
return cast(Union[None, str], data)
|
|
|
|
address = _parse_address(d.pop("address"))
|
|
|
|
def _parse_url(data: object) -> Union[None, str]:
|
|
if data is None:
|
|
return data
|
|
return cast(Union[None, str], data)
|
|
|
|
url = _parse_url(d.pop("url"))
|
|
|
|
def _parse_tags(data: object) -> Union[None, list[str]]:
|
|
if data is None:
|
|
return data
|
|
try:
|
|
if not isinstance(data, list):
|
|
raise TypeError()
|
|
tags_type_0 = cast(list[str], data)
|
|
|
|
return tags_type_0
|
|
except: # noqa: E722
|
|
pass
|
|
return cast(Union[None, list[str]], data)
|
|
|
|
tags = _parse_tags(d.pop("tags"))
|
|
|
|
state = State634Enum(d.pop("state"))
|
|
|
|
get_state_display = d.pop("get_state_display")
|
|
|
|
def _parse_rejection_reason(data: object) -> Union[None, RejectionReasonEnum]:
|
|
if data is None:
|
|
return data
|
|
try:
|
|
if not isinstance(data, str):
|
|
raise TypeError()
|
|
rejection_reason_type_0 = RejectionReasonEnum(data)
|
|
|
|
return rejection_reason_type_0
|
|
except: # noqa: E722
|
|
pass
|
|
return cast(Union[None, RejectionReasonEnum], data)
|
|
|
|
rejection_reason = _parse_rejection_reason(d.pop("rejection_reason"))
|
|
|
|
created_at = isoparse(d.pop("created_at"))
|
|
|
|
updated_at = isoparse(d.pop("updated_at"))
|
|
|
|
display_time = d.pop("display_time")
|
|
|
|
status = d.pop("status")
|
|
|
|
user_uuid = UUID(d.pop("user_uuid"))
|
|
|
|
comments_count = d.pop("comments_count")
|
|
|
|
likes_count = d.pop("likes_count")
|
|
|
|
state_ordering = d.pop("state_ordering")
|
|
|
|
statistics = AdStatistic.from_dict(d.pop("statistics"))
|
|
|
|
details = d.pop("details", UNSET)
|
|
|
|
def _parse_location(data: object) -> Union["CaptureLocationType0", None, Unset]:
|
|
if data is None:
|
|
return data
|
|
if isinstance(data, Unset):
|
|
return data
|
|
try:
|
|
if not isinstance(data, dict):
|
|
raise TypeError()
|
|
location_type_0 = CaptureLocationType0.from_dict(data)
|
|
|
|
return location_type_0
|
|
except: # noqa: E722
|
|
pass
|
|
return cast(Union["CaptureLocationType0", None, Unset], data)
|
|
|
|
location = _parse_location(d.pop("location", UNSET))
|
|
|
|
location_is_approximate = d.pop("location_is_approximate", UNSET)
|
|
|
|
_refined_banner = d.pop("refined_banner", UNSET)
|
|
refined_banner: Union[Unset, RefinedAdBanner]
|
|
if isinstance(_refined_banner, Unset):
|
|
refined_banner = UNSET
|
|
else:
|
|
refined_banner = RefinedAdBanner.from_dict(_refined_banner)
|
|
|
|
def _parse_new_title(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)
|
|
|
|
new_title = _parse_new_title(d.pop("new_title", UNSET))
|
|
|
|
def _parse_new_description(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)
|
|
|
|
new_description = _parse_new_description(d.pop("new_description", UNSET))
|
|
|
|
def _parse_new_banner(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)
|
|
|
|
new_banner = _parse_new_banner(d.pop("new_banner", UNSET))
|
|
|
|
def _parse_new_url(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)
|
|
|
|
new_url = _parse_new_url(d.pop("new_url", UNSET))
|
|
|
|
new_tags = d.pop("new_tags", UNSET)
|
|
|
|
def _parse_new_address(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)
|
|
|
|
new_address = _parse_new_address(d.pop("new_address", UNSET))
|
|
|
|
def _parse_new_reward_amount(data: object) -> Union[None, Unset, int]:
|
|
if data is None:
|
|
return data
|
|
if isinstance(data, Unset):
|
|
return data
|
|
return cast(Union[None, Unset, int], data)
|
|
|
|
new_reward_amount = _parse_new_reward_amount(d.pop("new_reward_amount", UNSET))
|
|
|
|
def _parse_new_reward_count(data: object) -> Union[None, Unset, int]:
|
|
if data is None:
|
|
return data
|
|
if isinstance(data, Unset):
|
|
return data
|
|
return cast(Union[None, Unset, int], data)
|
|
|
|
new_reward_count = _parse_new_reward_count(d.pop("new_reward_count", UNSET))
|
|
|
|
capture = cls(
|
|
uuid=uuid,
|
|
title=title,
|
|
type_=type_,
|
|
contents=contents,
|
|
refined_contents=refined_contents,
|
|
description=description,
|
|
banner=banner,
|
|
reward_amount=reward_amount,
|
|
reward_count=reward_count,
|
|
balance=balance,
|
|
address=address,
|
|
url=url,
|
|
tags=tags,
|
|
state=state,
|
|
get_state_display=get_state_display,
|
|
rejection_reason=rejection_reason,
|
|
created_at=created_at,
|
|
updated_at=updated_at,
|
|
display_time=display_time,
|
|
status=status,
|
|
user_uuid=user_uuid,
|
|
comments_count=comments_count,
|
|
likes_count=likes_count,
|
|
state_ordering=state_ordering,
|
|
statistics=statistics,
|
|
details=details,
|
|
location=location,
|
|
location_is_approximate=location_is_approximate,
|
|
refined_banner=refined_banner,
|
|
new_title=new_title,
|
|
new_description=new_description,
|
|
new_banner=new_banner,
|
|
new_url=new_url,
|
|
new_tags=new_tags,
|
|
new_address=new_address,
|
|
new_reward_amount=new_reward_amount,
|
|
new_reward_count=new_reward_count,
|
|
)
|
|
|
|
capture.additional_properties = d
|
|
return capture
|
|
|
|
@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
|