# 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, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from neurograph.v1.models.reporting_age_breakdown_row import ReportingAgeBreakdownRow
from neurograph.v1.models.reporting_summary_kpis import ReportingSummaryKPIs
from neurograph.v1.models.reporting_traffic_pipeline_day import ReportingTrafficPipelineDay
from neurograph.v1.models.reporting_traffic_trend_day import ReportingTrafficTrendDay
from typing import Optional, Set
from typing_extensions import Self

class ReportingCustomerInsightsResponse(BaseModel):
    """
    ReportingCustomerInsightsResponse
    """ # noqa: E501
    age_breakdown: Optional[List[ReportingAgeBreakdownRow]] = None
    cached: Optional[StrictBool] = None
    error: Optional[StrictStr] = None
    summary: Optional[ReportingSummaryKPIs] = None
    traffic_trend: Optional[List[ReportingTrafficTrendDay]] = None
    traffic_value_pipeline: Optional[List[ReportingTrafficPipelineDay]] = None
    __properties: ClassVar[List[str]] = ["age_breakdown", "cached", "error", "summary", "traffic_trend", "traffic_value_pipeline"]

    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 ReportingCustomerInsightsResponse 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 age_breakdown (list)
        _items = []
        if self.age_breakdown:
            for _item_age_breakdown in self.age_breakdown:
                if _item_age_breakdown:
                    _items.append(_item_age_breakdown.to_dict())
            _dict['age_breakdown'] = _items
        # override the default output from pydantic by calling `to_dict()` of summary
        if self.summary:
            _dict['summary'] = self.summary.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in traffic_trend (list)
        _items = []
        if self.traffic_trend:
            for _item_traffic_trend in self.traffic_trend:
                if _item_traffic_trend:
                    _items.append(_item_traffic_trend.to_dict())
            _dict['traffic_trend'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in traffic_value_pipeline (list)
        _items = []
        if self.traffic_value_pipeline:
            for _item_traffic_value_pipeline in self.traffic_value_pipeline:
                if _item_traffic_value_pipeline:
                    _items.append(_item_traffic_value_pipeline.to_dict())
            _dict['traffic_value_pipeline'] = _items
        return _dict

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

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

        _obj = cls.model_validate({
            "age_breakdown": [ReportingAgeBreakdownRow.from_dict(_item) for _item in obj["age_breakdown"]] if obj.get("age_breakdown") is not None else None,
            "cached": obj.get("cached"),
            "error": obj.get("error"),
            "summary": ReportingSummaryKPIs.from_dict(obj["summary"]) if obj.get("summary") is not None else None,
            "traffic_trend": [ReportingTrafficTrendDay.from_dict(_item) for _item in obj["traffic_trend"]] if obj.get("traffic_trend") is not None else None,
            "traffic_value_pipeline": [ReportingTrafficPipelineDay.from_dict(_item) for _item in obj["traffic_value_pipeline"]] if obj.get("traffic_value_pipeline") is not None else None
        })
        return _obj


