# coding: utf-8

"""
    Pinterest REST API

    Pinterest's REST API

    The version of the OpenAPI document: 5.23.0
    Contact: blah+oapicf@cliffano.com
    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 pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing import Optional, Set
from typing_extensions import Self

class ConversionTagConfigs(BaseModel):
    """
    ConversionTagConfigs
    """ # noqa: E501
    aem_db_enabled: Optional[StrictBool] = Field(default=False, description="Whether Automatic Enhanced Match birthdate is enabled. See [Enhanced match](https://help.pinterest.com/en/business/article/enhanced-match) for more information.")
    aem_enabled: Optional[StrictBool] = Field(default=False, description="Whether Automatic Enhanced Match email is enabled. See [Enhanced match](https://help.pinterest.com/en/business/article/enhanced-match) for more information.")
    aem_external_id_enabled: Optional[StrictBool] = Field(default=False, description="Whether Automatic Enhanced Match location is enabled. See [Enhanced match](https://help.pinterest.com/en/business/article/enhanced-match) for more information.")
    aem_fnln_enabled: Optional[StrictBool] = Field(default=False, description="Whether Automatic Enhanced Match name is enabled. See [Enhanced match](https://help.pinterest.com/en/business/article/enhanced-match) for more information.")
    aem_ge_enabled: Optional[StrictBool] = Field(default=False, description="Whether Automatic Enhanced Match gender is enabled. See [Enhanced match](https://help.pinterest.com/en/business/article/enhanced-match) for more information.")
    aem_loc_enabled: Optional[StrictBool] = Field(default=False, description="Whether Automatic Enhanced Match location is enabled. See [Enhanced match](https://help.pinterest.com/en/business/article/enhanced-match) for more information.")
    aem_ph_enabled: Optional[StrictBool] = Field(default=False, description="Whether Automatic Enhanced Match phone is enabled. See [Enhanced match](https://help.pinterest.com/en/business/article/enhanced-match) for more information.")
    md_frequency: Optional[Union[StrictFloat, StrictInt]] = Field(default=1, description="Metadata ingestion frequency.")
    no_code_capi_domains: Optional[List[StrictStr]] = Field(default=None, description="List of advertiser subdomains configured for NoCodeCAPI calls.")
    __properties: ClassVar[List[str]] = ["aem_db_enabled", "aem_enabled", "aem_external_id_enabled", "aem_fnln_enabled", "aem_ge_enabled", "aem_loc_enabled", "aem_ph_enabled", "md_frequency", "no_code_capi_domains"]

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


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of ConversionTagConfigs from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    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,
        )
        # set to None if aem_db_enabled (nullable) is None
        # and model_fields_set contains the field
        if self.aem_db_enabled is None and "aem_db_enabled" in self.model_fields_set:
            _dict['aem_db_enabled'] = None

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "aem_db_enabled": obj.get("aem_db_enabled") if obj.get("aem_db_enabled") is not None else False,
            "aem_enabled": obj.get("aem_enabled") if obj.get("aem_enabled") is not None else False,
            "aem_external_id_enabled": obj.get("aem_external_id_enabled") if obj.get("aem_external_id_enabled") is not None else False,
            "aem_fnln_enabled": obj.get("aem_fnln_enabled") if obj.get("aem_fnln_enabled") is not None else False,
            "aem_ge_enabled": obj.get("aem_ge_enabled") if obj.get("aem_ge_enabled") is not None else False,
            "aem_loc_enabled": obj.get("aem_loc_enabled") if obj.get("aem_loc_enabled") is not None else False,
            "aem_ph_enabled": obj.get("aem_ph_enabled") if obj.get("aem_ph_enabled") is not None else False,
            "md_frequency": obj.get("md_frequency") if obj.get("md_frequency") is not None else 1,
            "no_code_capi_domains": obj.get("no_code_capi_domains")
        })
        return _obj


