# 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_additional_field import AdRecommendationAdditionalField
from openapi_client.models.campaign.ad_recommendation_image_refine_operation import AdRecommendationImageRefineOperation
from openapi_client.models.campaign.ad_recommendation_image_suggestion import AdRecommendationImageSuggestion
from openapi_client.models.campaign.ad_recommendation_text_refine_operation import AdRecommendationTextRefineOperation
from openapi_client.models.campaign.asset_group import AssetGroup
from typing_extensions import Self

class RefineAssetGroupRecommendationRequest(BaseModel):
    """
    RefineAssetGroupRecommendationRequest
    """ # noqa: E501
    asset_group: Optional[AssetGroup] = Field(default=None, alias="AssetGroup")
    text_refine_operations: Optional[List[Optional[AdRecommendationTextRefineOperation]]] = Field(default=None, alias="TextRefineOperations")
    image_suggestions: Optional[List[Optional[AdRecommendationImageSuggestion]]] = Field(default=None, alias="ImageSuggestions")
    image_refine_operations: Optional[List[Optional[AdRecommendationImageRefineOperation]]] = Field(default=None, alias="ImageRefineOperations")
    return_additional_fields: Optional[AdRecommendationAdditionalField] = Field(default=None, alias="ReturnAdditionalFields")
    __properties: ClassVar[List[str]] = ["AssetGroup", "TextRefineOperations", "ImageSuggestions", "ImageRefineOperations", "ReturnAdditionalFields"]

    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 asset_group
        if self.asset_group:
            _dict['AssetGroup'] = self.asset_group.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in text_refine_operations (list)
        _items = []
        if self.text_refine_operations:
            for _item_text_refine_operations in self.text_refine_operations:
                if _item_text_refine_operations:
                    _items.append(_item_text_refine_operations.to_dict())
            _dict['TextRefineOperations'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in image_suggestions (list)
        _items = []
        if self.image_suggestions:
            for _item_image_suggestions in self.image_suggestions:
                if _item_image_suggestions:
                    _items.append(_item_image_suggestions.to_dict())
            _dict['ImageSuggestions'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in image_refine_operations (list)
        _items = []
        if self.image_refine_operations:
            for _item_image_refine_operations in self.image_refine_operations:
                if _item_image_refine_operations:
                    _items.append(_item_image_refine_operations.to_dict())
            _dict['ImageRefineOperations'] = _items
        # set to None if asset_group (nullable) is None
        # and model_fields_set contains the field
        if self.asset_group is None and "asset_group" in self.model_fields_set:
            _dict['AssetGroup'] = None

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "AssetGroup": AssetGroup.from_dict(obj["AssetGroup"]) if obj.get("AssetGroup") is not None else None,
                        "TextRefineOperations": [AdRecommendationTextRefineOperation.from_dict(_item) for _item in obj["TextRefineOperations"]] if obj.get("TextRefineOperations") is not None else None,
                        "ImageSuggestions": [AdRecommendationImageSuggestion.from_dict(_item) for _item in obj["ImageSuggestions"]] if obj.get("ImageSuggestions") is not None else None,
                        "ImageRefineOperations": [AdRecommendationImageRefineOperation.from_dict(_item) for _item in obj["ImageRefineOperations"]] if obj.get("ImageRefineOperations") is not None else None,
                        "ReturnAdditionalFields": obj.get("ReturnAdditionalFields") if obj.get("ReturnAdditionalFields") is not None else None
        })
        return _obj
