# coding: utf-8

"""
    CampaignManagementService

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: 1.0.0
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union, Set
from openapi_client.models.campaign.ad_recommendation_customized_property import AdRecommendationCustomizedProperty
from openapi_client.models.campaign.ad_recommendation_image_asset_property import AdRecommendationImageAssetProperty
from openapi_client.models.campaign.ad_recommendation_text_asset_property import AdRecommendationTextAssetProperty
from typing_extensions import Self

class AdRecommendationImageSuggestionMetadata(BaseModel):
    """
    AdRecommendationImageSuggestionMetadata
    """ # noqa: E501
    template_id: Optional[StrictStr] = Field(default=None, alias="TemplateId")
    template_version: Optional[StrictStr] = Field(default=None, alias="TemplateVersion")
    text_asset_properties: Optional[List[Optional[AdRecommendationTextAssetProperty]]] = Field(default=None, alias="TextAssetProperties")
    image_asset_properties: Optional[List[Optional[AdRecommendationImageAssetProperty]]] = Field(default=None, alias="ImageAssetProperties")
    customized_properties: Optional[List[Optional[AdRecommendationCustomizedProperty]]] = Field(default=None, alias="CustomizedProperties")
    __properties: ClassVar[List[str]] = ["TemplateId", "TemplateVersion", "TextAssetProperties", "ImageAssetProperties", "CustomizedProperties"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )
	

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of each item in text_asset_properties (list)
        _items = []
        if self.text_asset_properties:
            for _item_text_asset_properties in self.text_asset_properties:
                if _item_text_asset_properties:
                    _items.append(_item_text_asset_properties.to_dict())
            _dict['TextAssetProperties'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in image_asset_properties (list)
        _items = []
        if self.image_asset_properties:
            for _item_image_asset_properties in self.image_asset_properties:
                if _item_image_asset_properties:
                    _items.append(_item_image_asset_properties.to_dict())
            _dict['ImageAssetProperties'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in customized_properties (list)
        _items = []
        if self.customized_properties:
            for _item_customized_properties in self.customized_properties:
                if _item_customized_properties:
                    _items.append(_item_customized_properties.to_dict())
            _dict['CustomizedProperties'] = _items
        # set to None if template_id (nullable) is None
        # and model_fields_set contains the field
        if self.template_id is None and "template_id" in self.model_fields_set:
            _dict['TemplateId'] = None

        # set to None if template_version (nullable) is None
        # and model_fields_set contains the field
        if self.template_version is None and "template_version" in self.model_fields_set:
            _dict['TemplateVersion'] = None

        # set to None if text_asset_properties (nullable) is None
        # and model_fields_set contains the field
        if self.text_asset_properties is None and "text_asset_properties" in self.model_fields_set:
            _dict['TextAssetProperties'] = None

        # set to None if image_asset_properties (nullable) is None
        # and model_fields_set contains the field
        if self.image_asset_properties is None and "image_asset_properties" in self.model_fields_set:
            _dict['ImageAssetProperties'] = None

        # set to None if customized_properties (nullable) is None
        # and model_fields_set contains the field
        if self.customized_properties is None and "customized_properties" in self.model_fields_set:
            _dict['CustomizedProperties'] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of AdRecommendationImageSuggestionMetadata from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "TemplateId": obj.get("TemplateId") if obj.get("TemplateId") is not None else None,
                        "TemplateVersion": obj.get("TemplateVersion") if obj.get("TemplateVersion") is not None else None,
                        "TextAssetProperties": [AdRecommendationTextAssetProperty.from_dict(_item) for _item in obj["TextAssetProperties"]] if obj.get("TextAssetProperties") is not None else None,
                        "ImageAssetProperties": [AdRecommendationImageAssetProperty.from_dict(_item) for _item in obj["ImageAssetProperties"]] if obj.get("ImageAssetProperties") is not None else None,
                        "CustomizedProperties": [AdRecommendationCustomizedProperty.from_dict(_item) for _item in obj["CustomizedProperties"]] if obj.get("CustomizedProperties") is not None else None
        })
        return _obj
