# 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.currency_code import CurrencyCode
from openapi_client.models.adinsight.keyword_and_match_type import KeywordAndMatchType
from openapi_client.models.adinsight.target_ad_position import TargetAdPosition
from typing_extensions import Self

class GetEstimatedBidByKeywordsRequest(BaseModel):
    """
    GetEstimatedBidByKeywordsRequest
    """ # noqa: E501
    keywords: Optional[List[Optional[KeywordAndMatchType]]] = Field(default=None, alias="Keywords")
    target_position_for_ads: Optional[TargetAdPosition] = Field(default=None, alias="TargetPositionForAds")
    language: Optional[StrictStr] = Field(default=None, alias="Language")
    location_ids: Optional[List[StrictStr]] = Field(default=None, alias="LocationIds")
    currency_code: Optional[CurrencyCode] = Field(default=None, alias="CurrencyCode")
    campaign_id: Optional[StrictStr] = Field(default=None, alias="CampaignId")
    ad_group_id: Optional[StrictStr] = Field(default=None, alias="AdGroupId")
    entity_level_bid: Optional[StrictStr] = Field(default=None, alias="EntityLevelBid")
    __properties: ClassVar[List[str]] = ["Keywords", "TargetPositionForAds", "Language", "LocationIds", "CurrencyCode", "CampaignId", "AdGroupId", "EntityLevelBid"]

    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 each item in keywords (list)
        _items = []
        if self.keywords:
            for _item_keywords in self.keywords:
                if _item_keywords:
                    _items.append(_item_keywords.to_dict())
            _dict['Keywords'] = _items
        # 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 target_position_for_ads (nullable) is None
        # and model_fields_set contains the field
        if self.target_position_for_ads is None and "target_position_for_ads" in self.model_fields_set:
            _dict['TargetPositionForAds'] = 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 location_ids (nullable) is None
        # and model_fields_set contains the field
        if self.location_ids is None and "location_ids" in self.model_fields_set:
            _dict['LocationIds'] = None

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "Keywords": [KeywordAndMatchType.from_dict(_item) for _item in obj["Keywords"]] if obj.get("Keywords") is not None else None,
                        "TargetPositionForAds": obj.get("TargetPositionForAds") if obj.get("TargetPositionForAds") is not None else None,
                        "Language": obj.get("Language") if obj.get("Language") is not None else None,
                        "LocationIds": obj.get("LocationIds"),
                        "CurrencyCode": obj.get("CurrencyCode") if obj.get("CurrencyCode") is not None else None,
                        "CampaignId": obj.get("CampaignId") if obj.get("CampaignId") is not None else None,
                        "AdGroupId": obj.get("AdGroupId") if obj.get("AdGroupId") is not None else None,
                        "EntityLevelBid": obj.get("EntityLevelBid") if obj.get("EntityLevelBid") is not None else None
        })
        return _obj
