# coding: utf-8

"""
    Rapidata Asset API

    The API for the Rapidata Asset service

    The version of the OpenAPI document: v1
    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 pydantic import BaseModel, ConfigDict, Field, StrictInt
from typing import Any, ClassVar, Dict, List
from rapidata.api_client.models.boost_mode import BoostMode
from rapidata.api_client.models.get_boost_insights_endpoint_audience_output import GetBoostInsightsEndpointAudienceOutput
from rapidata.api_client.models.get_boost_insights_endpoint_global_boost_output import GetBoostInsightsEndpointGlobalBoostOutput
from rapidata.api_client.models.get_boost_insights_endpoint_language_boost_output import GetBoostInsightsEndpointLanguageBoostOutput
from rapidata.api_client.models.get_boost_insights_endpoint_leveled_audience_output import GetBoostInsightsEndpointLeveledAudienceOutput
from typing import Optional, Set
from typing_extensions import Self

class GetBoostInsightsEndpointOutput(BaseModel):
    """
    GetBoostInsightsEndpointOutput
    """ # noqa: E501
    mode: BoostMode
    manual_override_level: StrictInt = Field(description="The manual override level, if manual mode is active.", alias="manualOverrideLevel")
    global_boost: GetBoostInsightsEndpointGlobalBoostOutput = Field(description="Global boost insight with contributing campaigns.", alias="globalBoost")
    language_boosts: List[GetBoostInsightsEndpointLanguageBoostOutput] = Field(alias="languageBoosts")
    audience_boosts: List[GetBoostInsightsEndpointAudienceOutput] = Field(alias="audienceBoosts")
    prospect_blacklist: List[GetBoostInsightsEndpointAudienceOutput] = Field(alias="prospectBlacklist")
    distilling_boosts: List[GetBoostInsightsEndpointLeveledAudienceOutput] = Field(alias="distillingBoosts")
    labeling_boosts: List[GetBoostInsightsEndpointLeveledAudienceOutput] = Field(alias="labelingBoosts")
    __properties: ClassVar[List[str]] = ["mode", "manualOverrideLevel", "globalBoost", "languageBoosts", "audienceBoosts", "prospectBlacklist", "distillingBoosts", "labelingBoosts"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of GetBoostInsightsEndpointOutput from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    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 global_boost
        if self.global_boost:
            _dict['globalBoost'] = self.global_boost.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in language_boosts (list)
        _items = []
        if self.language_boosts:
            for _item_language_boosts in self.language_boosts:
                if _item_language_boosts:
                    _items.append(_item_language_boosts.to_dict())
            _dict['languageBoosts'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in audience_boosts (list)
        _items = []
        if self.audience_boosts:
            for _item_audience_boosts in self.audience_boosts:
                if _item_audience_boosts:
                    _items.append(_item_audience_boosts.to_dict())
            _dict['audienceBoosts'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in prospect_blacklist (list)
        _items = []
        if self.prospect_blacklist:
            for _item_prospect_blacklist in self.prospect_blacklist:
                if _item_prospect_blacklist:
                    _items.append(_item_prospect_blacklist.to_dict())
            _dict['prospectBlacklist'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in distilling_boosts (list)
        _items = []
        if self.distilling_boosts:
            for _item_distilling_boosts in self.distilling_boosts:
                if _item_distilling_boosts:
                    _items.append(_item_distilling_boosts.to_dict())
            _dict['distillingBoosts'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in labeling_boosts (list)
        _items = []
        if self.labeling_boosts:
            for _item_labeling_boosts in self.labeling_boosts:
                if _item_labeling_boosts:
                    _items.append(_item_labeling_boosts.to_dict())
            _dict['labelingBoosts'] = _items
        return _dict

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

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

        _obj = cls.model_validate({
            "mode": obj.get("mode"),
            "manualOverrideLevel": obj.get("manualOverrideLevel"),
            "globalBoost": GetBoostInsightsEndpointGlobalBoostOutput.from_dict(obj["globalBoost"]) if obj.get("globalBoost") is not None else None,
            "languageBoosts": [GetBoostInsightsEndpointLanguageBoostOutput.from_dict(_item) for _item in obj["languageBoosts"]] if obj.get("languageBoosts") is not None else None,
            "audienceBoosts": [GetBoostInsightsEndpointAudienceOutput.from_dict(_item) for _item in obj["audienceBoosts"]] if obj.get("audienceBoosts") is not None else None,
            "prospectBlacklist": [GetBoostInsightsEndpointAudienceOutput.from_dict(_item) for _item in obj["prospectBlacklist"]] if obj.get("prospectBlacklist") is not None else None,
            "distillingBoosts": [GetBoostInsightsEndpointLeveledAudienceOutput.from_dict(_item) for _item in obj["distillingBoosts"]] if obj.get("distillingBoosts") is not None else None,
            "labelingBoosts": [GetBoostInsightsEndpointLeveledAudienceOutput.from_dict(_item) for _item in obj["labelingBoosts"]] if obj.get("labelingBoosts") is not None else None
        })
        return _obj


