# 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 typing_extensions import Self

class PerformanceMaxSetting(BaseModel):
    """
    PerformanceMaxSetting
    """ # noqa: E501
    final_url_expansion_opt_out: Optional[StrictBool] = Field(default=None, alias="FinalUrlExpansionOptOut")
    page_feed_ids: Optional[List[StrictStr]] = Field(default=None, alias="PageFeedIds")
    auto_generated_text_opt_out: Optional[StrictBool] = Field(default=None, alias="AutoGeneratedTextOptOut")
    auto_generated_image_opt_out: Optional[StrictBool] = Field(default=None, alias="AutoGeneratedImageOptOut")
    cost_per_sale_opt_out: Optional[StrictBool] = Field(default=None, alias="CostPerSaleOptOut")
    type: Optional[StrictStr] = Field(default='PerformanceMaxSetting', alias="Type")
    __properties: ClassVar[List[str]] = ["FinalUrlExpansionOptOut", "PageFeedIds", "AutoGeneratedTextOptOut", "AutoGeneratedImageOptOut", "CostPerSaleOptOut", "Type"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )
	
    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 PerformanceMaxSetting 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 final_url_expansion_opt_out (nullable) is None
        # and model_fields_set contains the field
        if self.final_url_expansion_opt_out is None and "final_url_expansion_opt_out" in self.model_fields_set:
            _dict['FinalUrlExpansionOptOut'] = None

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "FinalUrlExpansionOptOut": obj.get("FinalUrlExpansionOptOut") if obj.get("FinalUrlExpansionOptOut") is not None else None,
                        "PageFeedIds": obj.get("PageFeedIds"),
                        "AutoGeneratedTextOptOut": obj.get("AutoGeneratedTextOptOut") if obj.get("AutoGeneratedTextOptOut") is not None else None,
                        "AutoGeneratedImageOptOut": obj.get("AutoGeneratedImageOptOut") if obj.get("AutoGeneratedImageOptOut") is not None else None,
                        "CostPerSaleOptOut": obj.get("CostPerSaleOptOut") if obj.get("CostPerSaleOptOut") is not None else None,
                        "Type": obj.get("Type") if obj.get("Type") is not None else 'PerformanceMaxSetting'
        })
        return _obj
