# coding: utf-8

"""
    Eazyrent products API

    EazyRent Products API ======================  Description ------------  The EazyRent Product API offers a comprehensive solution for managing rental and sale listings, including property details, media distribution, and data import capabilities. Designed for real estate professionals, this API allows users to create, update, and manage property listings efficiently while ensuring accurate data and broad market reach. With features to streamline listing distribution and import property data from other platforms, the Product API simplifies property management, helping agencies maintain up-to-date and comprehensive property portfolios.  Target Audience -----------------   * **Real Estate Agencies and Social Housing Providers:** Professionals who need a centralized system to manage property listings, including rental and sale offerings, media distribution, and data synchronization across various platforms.   * **Property Managers:** Organizations looking to efficiently organize and promote property listings, manage property details, and ensure accurate, consistent information across marketing channels.  Purpose ---------  The purpose of the EazyRent Product API is to enable streamlined property management within the EazyRent platform. By integrating this API, businesses can centralize their property data, automate distribution to marketing channels, and simplify the process of keeping listings updated. This provides agencies with a scalable, efficient way to manage property portfolios, ensuring quick, effective exposure to potential tenants and buyers.  How to use this API ---------------------  To get started with the EazyRent Product API, please refer to our comprehensive documentation for authentication details, endpoint descriptions, and integration guides. This resource will help you set up efficient property management workflows, from data import to listing updates and distribution, all accessible within your existing systems.

    The version of the OpenAPI document: 1
    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,
    StrictBool,
    StrictInt,
    StrictStr,
    field_validator,
)
from typing import Any, ClassVar, Dict, List, Optional
from eazyrent.products.v1.models.air_conditioning import AirConditioning
from eazyrent.products.v1.models.equipement import Equipement
from eazyrent.products.v1.models.pool_specification import PoolSpecification
from eazyrent.products.v1.models.room_specification import RoomSpecification
from eazyrent.products.v1.models.security_facilities import SecurityFacilities
from typing import Optional, Set
from typing_extensions import Self


class PropertyFacilities(BaseModel):
    """
    Represents the facilities available in a property, including air conditioning, pool specifications, garage, terraces, cellars, gardens, internet access, additional equipment, intercom, elevator, and parking details.
    """  # noqa: E501

    air_conditioning: Optional[AirConditioning] = None
    pool: Optional[PoolSpecification] = None
    garage: Optional[List[RoomSpecification]] = Field(
        default=None,
        description="A list of specifications for the property's garage(s). Each entry in the list represents a different garage. The list is empty if there are no garages.",
    )
    terraces: Optional[List[RoomSpecification]] = Field(
        default=None,
        description="A list of specifications for the property's terrace(s). Each entry in the list represents a different terrace. The list is empty if there are no terraces.",
    )
    cellars: Optional[List[RoomSpecification]] = Field(
        default=None,
        description="A list of specifications for the property's cellar(s). Each entry in the list represents a different cellar. The list is empty if there are no cellars.",
    )
    gardens: Optional[List[RoomSpecification]] = Field(
        default=None,
        description="A list of specifications for the property's garden(s). Each entry in the list represents a different garden. The list is empty if there are no gardens.",
    )
    internet_access: Optional[StrictStr] = None
    others: Optional[List[Equipement]] = Field(
        default=None,
        description="A list of other equipment available in the property. Each entry in the list represents a different piece of equipment. The list is empty if there are no additional equipment details.",
    )
    intercom: Optional[StrictBool] = None
    elevator: Optional[StrictBool] = None
    parking: Optional[StrictInt] = Field(
        default=0,
        description="The number of parking spaces available at the property. The default is 0.",
    )
    security_facilities: Optional[SecurityFacilities] = None
    __properties: ClassVar[List[str]] = [
        "air_conditioning",
        "pool",
        "garage",
        "terraces",
        "cellars",
        "gardens",
        "internet_access",
        "others",
        "intercom",
        "elevator",
        "parking",
        "security_facilities",
    ]

    @field_validator("internet_access")
    def internet_access_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(["unknown", "fiber", "copper"]):
            raise ValueError(
                "must be one of enum values ('unknown', 'fiber', 'copper')"
            )
        return value

    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 PropertyFacilities 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 air_conditioning
        if self.air_conditioning:
            _dict["air_conditioning"] = self.air_conditioning.to_dict()
        # override the default output from pydantic by calling `to_dict()` of pool
        if self.pool:
            _dict["pool"] = self.pool.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in garage (list)
        _items = []
        if self.garage:
            for _item_garage in self.garage:
                if _item_garage:
                    _items.append(_item_garage.to_dict())
            _dict["garage"] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in terraces (list)
        _items = []
        if self.terraces:
            for _item_terraces in self.terraces:
                if _item_terraces:
                    _items.append(_item_terraces.to_dict())
            _dict["terraces"] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in cellars (list)
        _items = []
        if self.cellars:
            for _item_cellars in self.cellars:
                if _item_cellars:
                    _items.append(_item_cellars.to_dict())
            _dict["cellars"] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in gardens (list)
        _items = []
        if self.gardens:
            for _item_gardens in self.gardens:
                if _item_gardens:
                    _items.append(_item_gardens.to_dict())
            _dict["gardens"] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in others (list)
        _items = []
        if self.others:
            for _item_others in self.others:
                if _item_others:
                    _items.append(_item_others.to_dict())
            _dict["others"] = _items
        # override the default output from pydantic by calling `to_dict()` of security_facilities
        if self.security_facilities:
            _dict["security_facilities"] = self.security_facilities.to_dict()
        # set to None if air_conditioning (nullable) is None
        # and model_fields_set contains the field
        if (
            self.air_conditioning is None
            and "air_conditioning" in self.model_fields_set
        ):
            _dict["air_conditioning"] = None

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate(
            {
                "air_conditioning": AirConditioning.from_dict(obj["air_conditioning"])
                if obj.get("air_conditioning") is not None
                else None,
                "pool": PoolSpecification.from_dict(obj["pool"])
                if obj.get("pool") is not None
                else None,
                "garage": [
                    RoomSpecification.from_dict(_item) for _item in obj["garage"]
                ]
                if obj.get("garage") is not None
                else None,
                "terraces": [
                    RoomSpecification.from_dict(_item) for _item in obj["terraces"]
                ]
                if obj.get("terraces") is not None
                else None,
                "cellars": [
                    RoomSpecification.from_dict(_item) for _item in obj["cellars"]
                ]
                if obj.get("cellars") is not None
                else None,
                "gardens": [
                    RoomSpecification.from_dict(_item) for _item in obj["gardens"]
                ]
                if obj.get("gardens") is not None
                else None,
                "internet_access": obj.get("internet_access"),
                "others": [Equipement.from_dict(_item) for _item in obj["others"]]
                if obj.get("others") is not None
                else None,
                "intercom": obj.get("intercom"),
                "elevator": obj.get("elevator"),
                "parking": obj.get("parking") if obj.get("parking") is not None else 0,
                "security_facilities": SecurityFacilities.from_dict(
                    obj["security_facilities"]
                )
                if obj.get("security_facilities") is not None
                else None,
            }
        )
        return _obj
