# 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 AuctionInsightKpi(BaseModel):
    """
    AuctionInsightKpi
    """ # noqa: E501
    segments: Optional[List[StrictStr]] = Field(default=None, alias="Segments")
    impression_share: Optional[StrictFloat] = Field(default=None, alias="ImpressionShare")
    overlap_rate: Optional[StrictFloat] = Field(default=None, alias="OverlapRate")
    average_position: Optional[StrictFloat] = Field(default=None, alias="AveragePosition")
    above_rate: Optional[StrictFloat] = Field(default=None, alias="AboveRate")
    top_of_page_rate: Optional[StrictFloat] = Field(default=None, alias="TopOfPageRate")
    outranking_share: Optional[StrictFloat] = Field(default=None, alias="OutrankingShare")
    absolute_top_of_page_rate: Optional[StrictFloat] = Field(default=None, alias="AbsoluteTopOfPageRate")
    __properties: ClassVar[List[str]] = ["Segments", "ImpressionShare", "OverlapRate", "AveragePosition", "AboveRate", "TopOfPageRate", "OutrankingShare", "AbsoluteTopOfPageRate"]

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "Segments": obj.get("Segments"),
                        "ImpressionShare": obj.get("ImpressionShare") if obj.get("ImpressionShare") is not None else None,
                        "OverlapRate": obj.get("OverlapRate") if obj.get("OverlapRate") is not None else None,
                        "AveragePosition": obj.get("AveragePosition") if obj.get("AveragePosition") is not None else None,
                        "AboveRate": obj.get("AboveRate") if obj.get("AboveRate") is not None else None,
                        "TopOfPageRate": obj.get("TopOfPageRate") if obj.get("TopOfPageRate") is not None else None,
                        "OutrankingShare": obj.get("OutrankingShare") if obj.get("OutrankingShare") is not None else None,
                        "AbsoluteTopOfPageRate": obj.get("AbsoluteTopOfPageRate") if obj.get("AbsoluteTopOfPageRate") is not None else None
        })
        return _obj
