# coding: utf-8

"""
    AdInsightService

    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 TrafficEstimate(BaseModel):
    """
    TrafficEstimate
    """ # noqa: E501
    impressions: Optional[StrictFloat] = Field(default=None, alias="Impressions")
    clicks: Optional[StrictFloat] = Field(default=None, alias="Clicks")
    total_cost: Optional[StrictFloat] = Field(default=None, alias="TotalCost")
    ctr: Optional[StrictFloat] = Field(default=None, alias="Ctr")
    average_cpc: Optional[StrictFloat] = Field(default=None, alias="AverageCpc")
    average_position: Optional[StrictFloat] = Field(default=None, alias="AveragePosition")
    __properties: ClassVar[List[str]] = ["Impressions", "Clicks", "TotalCost", "Ctr", "AverageCpc", "AveragePosition"]

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "Impressions": obj.get("Impressions") if obj.get("Impressions") is not None else None,
                        "Clicks": obj.get("Clicks") if obj.get("Clicks") is not None else None,
                        "TotalCost": obj.get("TotalCost") if obj.get("TotalCost") is not None else None,
                        "Ctr": obj.get("Ctr") if obj.get("Ctr") is not None else None,
                        "AverageCpc": obj.get("AverageCpc") if obj.get("AverageCpc") is not None else None,
                        "AveragePosition": obj.get("AveragePosition") if obj.get("AveragePosition") is not None else None
        })
        return _obj
