# 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.budget_limit_type import BudgetLimitType
from openapi_client.models.adinsight.budget_point import BudgetPoint
from typing_extensions import Self

class BudgetOpportunity(BaseModel):
    """
    BudgetOpportunity
    """ # noqa: E501
    campaign_id: Optional[StrictStr] = Field(default=None, alias="CampaignId")
    current_budget: Optional[StrictFloat] = Field(default=None, alias="CurrentBudget")
    recommended_budget: Optional[StrictFloat] = Field(default=None, alias="RecommendedBudget")
    budget_type: Optional[BudgetLimitType] = Field(default=None, alias="BudgetType")
    increase_in_impressions: Optional[StrictStr] = Field(default=None, alias="IncreaseInImpressions")
    percentage_increase_in_impressions: Optional[StrictInt] = Field(default=None, alias="PercentageIncreaseInImpressions")
    increase_in_clicks: Optional[StrictFloat] = Field(default=None, alias="IncreaseInClicks")
    percentage_increase_in_clicks: Optional[StrictInt] = Field(default=None, alias="PercentageIncreaseInClicks")
    budget_points: Optional[List[Optional[BudgetPoint]]] = Field(default=None, alias="BudgetPoints")
    opportunity_key: Optional[StrictStr] = Field(default=None, alias="OpportunityKey")
    __properties: ClassVar[List[str]] = ["CampaignId", "CurrentBudget", "RecommendedBudget", "BudgetType", "IncreaseInImpressions", "PercentageIncreaseInImpressions", "IncreaseInClicks", "PercentageIncreaseInClicks", "BudgetPoints", "OpportunityKey"]

    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 budget_points (list)
        _items = []
        if self.budget_points:
            for _item_budget_points in self.budget_points:
                if _item_budget_points:
                    _items.append(_item_budget_points.to_dict())
            _dict['BudgetPoints'] = _items
        # 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 current_budget (nullable) is None
        # and model_fields_set contains the field
        if self.current_budget is None and "current_budget" in self.model_fields_set:
            _dict['CurrentBudget'] = None

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "CampaignId": obj.get("CampaignId") if obj.get("CampaignId") is not None else None,
                        "CurrentBudget": obj.get("CurrentBudget") if obj.get("CurrentBudget") is not None else None,
                        "RecommendedBudget": obj.get("RecommendedBudget") if obj.get("RecommendedBudget") is not None else None,
                        "BudgetType": obj.get("BudgetType") if obj.get("BudgetType") is not None else None,
                        "IncreaseInImpressions": obj.get("IncreaseInImpressions") if obj.get("IncreaseInImpressions") is not None else None,
                        "PercentageIncreaseInImpressions": obj.get("PercentageIncreaseInImpressions") if obj.get("PercentageIncreaseInImpressions") is not None else None,
                        "IncreaseInClicks": obj.get("IncreaseInClicks") if obj.get("IncreaseInClicks") is not None else None,
                        "PercentageIncreaseInClicks": obj.get("PercentageIncreaseInClicks") if obj.get("PercentageIncreaseInClicks") is not None else None,
                        "BudgetPoints": [BudgetPoint.from_dict(_item) for _item in obj["BudgetPoints"]] if obj.get("BudgetPoints") is not None else None,
                        "OpportunityKey": obj.get("OpportunityKey") if obj.get("OpportunityKey") is not None else None
        })
        return _obj
