# 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_extension_id_to_entity_id_association import AdExtensionIdToEntityIdAssociation
from openapi_client.models.campaign.association_type import AssociationType
from typing_extensions import Self

class GetAdExtensionsEditorialReasonsRequest(BaseModel):
    """
    GetAdExtensionsEditorialReasonsRequest
    """ # noqa: E501
    account_id: Optional[StrictStr] = Field(default=None, alias="AccountId")
    ad_extension_id_to_entity_id_associations: Optional[List[Optional[AdExtensionIdToEntityIdAssociation]]] = Field(default=None, alias="AdExtensionIdToEntityIdAssociations")
    association_type: Optional[AssociationType] = Field(default=None, alias="AssociationType")
    __properties: ClassVar[List[str]] = ["AccountId", "AdExtensionIdToEntityIdAssociations", "AssociationType"]

    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 ad_extension_id_to_entity_id_associations (list)
        _items = []
        if self.ad_extension_id_to_entity_id_associations:
            for _item_ad_extension_id_to_entity_id_associations in self.ad_extension_id_to_entity_id_associations:
                if _item_ad_extension_id_to_entity_id_associations:
                    _items.append(_item_ad_extension_id_to_entity_id_associations.to_dict())
            _dict['AdExtensionIdToEntityIdAssociations'] = _items
        # set to None if account_id (nullable) is None
        # and model_fields_set contains the field
        if self.account_id is None and "account_id" in self.model_fields_set:
            _dict['AccountId'] = None

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "AccountId": obj.get("AccountId") if obj.get("AccountId") is not None else None,
                        "AdExtensionIdToEntityIdAssociations": [AdExtensionIdToEntityIdAssociation.from_dict(_item) for _item in obj["AdExtensionIdToEntityIdAssociations"]] if obj.get("AdExtensionIdToEntityIdAssociations") is not None else None,
                        "AssociationType": obj.get("AssociationType") if obj.get("AssociationType") is not None else None
        })
        return _obj
