# 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, StrictFloat, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from rentcast_client.models.rentcast_sale_listings200_response_inner_history import RentcastSaleListings200ResponseInnerHistory
from rentcast_client.models.rentcast_sale_listings200_response_inner_hoa import RentcastSaleListings200ResponseInnerHoa
from rentcast_client.models.rentcast_sale_listings200_response_inner_listing_agent import RentcastSaleListings200ResponseInnerListingAgent
from rentcast_client.models.rentcast_sale_listings200_response_inner_listing_office import RentcastSaleListings200ResponseInnerListingOffice
from typing import Optional, Set
from typing_extensions import Self
from pydantic_core import to_jsonable_python

class RentcastSaleListings200ResponseInner(BaseModel):
    """
    RentcastSaleListings200ResponseInner
    """ # 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")
    hoa: Optional[RentcastSaleListings200ResponseInnerHoa] = None
    status: Optional[StrictStr] = None
    price: Optional[Union[StrictFloat, StrictInt]] = None
    listing_type: Optional[StrictStr] = Field(default=None, alias="listingType")
    listed_date: Optional[datetime] = Field(default=None, alias="listedDate")
    removed_date: Optional[datetime] = Field(default=None, alias="removedDate")
    created_date: Optional[datetime] = Field(default=None, alias="createdDate")
    last_seen_date: Optional[datetime] = Field(default=None, alias="lastSeenDate")
    days_on_market: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="daysOnMarket")
    mls_name: Optional[StrictStr] = Field(default=None, alias="mlsName")
    mls_number: Optional[StrictStr] = Field(default=None, alias="mlsNumber")
    listing_agent: Optional[RentcastSaleListings200ResponseInnerListingAgent] = Field(default=None, alias="listingAgent")
    listing_office: Optional[RentcastSaleListings200ResponseInnerListingOffice] = Field(default=None, alias="listingOffice")
    history: Optional[RentcastSaleListings200ResponseInnerHistory] = None
    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", "hoa", "status", "price", "listingType", "listedDate", "removedDate", "createdDate", "lastSeenDate", "daysOnMarket", "mlsName", "mlsNumber", "listingAgent", "listingOffice", "history"]

    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 RentcastSaleListings200ResponseInner 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 listing_agent
        if self.listing_agent:
            _dict['listingAgent'] = self.listing_agent.to_dict()
        # override the default output from pydantic by calling `to_dict()` of listing_office
        if self.listing_office:
            _dict['listingOffice'] = self.listing_office.to_dict()
        # override the default output from pydantic by calling `to_dict()` of history
        if self.history:
            _dict['history'] = self.history.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 RentcastSaleListings200ResponseInner 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,
            "hoa": RentcastSaleListings200ResponseInnerHoa.from_dict(obj["hoa"]) if obj.get("hoa") is not None else None,
            "status": obj.get("status"),
            "price": obj.get("price") if obj.get("price") is not None else None,
            "listingType": obj.get("listingType"),
            "listedDate": obj.get("listedDate"),
            "removedDate": obj.get("removedDate"),
            "createdDate": obj.get("createdDate"),
            "lastSeenDate": obj.get("lastSeenDate"),
            "daysOnMarket": obj.get("daysOnMarket") if obj.get("daysOnMarket") is not None else None,
            "mlsName": obj.get("mlsName"),
            "mlsNumber": obj.get("mlsNumber"),
            "listingAgent": RentcastSaleListings200ResponseInnerListingAgent.from_dict(obj["listingAgent"]) if obj.get("listingAgent") is not None else None,
            "listingOffice": RentcastSaleListings200ResponseInnerListingOffice.from_dict(obj["listingOffice"]) if obj.get("listingOffice") is not None else None,
            "history": RentcastSaleListings200ResponseInnerHistory.from_dict(obj["history"]) if obj.get("history") is not None else None
        })
        # 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


