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 .access_model_enum import AccessModelEnum from .attendance_type_enum import AttendanceTypeEnum from .category_enum import CategoryEnum from .new_content_type_enum import NewContentTypeEnum from .payment_state_enum import PaymentStateEnum from .price_model_enum import PriceModelEnum from .product_condition_enum import ProductConditionEnum from .rejection_reason_enum import RejectionReasonEnum from .role_enum import RoleEnum from .state_634_enum import State634Enum from .transportation_cost_enum import TransportationCostEnum from .type_0d9_enum import Type0D9Enum from ..types import UNSET, Unset if TYPE_CHECKING: from .ad_content import AdContent from .ad_owner_location_type_0 import AdOwnerLocationType0 from .ad_owner_new_location_type_0 import AdOwnerNewLocationType0 from .ad_statistic import AdStatistic from .refined_ad_banner import RefinedAdBanner from .refined_ad_content import RefinedAdContent T = TypeVar("T", bound="AdOwner") @_attrs_define class AdOwner: """ Attributes: uuid (UUID): title (Union[None, str]): type_ (Type0D9Enum): * `1` - BILLBOARD * `2` - CAPTURED_BILLBOARD * `99` - PROMOTION * `100` - CONSTANT content (str): contents (list['AdContent']): refined_contents (list['RefinedAdContent']): description (Union[None, str]): location (Union['AdOwnerLocationType0', None]): banner (Union[None, str]): reward_amount (int): reward_count (int): address (Union[None, str]): url (Union[None, str]): phone_number (Union[None, str]): social_link (Union[None, str]): tags (Union[None, list[str]]): payment_state (PaymentStateEnum): * `1` - created * `2` - delayed * `3` - pending * `4` - incomplete * `5` - success * `6` - failed * `7` - expected_failure 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_payment_state_display (str): 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): category (Union[Unset, CategoryEnum]): * `1` - PRODUCT * `2` - SERVICE * `3` - SOCIAL_CONTENT role (Union[Unset, RoleEnum]): * `1` - provider * `2` - requester price_model (Union[None, PriceModelEnum, Unset]): price_detail (Union[Unset, Any]): product_condition (Union[None, ProductConditionEnum, Unset]): access_model (Union[Unset, AccessModelEnum]): * `1` - free * `2` - viewer_reward * `3` - tip_supported * `4` - paid_only attendance_type (Union[AttendanceTypeEnum, None, Unset]): can_republish (Union[None, Unset, bool]): transportation_cost (Union[None, TransportationCostEnum, Unset]): work_end_time (Union[None, Unset, int]): work_start_time (Union[None, Unset, int]): details (Union[Unset, Any]): location_is_approximate (Union[Unset, bool]): refined_banner (Union[Unset, RefinedAdBanner]): balance (Union[None, Unset, int]): new_title (Union[None, Unset, str]): new_location (Union['AdOwnerNewLocationType0', None, Unset]): new_description (Union[None, Unset, str]): new_banner (Union[None, Unset, str]): new_content (Union[None, Unset, str]): new_content_type (Union[NewContentTypeEnum, None, Unset]): new_url (Union[None, Unset, str]): new_tags (Union[Unset, Any]): new_address (Union[None, Unset, str]): new_phone_number (Union[None, Unset, str]): new_social_link (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 content: str contents: list["AdContent"] refined_contents: list["RefinedAdContent"] description: Union[None, str] location: Union["AdOwnerLocationType0", None] banner: Union[None, str] reward_amount: int reward_count: int address: Union[None, str] url: Union[None, str] phone_number: Union[None, str] social_link: Union[None, str] tags: Union[None, list[str]] payment_state: PaymentStateEnum state: State634Enum get_payment_state_display: str 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" category: Union[Unset, CategoryEnum] = UNSET role: Union[Unset, RoleEnum] = UNSET price_model: Union[None, PriceModelEnum, Unset] = UNSET price_detail: Union[Unset, Any] = UNSET product_condition: Union[None, ProductConditionEnum, Unset] = UNSET access_model: Union[Unset, AccessModelEnum] = UNSET attendance_type: Union[AttendanceTypeEnum, None, Unset] = UNSET can_republish: Union[None, Unset, bool] = UNSET transportation_cost: Union[None, TransportationCostEnum, Unset] = UNSET work_end_time: Union[None, Unset, int] = UNSET work_start_time: Union[None, Unset, int] = UNSET details: Union[Unset, Any] = UNSET location_is_approximate: Union[Unset, bool] = UNSET refined_banner: Union[Unset, "RefinedAdBanner"] = UNSET balance: Union[None, Unset, int] = UNSET new_title: Union[None, Unset, str] = UNSET new_location: Union["AdOwnerNewLocationType0", None, Unset] = UNSET new_description: Union[None, Unset, str] = UNSET new_banner: Union[None, Unset, str] = UNSET new_content: Union[None, Unset, str] = UNSET new_content_type: Union[NewContentTypeEnum, None, Unset] = UNSET new_url: Union[None, Unset, str] = UNSET new_tags: Union[Unset, Any] = UNSET new_address: Union[None, Unset, str] = UNSET new_phone_number: Union[None, Unset, str] = UNSET new_social_link: 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 .ad_owner_location_type_0 import AdOwnerLocationType0 from .ad_owner_new_location_type_0 import AdOwnerNewLocationType0 uuid = str(self.uuid) title: Union[None, str] title = self.title type_ = self.type_.value content = self.content 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 location: Union[None, dict[str, Any]] if isinstance(self.location, AdOwnerLocationType0): location = self.location.to_dict() else: location = self.location banner: Union[None, str] banner = self.banner reward_amount = self.reward_amount reward_count = self.reward_count address: Union[None, str] address = self.address url: Union[None, str] url = self.url phone_number: Union[None, str] phone_number = self.phone_number social_link: Union[None, str] social_link = self.social_link tags: Union[None, list[str]] if isinstance(self.tags, list): tags = self.tags else: tags = self.tags payment_state = self.payment_state.value state = self.state.value get_payment_state_display = self.get_payment_state_display 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() category: Union[Unset, int] = UNSET if not isinstance(self.category, Unset): category = self.category.value role: Union[Unset, int] = UNSET if not isinstance(self.role, Unset): role = self.role.value price_model: Union[None, Unset, int] if isinstance(self.price_model, Unset): price_model = UNSET elif isinstance(self.price_model, PriceModelEnum): price_model = self.price_model.value else: price_model = self.price_model price_detail = self.price_detail product_condition: Union[None, Unset, int] if isinstance(self.product_condition, Unset): product_condition = UNSET elif isinstance(self.product_condition, ProductConditionEnum): product_condition = self.product_condition.value else: product_condition = self.product_condition access_model: Union[Unset, int] = UNSET if not isinstance(self.access_model, Unset): access_model = self.access_model.value attendance_type: Union[None, Unset, int] if isinstance(self.attendance_type, Unset): attendance_type = UNSET elif isinstance(self.attendance_type, AttendanceTypeEnum): attendance_type = self.attendance_type.value else: attendance_type = self.attendance_type can_republish: Union[None, Unset, bool] if isinstance(self.can_republish, Unset): can_republish = UNSET else: can_republish = self.can_republish transportation_cost: Union[None, Unset, int] if isinstance(self.transportation_cost, Unset): transportation_cost = UNSET elif isinstance(self.transportation_cost, TransportationCostEnum): transportation_cost = self.transportation_cost.value else: transportation_cost = self.transportation_cost work_end_time: Union[None, Unset, int] if isinstance(self.work_end_time, Unset): work_end_time = UNSET else: work_end_time = self.work_end_time work_start_time: Union[None, Unset, int] if isinstance(self.work_start_time, Unset): work_start_time = UNSET else: work_start_time = self.work_start_time details = self.details 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() balance: Union[None, Unset, int] if isinstance(self.balance, Unset): balance = UNSET else: balance = self.balance new_title: Union[None, Unset, str] if isinstance(self.new_title, Unset): new_title = UNSET else: new_title = self.new_title new_location: Union[None, Unset, dict[str, Any]] if isinstance(self.new_location, Unset): new_location = UNSET elif isinstance(self.new_location, AdOwnerNewLocationType0): new_location = self.new_location.to_dict() else: new_location = self.new_location 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_content: Union[None, Unset, str] if isinstance(self.new_content, Unset): new_content = UNSET else: new_content = self.new_content new_content_type: Union[None, Unset, int] if isinstance(self.new_content_type, Unset): new_content_type = UNSET elif isinstance(self.new_content_type, NewContentTypeEnum): new_content_type = self.new_content_type.value else: new_content_type = self.new_content_type 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_phone_number: Union[None, Unset, str] if isinstance(self.new_phone_number, Unset): new_phone_number = UNSET else: new_phone_number = self.new_phone_number new_social_link: Union[None, Unset, str] if isinstance(self.new_social_link, Unset): new_social_link = UNSET else: new_social_link = self.new_social_link 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_, "content": content, "contents": contents, "refined_contents": refined_contents, "description": description, "location": location, "banner": banner, "reward_amount": reward_amount, "reward_count": reward_count, "address": address, "url": url, "phone_number": phone_number, "social_link": social_link, "tags": tags, "payment_state": payment_state, "state": state, "get_payment_state_display": get_payment_state_display, "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 category is not UNSET: field_dict["category"] = category if role is not UNSET: field_dict["role"] = role if price_model is not UNSET: field_dict["price_model"] = price_model if price_detail is not UNSET: field_dict["price_detail"] = price_detail if product_condition is not UNSET: field_dict["product_condition"] = product_condition if access_model is not UNSET: field_dict["access_model"] = access_model if attendance_type is not UNSET: field_dict["attendance_type"] = attendance_type if can_republish is not UNSET: field_dict["can_republish"] = can_republish if transportation_cost is not UNSET: field_dict["transportation_cost"] = transportation_cost if work_end_time is not UNSET: field_dict["work_end_time"] = work_end_time if work_start_time is not UNSET: field_dict["work_start_time"] = work_start_time if details is not UNSET: field_dict["details"] = details 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 balance is not UNSET: field_dict["balance"] = balance if new_title is not UNSET: field_dict["new_title"] = new_title if new_location is not UNSET: field_dict["new_location"] = new_location 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_content is not UNSET: field_dict["new_content"] = new_content if new_content_type is not UNSET: field_dict["new_content_type"] = new_content_type 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_phone_number is not UNSET: field_dict["new_phone_number"] = new_phone_number if new_social_link is not UNSET: field_dict["new_social_link"] = new_social_link 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_owner_location_type_0 import AdOwnerLocationType0 from .ad_owner_new_location_type_0 import AdOwnerNewLocationType0 from .ad_statistic import AdStatistic 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")) content = d.pop("content") 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_location(data: object) -> Union["AdOwnerLocationType0", None]: if data is None: return data try: if not isinstance(data, dict): raise TypeError() location_type_0 = AdOwnerLocationType0.from_dict(data) return location_type_0 except: # noqa: E722 pass return cast(Union["AdOwnerLocationType0", None], data) location = _parse_location(d.pop("location")) 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_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_phone_number(data: object) -> Union[None, str]: if data is None: return data return cast(Union[None, str], data) phone_number = _parse_phone_number(d.pop("phone_number")) def _parse_social_link(data: object) -> Union[None, str]: if data is None: return data return cast(Union[None, str], data) social_link = _parse_social_link(d.pop("social_link")) 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")) payment_state = PaymentStateEnum(d.pop("payment_state")) state = State634Enum(d.pop("state")) get_payment_state_display = d.pop("get_payment_state_display") 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")) _category = d.pop("category", UNSET) category: Union[Unset, CategoryEnum] if isinstance(_category, Unset): category = UNSET else: category = CategoryEnum(_category) _role = d.pop("role", UNSET) role: Union[Unset, RoleEnum] if isinstance(_role, Unset): role = UNSET else: role = RoleEnum(_role) def _parse_price_model(data: object) -> Union[None, PriceModelEnum, Unset]: if data is None: return data if isinstance(data, Unset): return data try: if not isinstance(data, int): raise TypeError() price_model_type_0 = PriceModelEnum(data) return price_model_type_0 except: # noqa: E722 pass return cast(Union[None, PriceModelEnum, Unset], data) price_model = _parse_price_model(d.pop("price_model", UNSET)) price_detail = d.pop("price_detail", UNSET) def _parse_product_condition(data: object) -> Union[None, ProductConditionEnum, Unset]: if data is None: return data if isinstance(data, Unset): return data try: if not isinstance(data, int): raise TypeError() product_condition_type_0 = ProductConditionEnum(data) return product_condition_type_0 except: # noqa: E722 pass return cast(Union[None, ProductConditionEnum, Unset], data) product_condition = _parse_product_condition(d.pop("product_condition", UNSET)) _access_model = d.pop("access_model", UNSET) access_model: Union[Unset, AccessModelEnum] if isinstance(_access_model, Unset): access_model = UNSET else: access_model = AccessModelEnum(_access_model) def _parse_attendance_type(data: object) -> Union[AttendanceTypeEnum, None, Unset]: if data is None: return data if isinstance(data, Unset): return data try: if not isinstance(data, int): raise TypeError() attendance_type_type_0 = AttendanceTypeEnum(data) return attendance_type_type_0 except: # noqa: E722 pass return cast(Union[AttendanceTypeEnum, None, Unset], data) attendance_type = _parse_attendance_type(d.pop("attendance_type", UNSET)) def _parse_can_republish(data: object) -> Union[None, Unset, bool]: if data is None: return data if isinstance(data, Unset): return data return cast(Union[None, Unset, bool], data) can_republish = _parse_can_republish(d.pop("can_republish", UNSET)) def _parse_transportation_cost(data: object) -> Union[None, TransportationCostEnum, Unset]: if data is None: return data if isinstance(data, Unset): return data try: if not isinstance(data, int): raise TypeError() transportation_cost_type_0 = TransportationCostEnum(data) return transportation_cost_type_0 except: # noqa: E722 pass return cast(Union[None, TransportationCostEnum, Unset], data) transportation_cost = _parse_transportation_cost(d.pop("transportation_cost", UNSET)) def _parse_work_end_time(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) work_end_time = _parse_work_end_time(d.pop("work_end_time", UNSET)) def _parse_work_start_time(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) work_start_time = _parse_work_start_time(d.pop("work_start_time", UNSET)) details = d.pop("details", 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_balance(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) balance = _parse_balance(d.pop("balance", UNSET)) 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_location(data: object) -> Union["AdOwnerNewLocationType0", None, Unset]: if data is None: return data if isinstance(data, Unset): return data try: if not isinstance(data, dict): raise TypeError() new_location_type_0 = AdOwnerNewLocationType0.from_dict(data) return new_location_type_0 except: # noqa: E722 pass return cast(Union["AdOwnerNewLocationType0", None, Unset], data) new_location = _parse_new_location(d.pop("new_location", 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_content(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_content = _parse_new_content(d.pop("new_content", UNSET)) def _parse_new_content_type(data: object) -> Union[NewContentTypeEnum, None, Unset]: if data is None: return data if isinstance(data, Unset): return data try: if not isinstance(data, int): raise TypeError() new_content_type_type_0 = NewContentTypeEnum(data) return new_content_type_type_0 except: # noqa: E722 pass return cast(Union[NewContentTypeEnum, None, Unset], data) new_content_type = _parse_new_content_type(d.pop("new_content_type", 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_phone_number(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_phone_number = _parse_new_phone_number(d.pop("new_phone_number", UNSET)) def _parse_new_social_link(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_social_link = _parse_new_social_link(d.pop("new_social_link", 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)) ad_owner = cls( uuid=uuid, title=title, type_=type_, content=content, contents=contents, refined_contents=refined_contents, description=description, location=location, banner=banner, reward_amount=reward_amount, reward_count=reward_count, address=address, url=url, phone_number=phone_number, social_link=social_link, tags=tags, payment_state=payment_state, state=state, get_payment_state_display=get_payment_state_display, 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, category=category, role=role, price_model=price_model, price_detail=price_detail, product_condition=product_condition, access_model=access_model, attendance_type=attendance_type, can_republish=can_republish, transportation_cost=transportation_cost, work_end_time=work_end_time, work_start_time=work_start_time, details=details, location_is_approximate=location_is_approximate, refined_banner=refined_banner, balance=balance, new_title=new_title, new_location=new_location, new_description=new_description, new_banner=new_banner, new_content=new_content, new_content_type=new_content_type, new_url=new_url, new_tags=new_tags, new_address=new_address, new_phone_number=new_phone_number, new_social_link=new_social_link, new_reward_amount=new_reward_amount, new_reward_count=new_reward_count, ) ad_owner.additional_properties = d return ad_owner @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