# 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 openapi_client.models.adinsight.breakdown import Breakdown
from openapi_client.models.adinsight.location_breakdown import LocationBreakdown
from typing_extensions import Self

class Breakdowns(BaseModel):
    """
    Breakdowns
    """ # noqa: E501
    age: Optional[Breakdown] = Field(default=None, alias="Age")
    device: Optional[Breakdown] = Field(default=None, alias="Device")
    gender: Optional[Breakdown] = Field(default=None, alias="Gender")
    in_market: Optional[Breakdown] = Field(default=None, alias="InMarket")
    industry: Optional[Breakdown] = Field(default=None, alias="Industry")
    job_function: Optional[Breakdown] = Field(default=None, alias="JobFunction")
    location_country: Optional[LocationBreakdown] = Field(default=None, alias="LocationCountry")
    location: Optional[LocationBreakdown] = Field(default=None, alias="Location")
    location_sub_geography: Optional[LocationBreakdown] = Field(default=None, alias="LocationSubGeography")
    location_metro_area: Optional[LocationBreakdown] = Field(default=None, alias="LocationMetroArea")
    location_city: Optional[LocationBreakdown] = Field(default=None, alias="LocationCity")
    location_postal_code: Optional[LocationBreakdown] = Field(default=None, alias="LocationPostalCode")
    location_county: Optional[LocationBreakdown] = Field(default=None, alias="LocationCounty")
    __properties: ClassVar[List[str]] = ["Age", "Device", "Gender", "InMarket", "Industry", "JobFunction", "LocationCountry", "Location", "LocationSubGeography", "LocationMetroArea", "LocationCity", "LocationPostalCode", "LocationCounty"]

    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,
        )
        # override the default output from pydantic by calling `to_dict()` of age
        if self.age:
            _dict['Age'] = self.age.to_dict()
        # override the default output from pydantic by calling `to_dict()` of device
        if self.device:
            _dict['Device'] = self.device.to_dict()
        # override the default output from pydantic by calling `to_dict()` of gender
        if self.gender:
            _dict['Gender'] = self.gender.to_dict()
        # override the default output from pydantic by calling `to_dict()` of in_market
        if self.in_market:
            _dict['InMarket'] = self.in_market.to_dict()
        # override the default output from pydantic by calling `to_dict()` of industry
        if self.industry:
            _dict['Industry'] = self.industry.to_dict()
        # override the default output from pydantic by calling `to_dict()` of job_function
        if self.job_function:
            _dict['JobFunction'] = self.job_function.to_dict()
        # override the default output from pydantic by calling `to_dict()` of location_country
        if self.location_country:
            _dict['LocationCountry'] = self.location_country.to_dict()
        # override the default output from pydantic by calling `to_dict()` of location
        if self.location:
            _dict['Location'] = self.location.to_dict()
        # override the default output from pydantic by calling `to_dict()` of location_sub_geography
        if self.location_sub_geography:
            _dict['LocationSubGeography'] = self.location_sub_geography.to_dict()
        # override the default output from pydantic by calling `to_dict()` of location_metro_area
        if self.location_metro_area:
            _dict['LocationMetroArea'] = self.location_metro_area.to_dict()
        # override the default output from pydantic by calling `to_dict()` of location_city
        if self.location_city:
            _dict['LocationCity'] = self.location_city.to_dict()
        # override the default output from pydantic by calling `to_dict()` of location_postal_code
        if self.location_postal_code:
            _dict['LocationPostalCode'] = self.location_postal_code.to_dict()
        # override the default output from pydantic by calling `to_dict()` of location_county
        if self.location_county:
            _dict['LocationCounty'] = self.location_county.to_dict()
        # set to None if age (nullable) is None
        # and model_fields_set contains the field
        if self.age is None and "age" in self.model_fields_set:
            _dict['Age'] = None

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "Age": Breakdown.from_dict(obj["Age"]) if obj.get("Age") is not None else None,
                        "Device": Breakdown.from_dict(obj["Device"]) if obj.get("Device") is not None else None,
                        "Gender": Breakdown.from_dict(obj["Gender"]) if obj.get("Gender") is not None else None,
                        "InMarket": Breakdown.from_dict(obj["InMarket"]) if obj.get("InMarket") is not None else None,
                        "Industry": Breakdown.from_dict(obj["Industry"]) if obj.get("Industry") is not None else None,
                        "JobFunction": Breakdown.from_dict(obj["JobFunction"]) if obj.get("JobFunction") is not None else None,
                        "LocationCountry": LocationBreakdown.from_dict(obj["LocationCountry"]) if obj.get("LocationCountry") is not None else None,
                        "Location": LocationBreakdown.from_dict(obj["Location"]) if obj.get("Location") is not None else None,
                        "LocationSubGeography": LocationBreakdown.from_dict(obj["LocationSubGeography"]) if obj.get("LocationSubGeography") is not None else None,
                        "LocationMetroArea": LocationBreakdown.from_dict(obj["LocationMetroArea"]) if obj.get("LocationMetroArea") is not None else None,
                        "LocationCity": LocationBreakdown.from_dict(obj["LocationCity"]) if obj.get("LocationCity") is not None else None,
                        "LocationPostalCode": LocationBreakdown.from_dict(obj["LocationPostalCode"]) if obj.get("LocationPostalCode") is not None else None,
                        "LocationCounty": LocationBreakdown.from_dict(obj["LocationCounty"]) if obj.get("LocationCounty") is not None else None
        })
        return _obj
