import datetime from typing import ( TYPE_CHECKING, Any, BinaryIO, Dict, List, Optional, TextIO, Tuple, Type, TypeVar, Union, cast, ) import attr from dateutil.parser import isoparse from ..models.campaign_call_to_action import CampaignCallToAction from ..models.campaign_content_type import CampaignContentType from ..models.campaign_link_type import CampaignLinkType from ..models.campaign_objective import CampaignObjective from ..models.campaign_platform import CampaignPlatform from ..models.campaign_status import CampaignStatus from ..types import UNSET, Unset if TYPE_CHECKING: from ..models.meta_campaign_image import MetaCampaignImage from ..models.meta_campaign_video import MetaCampaignVideo T = TypeVar("T", bound="MetaCampaign") @attr.s(auto_attribs=True) class MetaCampaign: """ Attributes: id (str): name (str): vendor_id (int): subaccount_id (int): global_participant_id (str): status (CampaignStatus): An enumeration. facebook_page_id (str): content_type (CampaignContentType): An enumeration. objective (CampaignObjective): An enumeration. platforms (List[CampaignPlatform]): created_at (datetime.datetime): created_by (str): updated_at (datetime.datetime): updated_by (str): images (List['MetaCampaignImage']): videos (List['MetaCampaignVideo']): product_id (Union[Unset, None, int]): product_upc (Union[Unset, None, str]): instagram_account_id (Union[Unset, None, str]): post_external_id (Union[Unset, None, str]): start_time (Union[Unset, None, datetime.datetime]): end_time (Union[Unset, None, datetime.datetime]): lifetime_budget (Union[Unset, None, float]): primary_text (Union[Unset, None, str]): headline (Union[Unset, None, str]): description (Union[Unset, None, str]): link_type (Union[Unset, None, CampaignLinkType]): An enumeration. website_url (Union[Unset, None, str]): landing_page_path (Union[Unset, None, str]): Songwhip landing page path landing_page_product_id (Union[Unset, None, int]): Songwhip landing page product Id call_to_action (Union[Unset, None, CampaignCallToAction]): An enumeration. """ id: str name: str vendor_id: int subaccount_id: int global_participant_id: str status: CampaignStatus facebook_page_id: str content_type: CampaignContentType objective: CampaignObjective platforms: List[CampaignPlatform] created_at: datetime.datetime created_by: str updated_at: datetime.datetime updated_by: str images: List["MetaCampaignImage"] videos: List["MetaCampaignVideo"] product_id: Union[Unset, None, int] = UNSET product_upc: Union[Unset, None, str] = UNSET instagram_account_id: Union[Unset, None, str] = UNSET post_external_id: Union[Unset, None, str] = UNSET start_time: Union[Unset, None, datetime.datetime] = UNSET end_time: Union[Unset, None, datetime.datetime] = UNSET lifetime_budget: Union[Unset, None, float] = UNSET primary_text: Union[Unset, None, str] = UNSET headline: Union[Unset, None, str] = UNSET description: Union[Unset, None, str] = UNSET link_type: Union[Unset, None, CampaignLinkType] = UNSET website_url: Union[Unset, None, str] = UNSET landing_page_path: Union[Unset, None, str] = UNSET landing_page_product_id: Union[Unset, None, int] = UNSET call_to_action: Union[Unset, None, CampaignCallToAction] = UNSET additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) def to_dict(self) -> Dict[str, Any]: from ..models.meta_campaign_image import MetaCampaignImage from ..models.meta_campaign_video import MetaCampaignVideo id = self.id name = self.name vendor_id = self.vendor_id subaccount_id = self.subaccount_id global_participant_id = self.global_participant_id status = self.status.value facebook_page_id = self.facebook_page_id content_type = self.content_type.value objective = self.objective.value platforms = [] for platforms_item_data in self.platforms: platforms_item = platforms_item_data.value platforms.append(platforms_item) created_at = self.created_at.isoformat() created_by = self.created_by updated_at = self.updated_at.isoformat() updated_by = self.updated_by images = [] for images_item_data in self.images: images_item = images_item_data.to_dict() images.append(images_item) videos = [] for videos_item_data in self.videos: videos_item = videos_item_data.to_dict() videos.append(videos_item) product_id = self.product_id product_upc = self.product_upc instagram_account_id = self.instagram_account_id post_external_id = self.post_external_id start_time: Union[Unset, None, str] = UNSET if not isinstance(self.start_time, Unset): start_time = self.start_time.isoformat() if self.start_time else None end_time: Union[Unset, None, str] = UNSET if not isinstance(self.end_time, Unset): end_time = self.end_time.isoformat() if self.end_time else None lifetime_budget = self.lifetime_budget primary_text = self.primary_text headline = self.headline description = self.description link_type: Union[Unset, None, str] = UNSET if not isinstance(self.link_type, Unset): link_type = self.link_type.value if self.link_type else None website_url = self.website_url landing_page_path = self.landing_page_path landing_page_product_id = self.landing_page_product_id call_to_action: Union[Unset, None, str] = UNSET if not isinstance(self.call_to_action, Unset): call_to_action = self.call_to_action.value if self.call_to_action else None field_dict: Dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update( { "id": id, "name": name, "vendorId": vendor_id, "subaccountId": subaccount_id, "globalParticipantId": global_participant_id, "status": status, "facebookPageId": facebook_page_id, "contentType": content_type, "objective": objective, "platforms": platforms, "createdAt": created_at, "createdBy": created_by, "updatedAt": updated_at, "updatedBy": updated_by, "images": images, "videos": videos, } ) if product_id is not UNSET: field_dict["productId"] = product_id if product_upc is not UNSET: field_dict["productUpc"] = product_upc if instagram_account_id is not UNSET: field_dict["instagramAccountId"] = instagram_account_id if post_external_id is not UNSET: field_dict["postExternalId"] = post_external_id if start_time is not UNSET: field_dict["startTime"] = start_time if end_time is not UNSET: field_dict["endTime"] = end_time if lifetime_budget is not UNSET: field_dict["lifetimeBudget"] = lifetime_budget if primary_text is not UNSET: field_dict["primaryText"] = primary_text if headline is not UNSET: field_dict["headline"] = headline if description is not UNSET: field_dict["description"] = description if link_type is not UNSET: field_dict["linkType"] = link_type if website_url is not UNSET: field_dict["websiteUrl"] = website_url if landing_page_path is not UNSET: field_dict["landingPagePath"] = landing_page_path if landing_page_product_id is not UNSET: field_dict["landingPageProductId"] = landing_page_product_id if call_to_action is not UNSET: field_dict["callToAction"] = call_to_action return field_dict @classmethod def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: from ..models.meta_campaign_image import MetaCampaignImage from ..models.meta_campaign_video import MetaCampaignVideo d = src_dict.copy() id = d.pop("id") name = d.pop("name") vendor_id = d.pop("vendorId") subaccount_id = d.pop("subaccountId") global_participant_id = d.pop("globalParticipantId") status = CampaignStatus(d.pop("status")) facebook_page_id = d.pop("facebookPageId") content_type = CampaignContentType(d.pop("contentType")) objective = CampaignObjective(d.pop("objective")) platforms = [] _platforms = d.pop("platforms") for platforms_item_data in _platforms: platforms_item = CampaignPlatform(platforms_item_data) platforms.append(platforms_item) created_at = isoparse(d.pop("createdAt")) created_by = d.pop("createdBy") updated_at = isoparse(d.pop("updatedAt")) updated_by = d.pop("updatedBy") images = [] _images = d.pop("images") for images_item_data in _images: images_item = MetaCampaignImage.from_dict(images_item_data) images.append(images_item) videos = [] _videos = d.pop("videos") for videos_item_data in _videos: videos_item = MetaCampaignVideo.from_dict(videos_item_data) videos.append(videos_item) product_id = d.pop("productId", UNSET) product_upc = d.pop("productUpc", UNSET) instagram_account_id = d.pop("instagramAccountId", UNSET) post_external_id = d.pop("postExternalId", UNSET) _start_time = d.pop("startTime", UNSET) start_time: Union[Unset, None, datetime.datetime] if _start_time is None: start_time = None elif isinstance(_start_time, Unset): start_time = UNSET else: start_time = isoparse(_start_time) _end_time = d.pop("endTime", UNSET) end_time: Union[Unset, None, datetime.datetime] if _end_time is None: end_time = None elif isinstance(_end_time, Unset): end_time = UNSET else: end_time = isoparse(_end_time) lifetime_budget = d.pop("lifetimeBudget", UNSET) primary_text = d.pop("primaryText", UNSET) headline = d.pop("headline", UNSET) description = d.pop("description", UNSET) _link_type = d.pop("linkType", UNSET) link_type: Union[Unset, None, CampaignLinkType] if _link_type is None: link_type = None elif isinstance(_link_type, Unset): link_type = UNSET else: link_type = CampaignLinkType(_link_type) website_url = d.pop("websiteUrl", UNSET) landing_page_path = d.pop("landingPagePath", UNSET) landing_page_product_id = d.pop("landingPageProductId", UNSET) _call_to_action = d.pop("callToAction", UNSET) call_to_action: Union[Unset, None, CampaignCallToAction] if _call_to_action is None: call_to_action = None elif isinstance(_call_to_action, Unset): call_to_action = UNSET else: call_to_action = CampaignCallToAction(_call_to_action) meta_campaign = cls( id=id, name=name, vendor_id=vendor_id, subaccount_id=subaccount_id, global_participant_id=global_participant_id, status=status, facebook_page_id=facebook_page_id, content_type=content_type, objective=objective, platforms=platforms, created_at=created_at, created_by=created_by, updated_at=updated_at, updated_by=updated_by, images=images, videos=videos, product_id=product_id, product_upc=product_upc, instagram_account_id=instagram_account_id, post_external_id=post_external_id, start_time=start_time, end_time=end_time, lifetime_budget=lifetime_budget, primary_text=primary_text, headline=headline, description=description, link_type=link_type, website_url=website_url, landing_page_path=landing_page_path, landing_page_product_id=landing_page_product_id, call_to_action=call_to_action, ) meta_campaign.additional_properties = d return meta_campaign @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