# coding: utf-8

"""
    Pinterest REST API

    Pinterest's REST API

    The version of the OpenAPI document: 5.23.0
    Contact: blah+oapicf@cliffano.com
    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 pinterestsdk.models.product_categories_demographic import ProductCategoriesDemographic
from pinterestsdk.models.product_categories_metrics_highlights import ProductCategoriesMetricsHighlights
from pinterestsdk.models.product_category_enum import ProductCategoryEnum
from typing import Optional, Set
from typing_extensions import Self

class ProductCategoryDetails(BaseModel):
    """
    Product category details
    """ # noqa: E501
    demographics: Optional[ProductCategoriesDemographic] = None
    has_prediction: StrictBool = Field(description="     Indicates whether the keyword has a prediction available for the next 90 days.     This field is only applicable when include_prediction query parameter is set to true.     By default, the value is false and no prediction data is included in the response.")
    metrics_highlights: Optional[ProductCategoriesMetricsHighlights] = None
    predicted_time_series: Optional[Dict[str, Union[StrictFloat, StrictInt]]] = Field(default=None, description="     A sequence of weekly observations of the predicted relative search volume for this keyword over the next 3 months.     These values are normalized to a [0-100] range, and can be used to visualize the forecasted user interest in this keyword.     Similar to the historical time_series, normalization is applied independently to the predicted time series of each keyword, but the normalize_against_group query parameter can be used in cases where you wish to compare relative predicted volume between keywords.     **Note**: The cut-off date between historical and predicted time series depends on Pinterest data availability. Usually the data needs a few days to be calculated, so the predicted time series may contain some past dates compared to today.     **Note**: The date of each observation is in ISO-8601 format and represents the end of the week. For example, a value of 2024-01-07 would include predicted searches for the week ending on 2024-01-07.")
    product_category: ProductCategoryEnum
    related_searches: Optional[List[StrictStr]] = Field(default=None, description="Related search terms for this product category")
    time_series: Optional[Dict[str, Union[StrictFloat, StrictInt]]] = Field(default=None, description="Time series data showing trend values over time, indexed between 0 and 100")
    __properties: ClassVar[List[str]] = ["demographics", "has_prediction", "metrics_highlights", "predicted_time_series", "product_category", "related_searches", "time_series"]

    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 ProductCategoryDetails 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 demographics
        if self.demographics:
            _dict['demographics'] = self.demographics.to_dict()
        # override the default output from pydantic by calling `to_dict()` of metrics_highlights
        if self.metrics_highlights:
            _dict['metrics_highlights'] = self.metrics_highlights.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "demographics": ProductCategoriesDemographic.from_dict(obj["demographics"]) if obj.get("demographics") is not None else None,
            "has_prediction": obj.get("has_prediction"),
            "metrics_highlights": ProductCategoriesMetricsHighlights.from_dict(obj["metrics_highlights"]) if obj.get("metrics_highlights") is not None else None,
            "predicted_time_series": obj.get("predicted_time_series"),
            "product_category": obj.get("product_category"),
            "related_searches": obj.get("related_searches"),
            "time_series": obj.get("time_series")
        })
        return _obj


