# coding: utf-8

"""
    CATAPA API

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

    The version of the OpenAPI document: 1.0.0
    Contact: support@catapa.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, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from openapi_client.models.analytics_column_response import AnalyticsColumnResponse
from typing import Optional, Set
from typing_extensions import Self

class ChartFilterResponse(BaseModel):
    """
    ChartFilterResponse
    """ # noqa: E501
    id: Optional[StrictStr] = None
    chart_filter_type: Optional[StrictStr] = Field(default=None, alias="chartFilterType")
    column: Optional[AnalyticsColumnResponse] = None
    values: Optional[List[StrictStr]] = None
    start_date: Optional[StrictStr] = Field(default=None, alias="startDate")
    end_date: Optional[StrictStr] = Field(default=None, alias="endDate")
    time_frame: Optional[StrictStr] = Field(default=None, alias="timeFrame")
    time_unit: Optional[StrictStr] = Field(default=None, alias="timeUnit")
    duration: Optional[Union[StrictFloat, StrictInt]] = None
    __properties: ClassVar[List[str]] = ["id", "chartFilterType", "column", "values", "startDate", "endDate", "timeFrame", "timeUnit", "duration"]

    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 ChartFilterResponse 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 column
        if self.column:
            _dict['column'] = self.column.to_dict()
        # set to None if values (nullable) is None
        # and model_fields_set contains the field
        if self.values is None and "values" in self.model_fields_set:
            _dict['values'] = None

        # set to None if start_date (nullable) is None
        # and model_fields_set contains the field
        if self.start_date is None and "start_date" in self.model_fields_set:
            _dict['startDate'] = None

        # set to None if end_date (nullable) is None
        # and model_fields_set contains the field
        if self.end_date is None and "end_date" in self.model_fields_set:
            _dict['endDate'] = None

        # set to None if time_frame (nullable) is None
        # and model_fields_set contains the field
        if self.time_frame is None and "time_frame" in self.model_fields_set:
            _dict['timeFrame'] = None

        # set to None if time_unit (nullable) is None
        # and model_fields_set contains the field
        if self.time_unit is None and "time_unit" in self.model_fields_set:
            _dict['timeUnit'] = None

        # set to None if duration (nullable) is None
        # and model_fields_set contains the field
        if self.duration is None and "duration" in self.model_fields_set:
            _dict['duration'] = None

        return _dict

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

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

        _obj = cls.model_validate({
            "id": obj.get("id"),
            "chartFilterType": obj.get("chartFilterType"),
            "column": AnalyticsColumnResponse.from_dict(obj["column"]) if obj.get("column") is not None else None,
            "values": obj.get("values"),
            "startDate": obj.get("startDate"),
            "endDate": obj.get("endDate"),
            "timeFrame": obj.get("timeFrame"),
            "timeUnit": obj.get("timeUnit"),
            "duration": obj.get("duration")
        })
        return _obj


