# 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.day_month_and_year import DayMonthAndYear
from typing_extensions import Self

class GetHistoricalSearchCountRequest(BaseModel):
    """
    GetHistoricalSearchCountRequest
    """ # noqa: E501
    keywords: Optional[List[StrictStr]] = Field(default=None, alias="Keywords")
    language: Optional[StrictStr] = Field(default=None, alias="Language")
    publisher_countries: Optional[List[StrictStr]] = Field(default=None, alias="PublisherCountries")
    start_date: Optional[DayMonthAndYear] = Field(default=None, alias="StartDate")
    end_date: Optional[DayMonthAndYear] = Field(default=None, alias="EndDate")
    time_period_rollup: Optional[StrictStr] = Field(default=None, alias="TimePeriodRollup")
    devices: Optional[List[StrictStr]] = Field(default=None, alias="Devices")
    __properties: ClassVar[List[str]] = ["Keywords", "Language", "PublisherCountries", "StartDate", "EndDate", "TimePeriodRollup", "Devices"]

    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 start_date
        if self.start_date:
            _dict['StartDate'] = self.start_date.to_dict()
        # override the default output from pydantic by calling `to_dict()` of end_date
        if self.end_date:
            _dict['EndDate'] = self.end_date.to_dict()
        # set to None if keywords (nullable) is None
        # and model_fields_set contains the field
        if self.keywords is None and "keywords" in self.model_fields_set:
            _dict['Keywords'] = None

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "Keywords": obj.get("Keywords"),
                        "Language": obj.get("Language") if obj.get("Language") is not None else None,
                        "PublisherCountries": obj.get("PublisherCountries"),
                        "StartDate": DayMonthAndYear.from_dict(obj["StartDate"]) if obj.get("StartDate") is not None else None,
                        "EndDate": DayMonthAndYear.from_dict(obj["EndDate"]) if obj.get("EndDate") is not None else None,
                        "TimePeriodRollup": obj.get("TimePeriodRollup") if obj.get("TimePeriodRollup") is not None else None,
                        "Devices": obj.get("Devices")
        })
        return _obj
