# 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 BroadMatchSearchQueryKPI(BaseModel):
    """
    BroadMatchSearchQueryKPI
    """ # noqa: E501
    search_query: Optional[StrictStr] = Field(default=None, alias="SearchQuery")
    impressions: Optional[StrictStr] = Field(default=None, alias="Impressions")
    clicks: Optional[StrictFloat] = Field(default=None, alias="Clicks")
    srpv: Optional[StrictStr] = Field(default=None, alias="SRPV")
    average_ctr: Optional[StrictFloat] = Field(default=None, alias="AverageCTR")
    __properties: ClassVar[List[str]] = ["SearchQuery", "Impressions", "Clicks", "SRPV", "AverageCTR"]

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "SearchQuery": obj.get("SearchQuery") if obj.get("SearchQuery") is not None else None,
                        "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,
                        "SRPV": obj.get("SRPV") if obj.get("SRPV") is not None else None,
                        "AverageCTR": obj.get("AverageCTR") if obj.get("AverageCTR") is not None else None
        })
        return _obj
