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_statistic import AdStatistic from .patched_ad_owner_location_type_0 import PatchedAdOwnerLocationType0 from .patched_ad_owner_new_location_type_0 import PatchedAdOwnerNewLocationType0 from .refined_ad_banner import RefinedAdBanner from .refined_ad_content import RefinedAdContent T = TypeVar("T", bound="PatchedAdOwner") @_attrs_define class PatchedAdOwner: """ Attributes: uuid (Union[Unset, UUID]): title (Union[None, Unset, str]): type_ (Union[Unset, Type0D9Enum]): * `1` - BILLBOARD * `2` - CAPTURED_BILLBOARD * `99` - PROMOTION * `100` - CONSTANT 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]): content (Union[Unset, str]): contents (Union[Unset, list['AdContent']]): refined_contents (Union[Unset, list['RefinedAdContent']]): description (Union[None, Unset, str]): location (Union['PatchedAdOwnerLocationType0', None, Unset]): location_is_approximate (Union[Unset, bool]): banner (Union[None, Unset, str]): refined_banner (Union[Unset, RefinedAdBanner]): reward_amount (Union[Unset, int]): reward_count (Union[Unset, int]): balance (Union[None, Unset, int]): address (Union[None, Unset, str]): url (Union[None, Unset, str]): phone_number (Union[None, Unset, str]): social_link (Union[None, Unset, str]): tags (Union[None, Unset, list[str]]): new_title (Union[None, Unset, str]): new_location (Union['PatchedAdOwnerNewLocationType0', 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]): payment_state (Union[Unset, PaymentStateEnum]): * `1` - created * `2` - delayed * `3` - pending * `4` - incomplete * `5` - success * `6` - failed * `7` - expected_failure 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 get_payment_state_display (Union[Unset, str]): get_state_display (Union[Unset, str]): rejection_reason (Union[None, RejectionReasonEnum, Unset]): created_at (Union[Unset, datetime.datetime]): updated_at (Union[Unset, datetime.datetime]): display_time (Union[Unset, str]): status (Union[Unset, str]): user_uuid (Union[Unset, UUID]): comments_count (Union[Unset, str]): likes_count (Union[Unset, str]): state_ordering (Union[Unset, str]): statistics (Union[Unset, AdStatistic]): """ uuid: Union[Unset, UUID] = UNSET title: Union[None, Unset, str] = UNSET type_: Union[Unset, Type0D9Enum] = UNSET 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 content: Union[Unset, str] = UNSET contents: Union[Unset, list["AdContent"]] = UNSET refined_contents: Union[Unset, list["RefinedAdContent"]] = UNSET description: Union[None, Unset, str] = UNSET location: Union["PatchedAdOwnerLocationType0", None, Unset] = UNSET location_is_approximate: Union[Unset, bool] = UNSET banner: Union[None, Unset, str] = UNSET refined_banner: Union[Unset, "RefinedAdBanner"] = UNSET reward_amount: Union[Unset, int] = UNSET reward_count: Union[Unset, int] = UNSET balance: Union[None, Unset, int] = UNSET address: Union[None, Unset, str] = UNSET url: Union[None, Unset, str] = UNSET phone_number: Union[None, Unset, str] = UNSET social_link: Union[None, Unset, str] = UNSET tags: Union[None, Unset, list[str]] = UNSET new_title: Union[None, Unset, str] = UNSET new_location: Union["PatchedAdOwnerNewLocationType0", 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 payment_state: Union[Unset, PaymentStateEnum] = UNSET state: Union[Unset, State634Enum] = UNSET get_payment_state_display: Union[Unset, str] = UNSET get_state_display: Union[Unset, str] = UNSET rejection_reason: Union[None, RejectionReasonEnum, Unset] = UNSET created_at: Union[Unset, datetime.datetime] = UNSET updated_at: Union[Unset, datetime.datetime] = UNSET display_time: Union[Unset, str] = UNSET status: Union[Unset, str] = UNSET user_uuid: Union[Unset, UUID] = UNSET comments_count: Union[Unset, str] = UNSET likes_count: Union[Unset, str] = UNSET state_ordering: Union[Unset, str] = UNSET statistics: Union[Unset, "AdStatistic"] = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: from .patched_ad_owner_location_type_0 import PatchedAdOwnerLocationType0 from .patched_ad_owner_new_location_type_0 import PatchedAdOwnerNewLocationType0 uuid: Union[Unset, str] = UNSET if not isinstance(self.uuid, Unset): uuid = str(self.uuid) title: Union[None, Unset, str] if isinstance(self.title, Unset): title = UNSET else: title = self.title type_: Union[Unset, int] = UNSET if not isinstance(self.type_, Unset): type_ = self.type_.value 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 content = self.content contents: Union[Unset, list[dict[str, Any]]] = UNSET if not isinstance(self.contents, Unset): contents = [] for contents_item_data in self.contents: contents_item = contents_item_data.to_dict() contents.append(contents_item) refined_contents: Union[Unset, list[dict[str, Any]]] = UNSET if not isinstance(self.refined_contents, Unset): 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, Unset, str] if isinstance(self.description, Unset): description = UNSET else: description = self.description location: Union[None, Unset, dict[str, Any]] if isinstance(self.location, Unset): location = UNSET elif isinstance(self.location, PatchedAdOwnerLocationType0): location = self.location.to_dict() else: location = self.location location_is_approximate = self.location_is_approximate banner: Union[None, Unset, str] if isinstance(self.banner, Unset): banner = UNSET else: banner = self.banner refined_banner: Union[Unset, dict[str, Any]] = UNSET if not isinstance(self.refined_banner, Unset): refined_banner = self.refined_banner.to_dict() reward_amount = self.reward_amount reward_count = self.reward_count balance: Union[None, Unset, int] if isinstance(self.balance, Unset): balance = UNSET else: balance = self.balance address: Union[None, Unset, str] if isinstance(self.address, Unset): address = UNSET else: address = self.address url: Union[None, Unset, str] if isinstance(self.url, Unset): url = UNSET else: url = self.url phone_number: Union[None, Unset, str] if isinstance(self.phone_number, Unset): phone_number = UNSET else: phone_number = self.phone_number social_link: Union[None, Unset, str] if isinstance(self.social_link, Unset): social_link = UNSET else: social_link = self.social_link tags: Union[None, Unset, list[str]] if isinstance(self.tags, Unset): tags = UNSET elif isinstance(self.tags, list): tags = self.tags else: tags = self.tags 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, PatchedAdOwnerNewLocationType0): 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 payment_state: Union[Unset, int] = UNSET if not isinstance(self.payment_state, Unset): payment_state = self.payment_state.value state: Union[Unset, int] = UNSET if not isinstance(self.state, Unset): state = self.state.value get_payment_state_display = self.get_payment_state_display get_state_display = self.get_state_display rejection_reason: Union[None, Unset, str] if isinstance(self.rejection_reason, Unset): rejection_reason = UNSET elif isinstance(self.rejection_reason, RejectionReasonEnum): rejection_reason = self.rejection_reason.value else: rejection_reason = self.rejection_reason created_at: Union[Unset, str] = UNSET if not isinstance(self.created_at, Unset): created_at = self.created_at.isoformat() updated_at: Union[Unset, str] = UNSET if not isinstance(self.updated_at, Unset): updated_at = self.updated_at.isoformat() display_time = self.display_time status = self.status user_uuid: Union[Unset, str] = UNSET if not isinstance(self.user_uuid, Unset): user_uuid = str(self.user_uuid) comments_count = self.comments_count likes_count = self.likes_count state_ordering = self.state_ordering statistics: Union[Unset, dict[str, Any]] = UNSET if not isinstance(self.statistics, Unset): statistics = self.statistics.to_dict() field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) if uuid is not UNSET: field_dict["uuid"] = uuid if title is not UNSET: field_dict["title"] = title if type_ is not UNSET: field_dict["type"] = type_ 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 content is not UNSET: field_dict["content"] = content if contents is not UNSET: field_dict["contents"] = contents if refined_contents is not UNSET: field_dict["refined_contents"] = refined_contents if description is not UNSET: field_dict["description"] = description 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 banner is not UNSET: field_dict["banner"] = banner if refined_banner is not UNSET: field_dict["refined_banner"] = refined_banner if reward_amount is not UNSET: field_dict["reward_amount"] = reward_amount if reward_count is not UNSET: field_dict["reward_count"] = reward_count if balance is not UNSET: field_dict["balance"] = balance if address is not UNSET: field_dict["address"] = address if url is not UNSET: field_dict["url"] = url if phone_number is not UNSET: field_dict["phone_number"] = phone_number if social_link is not UNSET: field_dict["social_link"] = social_link if tags is not UNSET: field_dict["tags"] = tags 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 if payment_state is not UNSET: field_dict["payment_state"] = payment_state if state is not UNSET: field_dict["state"] = state if get_payment_state_display is not UNSET: field_dict["get_payment_state_display"] = get_payment_state_display if get_state_display is not UNSET: field_dict["get_state_display"] = get_state_display if rejection_reason is not UNSET: field_dict["rejection_reason"] = rejection_reason if created_at is not UNSET: field_dict["created_at"] = created_at if updated_at is not UNSET: field_dict["updated_at"] = updated_at if display_time is not UNSET: field_dict["display_time"] = display_time if status is not UNSET: field_dict["status"] = status if user_uuid is not UNSET: field_dict["user_uuid"] = user_uuid if comments_count is not UNSET: field_dict["comments_count"] = comments_count if likes_count is not UNSET: field_dict["likes_count"] = likes_count if state_ordering is not UNSET: field_dict["state_ordering"] = state_ordering if statistics is not UNSET: field_dict["statistics"] = statistics 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 .patched_ad_owner_location_type_0 import PatchedAdOwnerLocationType0 from .patched_ad_owner_new_location_type_0 import PatchedAdOwnerNewLocationType0 from .refined_ad_banner import RefinedAdBanner from .refined_ad_content import RefinedAdContent d = dict(src_dict) _uuid = d.pop("uuid", UNSET) uuid: Union[Unset, UUID] if isinstance(_uuid, Unset): uuid = UNSET else: uuid = UUID(_uuid) def _parse_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) title = _parse_title(d.pop("title", UNSET)) _type_ = d.pop("type", UNSET) type_: Union[Unset, Type0D9Enum] if isinstance(_type_, Unset): type_ = UNSET else: type_ = Type0D9Enum(_type_) _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) content = d.pop("content", UNSET) contents = [] _contents = d.pop("contents", UNSET) for contents_item_data in _contents or []: contents_item = AdContent.from_dict(contents_item_data) contents.append(contents_item) refined_contents = [] _refined_contents = d.pop("refined_contents", UNSET) for refined_contents_item_data in _refined_contents or []: refined_contents_item = RefinedAdContent.from_dict(refined_contents_item_data) refined_contents.append(refined_contents_item) def _parse_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) description = _parse_description(d.pop("description", UNSET)) def _parse_location(data: object) -> Union["PatchedAdOwnerLocationType0", 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 = PatchedAdOwnerLocationType0.from_dict(data) return location_type_0 except: # noqa: E722 pass return cast(Union["PatchedAdOwnerLocationType0", None, Unset], data) location = _parse_location(d.pop("location", UNSET)) location_is_approximate = d.pop("location_is_approximate", UNSET) def _parse_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) banner = _parse_banner(d.pop("banner", 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) reward_amount = d.pop("reward_amount", UNSET) reward_count = d.pop("reward_count", UNSET) 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_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) address = _parse_address(d.pop("address", UNSET)) def _parse_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) url = _parse_url(d.pop("url", UNSET)) def _parse_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) phone_number = _parse_phone_number(d.pop("phone_number", UNSET)) def _parse_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) social_link = _parse_social_link(d.pop("social_link", UNSET)) def _parse_tags(data: object) -> Union[None, Unset, list[str]]: if data is None: return data if isinstance(data, Unset): 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, Unset, list[str]], data) tags = _parse_tags(d.pop("tags", 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["PatchedAdOwnerNewLocationType0", 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 = PatchedAdOwnerNewLocationType0.from_dict(data) return new_location_type_0 except: # noqa: E722 pass return cast(Union["PatchedAdOwnerNewLocationType0", 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)) _payment_state = d.pop("payment_state", UNSET) payment_state: Union[Unset, PaymentStateEnum] if isinstance(_payment_state, Unset): payment_state = UNSET else: payment_state = PaymentStateEnum(_payment_state) _state = d.pop("state", UNSET) state: Union[Unset, State634Enum] if isinstance(_state, Unset): state = UNSET else: state = State634Enum(_state) get_payment_state_display = d.pop("get_payment_state_display", UNSET) get_state_display = d.pop("get_state_display", UNSET) def _parse_rejection_reason(data: object) -> Union[None, RejectionReasonEnum, Unset]: if data is None: return data if isinstance(data, Unset): 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, Unset], data) rejection_reason = _parse_rejection_reason(d.pop("rejection_reason", UNSET)) _created_at = d.pop("created_at", UNSET) created_at: Union[Unset, datetime.datetime] if isinstance(_created_at, Unset): created_at = UNSET else: created_at = isoparse(_created_at) _updated_at = d.pop("updated_at", UNSET) updated_at: Union[Unset, datetime.datetime] if isinstance(_updated_at, Unset): updated_at = UNSET else: updated_at = isoparse(_updated_at) display_time = d.pop("display_time", UNSET) status = d.pop("status", UNSET) _user_uuid = d.pop("user_uuid", UNSET) user_uuid: Union[Unset, UUID] if isinstance(_user_uuid, Unset): user_uuid = UNSET else: user_uuid = UUID(_user_uuid) comments_count = d.pop("comments_count", UNSET) likes_count = d.pop("likes_count", UNSET) state_ordering = d.pop("state_ordering", UNSET) _statistics = d.pop("statistics", UNSET) statistics: Union[Unset, AdStatistic] if isinstance(_statistics, Unset): statistics = UNSET else: statistics = AdStatistic.from_dict(_statistics) patched_ad_owner = cls( uuid=uuid, title=title, type_=type_, 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, content=content, contents=contents, refined_contents=refined_contents, description=description, location=location, location_is_approximate=location_is_approximate, banner=banner, refined_banner=refined_banner, reward_amount=reward_amount, reward_count=reward_count, balance=balance, address=address, url=url, phone_number=phone_number, social_link=social_link, tags=tags, 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, 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, ) patched_ad_owner.additional_properties = d return patched_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