# 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
    Contact: support@rentcast.io
    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 datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from rentcast_client.models.rentcast_property_records200_response_inner_features import RentcastPropertyRecords200ResponseInnerFeatures
from rentcast_client.models.rentcast_property_records200_response_inner_history import RentcastPropertyRecords200ResponseInnerHistory
from rentcast_client.models.rentcast_property_records200_response_inner_hoa import RentcastPropertyRecords200ResponseInnerHoa
from rentcast_client.models.rentcast_property_records200_response_inner_owner import RentcastPropertyRecords200ResponseInnerOwner
from rentcast_client.models.rentcast_property_records200_response_inner_property_taxes import RentcastPropertyRecords200ResponseInnerPropertyTaxes
from rentcast_client.models.rentcast_property_records200_response_inner_tax_assessments import RentcastPropertyRecords200ResponseInnerTaxAssessments
from typing import Optional, Set
from typing_extensions import Self
from pydantic_core import to_jsonable_python

class RentcastPropertyRecords200ResponseInner(BaseModel):
    """
    RentcastPropertyRecords200ResponseInner
    """ # noqa: E501
    id: Optional[StrictStr] = None
    formatted_address: Optional[StrictStr] = Field(default=None, alias="formattedAddress")
    address_line1: Optional[StrictStr] = Field(default=None, alias="addressLine1")
    address_line2: Optional[StrictStr] = Field(default=None, alias="addressLine2")
    city: Optional[StrictStr] = None
    state: Optional[StrictStr] = None
    state_fips: Optional[StrictStr] = Field(default=None, alias="stateFips")
    zip_code: Optional[StrictStr] = Field(default=None, alias="zipCode")
    county: Optional[StrictStr] = None
    county_fips: Optional[StrictStr] = Field(default=None, alias="countyFips")
    latitude: Optional[Union[StrictFloat, StrictInt]] = None
    longitude: Optional[Union[StrictFloat, StrictInt]] = None
    property_type: Optional[StrictStr] = Field(default=None, alias="propertyType")
    bedrooms: Optional[Union[StrictFloat, StrictInt]] = None
    bathrooms: Optional[Union[StrictFloat, StrictInt]] = None
    square_footage: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="squareFootage")
    lot_size: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="lotSize")
    year_built: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="yearBuilt")
    assessor_id: Optional[StrictStr] = Field(default=None, alias="assessorID")
    legal_description: Optional[StrictStr] = Field(default=None, alias="legalDescription")
    subdivision: Optional[StrictStr] = None
    zoning: Optional[StrictStr] = None
    last_sale_date: Optional[datetime] = Field(default=None, alias="lastSaleDate")
    last_sale_price: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="lastSalePrice")
    hoa: Optional[RentcastPropertyRecords200ResponseInnerHoa] = None
    features: Optional[RentcastPropertyRecords200ResponseInnerFeatures] = None
    tax_assessments: Optional[RentcastPropertyRecords200ResponseInnerTaxAssessments] = Field(default=None, alias="taxAssessments")
    property_taxes: Optional[RentcastPropertyRecords200ResponseInnerPropertyTaxes] = Field(default=None, alias="propertyTaxes")
    history: Optional[RentcastPropertyRecords200ResponseInnerHistory] = None
    owner: Optional[RentcastPropertyRecords200ResponseInnerOwner] = None
    owner_occupied: Optional[StrictBool] = Field(default=False, alias="ownerOccupied")
    additional_properties: Dict[str, Any] = {}
    __properties: ClassVar[List[str]] = ["id", "formattedAddress", "addressLine1", "addressLine2", "city", "state", "stateFips", "zipCode", "county", "countyFips", "latitude", "longitude", "propertyType", "bedrooms", "bathrooms", "squareFootage", "lotSize", "yearBuilt", "assessorID", "legalDescription", "subdivision", "zoning", "lastSaleDate", "lastSalePrice", "hoa", "features", "taxAssessments", "propertyTaxes", "history", "owner", "ownerOccupied"]

    model_config = ConfigDict(
        validate_by_name=True,
        validate_by_alias=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"""
        return json.dumps(to_jsonable_python(self.to_dict()))

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of RentcastPropertyRecords200ResponseInner 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.
        * Fields in `self.additional_properties` are added to the output dict.
        """
        excluded_fields: Set[str] = set([
            "additional_properties",
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of hoa
        if self.hoa:
            _dict['hoa'] = self.hoa.to_dict()
        # override the default output from pydantic by calling `to_dict()` of features
        if self.features:
            _dict['features'] = self.features.to_dict()
        # override the default output from pydantic by calling `to_dict()` of tax_assessments
        if self.tax_assessments:
            _dict['taxAssessments'] = self.tax_assessments.to_dict()
        # override the default output from pydantic by calling `to_dict()` of property_taxes
        if self.property_taxes:
            _dict['propertyTaxes'] = self.property_taxes.to_dict()
        # override the default output from pydantic by calling `to_dict()` of history
        if self.history:
            _dict['history'] = self.history.to_dict()
        # override the default output from pydantic by calling `to_dict()` of owner
        if self.owner:
            _dict['owner'] = self.owner.to_dict()
        # puts key-value pairs in additional_properties in the top level
        if self.additional_properties is not None:
            for _key, _value in self.additional_properties.items():
                _dict[_key] = _value

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of RentcastPropertyRecords200ResponseInner 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"),
            "formattedAddress": obj.get("formattedAddress"),
            "addressLine1": obj.get("addressLine1"),
            "addressLine2": obj.get("addressLine2"),
            "city": obj.get("city"),
            "state": obj.get("state"),
            "stateFips": obj.get("stateFips"),
            "zipCode": obj.get("zipCode"),
            "county": obj.get("county"),
            "countyFips": obj.get("countyFips"),
            "latitude": obj.get("latitude") if obj.get("latitude") is not None else None,
            "longitude": obj.get("longitude") if obj.get("longitude") is not None else None,
            "propertyType": obj.get("propertyType"),
            "bedrooms": obj.get("bedrooms") if obj.get("bedrooms") is not None else None,
            "bathrooms": obj.get("bathrooms") if obj.get("bathrooms") is not None else None,
            "squareFootage": obj.get("squareFootage") if obj.get("squareFootage") is not None else None,
            "lotSize": obj.get("lotSize") if obj.get("lotSize") is not None else None,
            "yearBuilt": obj.get("yearBuilt") if obj.get("yearBuilt") is not None else None,
            "assessorID": obj.get("assessorID"),
            "legalDescription": obj.get("legalDescription"),
            "subdivision": obj.get("subdivision"),
            "zoning": obj.get("zoning"),
            "lastSaleDate": obj.get("lastSaleDate"),
            "lastSalePrice": obj.get("lastSalePrice") if obj.get("lastSalePrice") is not None else None,
            "hoa": RentcastPropertyRecords200ResponseInnerHoa.from_dict(obj["hoa"]) if obj.get("hoa") is not None else None,
            "features": RentcastPropertyRecords200ResponseInnerFeatures.from_dict(obj["features"]) if obj.get("features") is not None else None,
            "taxAssessments": RentcastPropertyRecords200ResponseInnerTaxAssessments.from_dict(obj["taxAssessments"]) if obj.get("taxAssessments") is not None else None,
            "propertyTaxes": RentcastPropertyRecords200ResponseInnerPropertyTaxes.from_dict(obj["propertyTaxes"]) if obj.get("propertyTaxes") is not None else None,
            "history": RentcastPropertyRecords200ResponseInnerHistory.from_dict(obj["history"]) if obj.get("history") is not None else None,
            "owner": RentcastPropertyRecords200ResponseInnerOwner.from_dict(obj["owner"]) if obj.get("owner") is not None else None,
            "ownerOccupied": obj.get("ownerOccupied") if obj.get("ownerOccupied") is not None else False
        })
        # store additional fields in additional_properties
        for _key in obj.keys():
            if _key not in cls.__properties:
                _obj.additional_properties[_key] = obj.get(_key)

        return _obj


