# 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, StrictBool, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from neurograph.v1.models.reporting_affinity_debug_info import ReportingAffinityDebugInfo
from neurograph.v1.models.reporting_affinity_meta import ReportingAffinityMeta
from neurograph.v1.models.reporting_category_performance_data import ReportingCategoryPerformanceData
from neurograph.v1.models.reporting_category_spend_data import ReportingCategorySpendData
from neurograph.v1.models.reporting_price_tolerance_data import ReportingPriceToleranceData
from neurograph.v1.models.reporting_product_performance_data import ReportingProductPerformanceData
from neurograph.v1.models.reporting_purchase_cycle_data import ReportingPurchaseCycleData
from neurograph.v1.models.reporting_purchase_timing_data import ReportingPurchaseTimingData
from typing import Optional, Set
from typing_extensions import Self

class ReportingPersonaProductAffinityResponse(BaseModel):
    """
    ReportingPersonaProductAffinityResponse
    """ # noqa: E501
    cached: Optional[StrictBool] = None
    category_performance: Optional[ReportingCategoryPerformanceData] = None
    category_spend: Optional[ReportingCategorySpendData] = None
    debug_info: Optional[ReportingAffinityDebugInfo] = None
    error: Optional[StrictStr] = None
    meta: Optional[ReportingAffinityMeta] = None
    no_data: Optional[StrictBool] = None
    price_tolerance: Optional[ReportingPriceToleranceData] = None
    product_performance: Optional[ReportingProductPerformanceData] = None
    purchase_cycle: Optional[ReportingPurchaseCycleData] = None
    purchase_timing: Optional[ReportingPurchaseTimingData] = None
    query_time_ms: Optional[StrictInt] = None
    __properties: ClassVar[List[str]] = ["cached", "category_performance", "category_spend", "debug_info", "error", "meta", "no_data", "price_tolerance", "product_performance", "purchase_cycle", "purchase_timing", "query_time_ms"]

    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 ReportingPersonaProductAffinityResponse 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 category_performance
        if self.category_performance:
            _dict['category_performance'] = self.category_performance.to_dict()
        # override the default output from pydantic by calling `to_dict()` of category_spend
        if self.category_spend:
            _dict['category_spend'] = self.category_spend.to_dict()
        # override the default output from pydantic by calling `to_dict()` of debug_info
        if self.debug_info:
            _dict['debug_info'] = self.debug_info.to_dict()
        # override the default output from pydantic by calling `to_dict()` of meta
        if self.meta:
            _dict['meta'] = self.meta.to_dict()
        # override the default output from pydantic by calling `to_dict()` of price_tolerance
        if self.price_tolerance:
            _dict['price_tolerance'] = self.price_tolerance.to_dict()
        # override the default output from pydantic by calling `to_dict()` of product_performance
        if self.product_performance:
            _dict['product_performance'] = self.product_performance.to_dict()
        # override the default output from pydantic by calling `to_dict()` of purchase_cycle
        if self.purchase_cycle:
            _dict['purchase_cycle'] = self.purchase_cycle.to_dict()
        # override the default output from pydantic by calling `to_dict()` of purchase_timing
        if self.purchase_timing:
            _dict['purchase_timing'] = self.purchase_timing.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "cached": obj.get("cached"),
            "category_performance": ReportingCategoryPerformanceData.from_dict(obj["category_performance"]) if obj.get("category_performance") is not None else None,
            "category_spend": ReportingCategorySpendData.from_dict(obj["category_spend"]) if obj.get("category_spend") is not None else None,
            "debug_info": ReportingAffinityDebugInfo.from_dict(obj["debug_info"]) if obj.get("debug_info") is not None else None,
            "error": obj.get("error"),
            "meta": ReportingAffinityMeta.from_dict(obj["meta"]) if obj.get("meta") is not None else None,
            "no_data": obj.get("no_data"),
            "price_tolerance": ReportingPriceToleranceData.from_dict(obj["price_tolerance"]) if obj.get("price_tolerance") is not None else None,
            "product_performance": ReportingProductPerformanceData.from_dict(obj["product_performance"]) if obj.get("product_performance") is not None else None,
            "purchase_cycle": ReportingPurchaseCycleData.from_dict(obj["purchase_cycle"]) if obj.get("purchase_cycle") is not None else None,
            "purchase_timing": ReportingPurchaseTimingData.from_dict(obj["purchase_timing"]) if obj.get("purchase_timing") is not None else None,
            "query_time_ms": obj.get("query_time_ms")
        })
        return _obj


