# coding: utf-8

"""
    RentCast API

    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
from typing import Any, ClassVar, Dict, List, Optional
from rentcast_client.models.market_statistics200_response_rental_data_history202309 import MarketStatistics200ResponseRentalDataHistory202309
from rentcast_client.models.market_statistics200_response_rental_data_history202310 import MarketStatistics200ResponseRentalDataHistory202310
from rentcast_client.models.market_statistics200_response_rental_data_history202311 import MarketStatistics200ResponseRentalDataHistory202311
from rentcast_client.models.market_statistics200_response_rental_data_history202312 import MarketStatistics200ResponseRentalDataHistory202312
from rentcast_client.models.market_statistics200_response_rental_data_history202401 import MarketStatistics200ResponseRentalDataHistory202401
from rentcast_client.models.market_statistics200_response_rental_data_history202402 import MarketStatistics200ResponseRentalDataHistory202402
from typing import Optional, Set
from typing_extensions import Self

class MarketStatistics200ResponseRentalDataHistory(BaseModel):
    """
    MarketStatistics200ResponseRentalDataHistory
    """ # noqa: E501
    var_2023_09: Optional[MarketStatistics200ResponseRentalDataHistory202309] = Field(default=None, alias="2023-09")
    var_2023_10: Optional[MarketStatistics200ResponseRentalDataHistory202310] = Field(default=None, alias="2023-10")
    var_2023_11: Optional[MarketStatistics200ResponseRentalDataHistory202311] = Field(default=None, alias="2023-11")
    var_2023_12: Optional[MarketStatistics200ResponseRentalDataHistory202312] = Field(default=None, alias="2023-12")
    var_2024_01: Optional[MarketStatistics200ResponseRentalDataHistory202401] = Field(default=None, alias="2024-01")
    var_2024_02: Optional[MarketStatistics200ResponseRentalDataHistory202402] = Field(default=None, alias="2024-02")
    __properties: ClassVar[List[str]] = ["2023-09", "2023-10", "2023-11", "2023-12", "2024-01", "2024-02"]

    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 MarketStatistics200ResponseRentalDataHistory 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 var_2023_09
        if self.var_2023_09:
            _dict['2023-09'] = self.var_2023_09.to_dict()
        # override the default output from pydantic by calling `to_dict()` of var_2023_10
        if self.var_2023_10:
            _dict['2023-10'] = self.var_2023_10.to_dict()
        # override the default output from pydantic by calling `to_dict()` of var_2023_11
        if self.var_2023_11:
            _dict['2023-11'] = self.var_2023_11.to_dict()
        # override the default output from pydantic by calling `to_dict()` of var_2023_12
        if self.var_2023_12:
            _dict['2023-12'] = self.var_2023_12.to_dict()
        # override the default output from pydantic by calling `to_dict()` of var_2024_01
        if self.var_2024_01:
            _dict['2024-01'] = self.var_2024_01.to_dict()
        # override the default output from pydantic by calling `to_dict()` of var_2024_02
        if self.var_2024_02:
            _dict['2024-02'] = self.var_2024_02.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "2023-09": MarketStatistics200ResponseRentalDataHistory202309.from_dict(obj["2023-09"]) if obj.get("2023-09") is not None else None,
            "2023-10": MarketStatistics200ResponseRentalDataHistory202310.from_dict(obj["2023-10"]) if obj.get("2023-10") is not None else None,
            "2023-11": MarketStatistics200ResponseRentalDataHistory202311.from_dict(obj["2023-11"]) if obj.get("2023-11") is not None else None,
            "2023-12": MarketStatistics200ResponseRentalDataHistory202312.from_dict(obj["2023-12"]) if obj.get("2023-12") is not None else None,
            "2024-01": MarketStatistics200ResponseRentalDataHistory202401.from_dict(obj["2024-01"]) if obj.get("2024-01") is not None else None,
            "2024-02": MarketStatistics200ResponseRentalDataHistory202402.from_dict(obj["2024-02"]) if obj.get("2024-02") is not None else None
        })
        return _obj


