# 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 typing import Optional, Set
from typing_extensions import Self

class ReportingCategoryPerformanceRow(BaseModel):
    """
    ReportingCategoryPerformanceRow
    """ # noqa: E501
    account_avg_affinity: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Account baseline fields for over/under indexing")
    account_avg_conv_rate: Optional[Union[StrictFloat, StrictInt]] = None
    account_avg_purchases: Optional[Union[StrictFloat, StrictInt]] = None
    account_purchase_pct: Optional[Union[StrictFloat, StrictInt]] = None
    affinity_delta: Optional[Union[StrictFloat, StrictInt]] = None
    aov: Optional[Union[StrictFloat, StrictInt]] = None
    avg_affinity_score: Optional[Union[StrictFloat, StrictInt]] = None
    category_name: Optional[StrictStr] = None
    conv_rate_delta: Optional[Union[StrictFloat, StrictInt]] = None
    conversion_rate: Optional[Union[StrictFloat, StrictInt]] = None
    engagement_level: Optional[StrictStr] = None
    is_top_category: Optional[StrictBool] = None
    persona_purchase_pct: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Purchase share index fields (persona vs account proportion)")
    purchase_pct_delta: Optional[Union[StrictFloat, StrictInt]] = None
    purchases: Optional[StrictInt] = None
    relative_performance: Optional[Union[StrictFloat, StrictInt]] = None
    rpv: Optional[Union[StrictFloat, StrictInt]] = None
    total_visitors: Optional[StrictInt] = None
    __properties: ClassVar[List[str]] = ["account_avg_affinity", "account_avg_conv_rate", "account_avg_purchases", "account_purchase_pct", "affinity_delta", "aov", "avg_affinity_score", "category_name", "conv_rate_delta", "conversion_rate", "engagement_level", "is_top_category", "persona_purchase_pct", "purchase_pct_delta", "purchases", "relative_performance", "rpv", "total_visitors"]

    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 ReportingCategoryPerformanceRow 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,
        )
        return _dict

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

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

        _obj = cls.model_validate({
            "account_avg_affinity": obj.get("account_avg_affinity"),
            "account_avg_conv_rate": obj.get("account_avg_conv_rate"),
            "account_avg_purchases": obj.get("account_avg_purchases"),
            "account_purchase_pct": obj.get("account_purchase_pct"),
            "affinity_delta": obj.get("affinity_delta"),
            "aov": obj.get("aov"),
            "avg_affinity_score": obj.get("avg_affinity_score"),
            "category_name": obj.get("category_name"),
            "conv_rate_delta": obj.get("conv_rate_delta"),
            "conversion_rate": obj.get("conversion_rate"),
            "engagement_level": obj.get("engagement_level"),
            "is_top_category": obj.get("is_top_category"),
            "persona_purchase_pct": obj.get("persona_purchase_pct"),
            "purchase_pct_delta": obj.get("purchase_pct_delta"),
            "purchases": obj.get("purchases"),
            "relative_performance": obj.get("relative_performance"),
            "rpv": obj.get("rpv"),
            "total_visitors": obj.get("total_visitors")
        })
        return _obj


