# 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 KeywordDemographic(BaseModel):
    """
    KeywordDemographic
    """ # noqa: E501
    device: Optional[StrictStr] = Field(default=None, alias="Device")
    eighteen_to_twenty_four: Optional[StrictFloat] = Field(default=None, alias="EighteenToTwentyFour")
    twenty_five_to_thirty_four: Optional[StrictFloat] = Field(default=None, alias="TwentyFiveToThirtyFour")
    thirty_five_to_fourty_nine: Optional[StrictFloat] = Field(default=None, alias="ThirtyFiveToFourtyNine")
    fifty_to_sixty_four: Optional[StrictFloat] = Field(default=None, alias="FiftyToSixtyFour")
    sixty_five_and_above: Optional[StrictFloat] = Field(default=None, alias="SixtyFiveAndAbove")
    age_unknown: Optional[StrictFloat] = Field(default=None, alias="AgeUnknown")
    female: Optional[StrictFloat] = Field(default=None, alias="Female")
    male: Optional[StrictFloat] = Field(default=None, alias="Male")
    gender_unknown: Optional[StrictFloat] = Field(default=None, alias="GenderUnknown")
    __properties: ClassVar[List[str]] = ["Device", "EighteenToTwentyFour", "TwentyFiveToThirtyFour", "ThirtyFiveToFourtyNine", "FiftyToSixtyFour", "SixtyFiveAndAbove", "AgeUnknown", "Female", "Male", "GenderUnknown"]

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "Device": obj.get("Device") if obj.get("Device") is not None else None,
                        "EighteenToTwentyFour": obj.get("EighteenToTwentyFour") if obj.get("EighteenToTwentyFour") is not None else None,
                        "TwentyFiveToThirtyFour": obj.get("TwentyFiveToThirtyFour") if obj.get("TwentyFiveToThirtyFour") is not None else None,
                        "ThirtyFiveToFourtyNine": obj.get("ThirtyFiveToFourtyNine") if obj.get("ThirtyFiveToFourtyNine") is not None else None,
                        "FiftyToSixtyFour": obj.get("FiftyToSixtyFour") if obj.get("FiftyToSixtyFour") is not None else None,
                        "SixtyFiveAndAbove": obj.get("SixtyFiveAndAbove") if obj.get("SixtyFiveAndAbove") is not None else None,
                        "AgeUnknown": obj.get("AgeUnknown") if obj.get("AgeUnknown") is not None else None,
                        "Female": obj.get("Female") if obj.get("Female") is not None else None,
                        "Male": obj.get("Male") if obj.get("Male") is not None else None,
                        "GenderUnknown": obj.get("GenderUnknown") if obj.get("GenderUnknown") is not None else None
        })
        return _obj
