# 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.bid_landscape_point import BidLandscapePoint
from openapi_client.models.adinsight.day_month_and_year import DayMonthAndYear
from typing_extensions import Self

class KeywordBidLandscape(BaseModel):
    """
    KeywordBidLandscape
    """ # noqa: E501
    keyword_id: Optional[StrictStr] = Field(default=None, alias="KeywordId")
    start_date: Optional[DayMonthAndYear] = Field(default=None, alias="StartDate")
    end_date: Optional[DayMonthAndYear] = Field(default=None, alias="EndDate")
    bid_landscape_points: Optional[List[Optional[BidLandscapePoint]]] = Field(default=None, alias="BidLandscapePoints")
    __properties: ClassVar[List[str]] = ["KeywordId", "StartDate", "EndDate", "BidLandscapePoints"]

    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()
        # override the default output from pydantic by calling `to_dict()` of each item in bid_landscape_points (list)
        _items = []
        if self.bid_landscape_points:
            for _item_bid_landscape_points in self.bid_landscape_points:
                if _item_bid_landscape_points:
                    _items.append(_item_bid_landscape_points.to_dict())
            _dict['BidLandscapePoints'] = _items
        # set to None if keyword_id (nullable) is None
        # and model_fields_set contains the field
        if self.keyword_id is None and "keyword_id" in self.model_fields_set:
            _dict['KeywordId'] = 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 bid_landscape_points (nullable) is None
        # and model_fields_set contains the field
        if self.bid_landscape_points is None and "bid_landscape_points" in self.model_fields_set:
            _dict['BidLandscapePoints'] = None

        return _dict

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

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

        _obj = cls.model_validate({
            "KeywordId": obj.get("KeywordId") if obj.get("KeywordId") is not None else None,
                        "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,
                        "BidLandscapePoints": [BidLandscapePoint.from_dict(_item) for _item in obj["BidLandscapePoints"]] if obj.get("BidLandscapePoints") is not None else None
        })
        return _obj
