# coding: utf-8

"""
    Neurograph Core

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: 1.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 pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from neurograph.v1.models.reporting_scenario_market_concept import ReportingScenarioMarketConcept
from neurograph.v1.models.reporting_scenario_path import ReportingScenarioPath
from neurograph.v1.models.reporting_scenario_product import ReportingScenarioProduct
from typing import Optional, Set
from typing_extensions import Self

class ReportingBuyerScenario(BaseModel):
    """
    ReportingBuyerScenario
    """ # noqa: E501
    authored_boost: Optional[Union[StrictFloat, StrictInt]] = None
    blended_score: Optional[Union[StrictFloat, StrictInt]] = None
    cluster_boost: Optional[Union[StrictFloat, StrictInt]] = None
    cluster_ref_size: Optional[StrictInt] = None
    cluster_size: Optional[StrictInt] = None
    color: Optional[StrictStr] = None
    complexity: Optional[StrictStr] = None
    confidence: Optional[Union[StrictFloat, StrictInt]] = None
    description: Optional[StrictStr] = Field(default=None, description="Rich metadata (from resolved canonical entity's data column)")
    diversity_factor: Optional[Union[StrictFloat, StrictInt]] = None
    final_score: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="v7 Scores (adaptive blending + cluster boost + authored boost + signal gate)")
    graph_paths: Optional[StrictInt] = None
    graph_score: Optional[Union[StrictFloat, StrictInt]] = None
    graph_weight: Optional[Union[StrictFloat, StrictInt]] = None
    icon: Optional[StrictStr] = Field(default=None, description="UI helpers")
    intent: Optional[StrictStr] = None
    is_persona_authored: Optional[StrictBool] = Field(default=None, description="★ v7: Persona authorship diagnostics")
    key_concepts: Optional[List[StrictStr]] = None
    market_concepts: Optional[List[ReportingScenarioMarketConcept]] = Field(default=None, description="Ranked market concepts from knowledge graph")
    matched_products: Optional[StrictInt] = Field(default=None, description="Adaptive blend diagnostics")
    num_paths: Optional[StrictInt] = None
    persona_context: Optional[StrictStr] = None
    primary_category: Optional[StrictStr] = None
    product_diversity: Optional[Union[StrictFloat, StrictInt]] = None
    product_paths: Optional[StrictInt] = None
    product_score: Optional[Union[StrictFloat, StrictInt]] = None
    product_signal_count: Optional[StrictInt] = Field(default=None, description="Signal diagnostics")
    product_signal_gate: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="★ v7: Product signal gate (purchase-evidence multiplier)")
    purchase_likelihood: Optional[Union[StrictFloat, StrictInt]] = None
    relevance_pct: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Normalised relevance score (0-100, top scenario = 100)")
    scenario_name: Optional[StrictStr] = None
    scenario_resolved_id: Optional[StrictStr] = Field(default=None, description="Identity")
    scenario_type: Optional[StrictStr] = None
    scenario_variants: Optional[List[StrictStr]] = None
    shortest_path: Optional[StrictInt] = None
    source_persona_id: Optional[StrictStr] = None
    tags: Optional[List[StrictStr]] = None
    timeline: Optional[StrictStr] = None
    top_paths: Optional[List[ReportingScenarioPath]] = Field(default=None, description="Explainability")
    top_products: Optional[List[ReportingScenarioProduct]] = None
    trigger_event: Optional[StrictStr] = None
    __properties: ClassVar[List[str]] = ["authored_boost", "blended_score", "cluster_boost", "cluster_ref_size", "cluster_size", "color", "complexity", "confidence", "description", "diversity_factor", "final_score", "graph_paths", "graph_score", "graph_weight", "icon", "intent", "is_persona_authored", "key_concepts", "market_concepts", "matched_products", "num_paths", "persona_context", "primary_category", "product_diversity", "product_paths", "product_score", "product_signal_count", "product_signal_gate", "purchase_likelihood", "relevance_pct", "scenario_name", "scenario_resolved_id", "scenario_type", "scenario_variants", "shortest_path", "source_persona_id", "tags", "timeline", "top_paths", "top_products", "trigger_event"]

    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 ReportingBuyerScenario 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 each item in market_concepts (list)
        _items = []
        if self.market_concepts:
            for _item_market_concepts in self.market_concepts:
                if _item_market_concepts:
                    _items.append(_item_market_concepts.to_dict())
            _dict['market_concepts'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in top_paths (list)
        _items = []
        if self.top_paths:
            for _item_top_paths in self.top_paths:
                if _item_top_paths:
                    _items.append(_item_top_paths.to_dict())
            _dict['top_paths'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in top_products (list)
        _items = []
        if self.top_products:
            for _item_top_products in self.top_products:
                if _item_top_products:
                    _items.append(_item_top_products.to_dict())
            _dict['top_products'] = _items
        return _dict

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

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

        _obj = cls.model_validate({
            "authored_boost": obj.get("authored_boost"),
            "blended_score": obj.get("blended_score"),
            "cluster_boost": obj.get("cluster_boost"),
            "cluster_ref_size": obj.get("cluster_ref_size"),
            "cluster_size": obj.get("cluster_size"),
            "color": obj.get("color"),
            "complexity": obj.get("complexity"),
            "confidence": obj.get("confidence"),
            "description": obj.get("description"),
            "diversity_factor": obj.get("diversity_factor"),
            "final_score": obj.get("final_score"),
            "graph_paths": obj.get("graph_paths"),
            "graph_score": obj.get("graph_score"),
            "graph_weight": obj.get("graph_weight"),
            "icon": obj.get("icon"),
            "intent": obj.get("intent"),
            "is_persona_authored": obj.get("is_persona_authored"),
            "key_concepts": obj.get("key_concepts"),
            "market_concepts": [ReportingScenarioMarketConcept.from_dict(_item) for _item in obj["market_concepts"]] if obj.get("market_concepts") is not None else None,
            "matched_products": obj.get("matched_products"),
            "num_paths": obj.get("num_paths"),
            "persona_context": obj.get("persona_context"),
            "primary_category": obj.get("primary_category"),
            "product_diversity": obj.get("product_diversity"),
            "product_paths": obj.get("product_paths"),
            "product_score": obj.get("product_score"),
            "product_signal_count": obj.get("product_signal_count"),
            "product_signal_gate": obj.get("product_signal_gate"),
            "purchase_likelihood": obj.get("purchase_likelihood"),
            "relevance_pct": obj.get("relevance_pct"),
            "scenario_name": obj.get("scenario_name"),
            "scenario_resolved_id": obj.get("scenario_resolved_id"),
            "scenario_type": obj.get("scenario_type"),
            "scenario_variants": obj.get("scenario_variants"),
            "shortest_path": obj.get("shortest_path"),
            "source_persona_id": obj.get("source_persona_id"),
            "tags": obj.get("tags"),
            "timeline": obj.get("timeline"),
            "top_paths": [ReportingScenarioPath.from_dict(_item) for _item in obj["top_paths"]] if obj.get("top_paths") is not None else None,
            "top_products": [ReportingScenarioProduct.from_dict(_item) for _item in obj["top_products"]] if obj.get("top_products") is not None else None,
            "trigger_event": obj.get("trigger_event")
        })
        return _obj


