# 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 datetime import date, datetime
from pydantic import (
    BaseModel,
    ConfigDict,
    Field,
    StrictBool,
    StrictFloat,
    StrictInt,
    StrictStr,
    field_validator,
)
from typing import Any, ClassVar, Dict, List, Optional, Union
from eazyrent.products.v1.models.address import Address
from eazyrent.products.v1.models.building_information import BuildingInformation
from eazyrent.products.v1.models.internal_information import InternalInformation
from eazyrent.products.v1.models.product_type import ProductType
from eazyrent.products.v1.models.property_facilities import PropertyFacilities
from typing import Optional, Set
from typing_extensions import Self


class CreateForSaleProductInput(BaseModel):
    """
    CreateForSaleProductInput
    """  # noqa: E501

    achived_at: Optional[datetime] = None
    category: Optional[ProductType] = None
    title: Optional[StrictStr] = None
    description: Optional[StrictStr] = None
    reference: Optional[StrictStr] = None
    available: Optional[StrictBool] = Field(
        default=True,
        description="Indicates whether the property is currently available.",
    )
    availability: Optional[date] = None
    exclusivity: Optional[StrictBool] = None
    disable_spontaneous_applications: Optional[StrictBool] = Field(
        default=False,
        description="If disabled, the public link to send an application will stop accepting applications.",
    )
    managers: Optional[List[StrictStr]] = None
    meta: Optional[Any] = None
    address: Optional[Address] = None
    owner: Optional[StrictStr] = None
    building_information: Optional[BuildingInformation] = None
    property_facilities: Optional[PropertyFacilities] = None
    internal_information: Optional[InternalInformation] = None
    mandate_type: Optional[StrictStr] = Field(
        default="sales", description="The type of mandate for the property."
    )
    price: Optional[Union[StrictFloat, StrictInt]] = None
    fee: Optional[Union[StrictFloat, StrictInt]] = None
    fee_type: Optional[StrictStr] = Field(
        default="direct",
        description="The type of fee arrangement (e.g., direct or reverse).",
    )
    __properties: ClassVar[List[str]] = [
        "achived_at",
        "category",
        "title",
        "description",
        "reference",
        "available",
        "availability",
        "exclusivity",
        "disable_spontaneous_applications",
        "managers",
        "meta",
        "address",
        "owner",
        "building_information",
        "property_facilities",
        "internal_information",
        "mandate_type",
        "price",
        "fee",
        "fee_type",
    ]

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

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

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

        if value not in set(["direct", "reverse"]):
            raise ValueError("must be one of enum values ('direct', 'reverse')")
        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 CreateForSaleProductInput 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 address
        if self.address:
            _dict["address"] = self.address.to_dict()
        # override the default output from pydantic by calling `to_dict()` of building_information
        if self.building_information:
            _dict["building_information"] = self.building_information.to_dict()
        # override the default output from pydantic by calling `to_dict()` of property_facilities
        if self.property_facilities:
            _dict["property_facilities"] = self.property_facilities.to_dict()
        # override the default output from pydantic by calling `to_dict()` of internal_information
        if self.internal_information:
            _dict["internal_information"] = self.internal_information.to_dict()
        # set to None if achived_at (nullable) is None
        # and model_fields_set contains the field
        if self.achived_at is None and "achived_at" in self.model_fields_set:
            _dict["achived_at"] = None

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        return _dict

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

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

        _obj = cls.model_validate(
            {
                "achived_at": obj.get("achived_at"),
                "category": obj.get("category"),
                "title": obj.get("title"),
                "description": obj.get("description"),
                "reference": obj.get("reference"),
                "available": obj.get("available")
                if obj.get("available") is not None
                else True,
                "availability": obj.get("availability"),
                "exclusivity": obj.get("exclusivity"),
                "disable_spontaneous_applications": obj.get(
                    "disable_spontaneous_applications"
                )
                if obj.get("disable_spontaneous_applications") is not None
                else False,
                "managers": obj.get("managers"),
                "meta": obj.get("meta"),
                "address": Address.from_dict(obj["address"])
                if obj.get("address") is not None
                else None,
                "owner": obj.get("owner"),
                "building_information": BuildingInformation.from_dict(
                    obj["building_information"]
                )
                if obj.get("building_information") is not None
                else None,
                "property_facilities": PropertyFacilities.from_dict(
                    obj["property_facilities"]
                )
                if obj.get("property_facilities") is not None
                else None,
                "internal_information": InternalInformation.from_dict(
                    obj["internal_information"]
                )
                if obj.get("internal_information") is not None
                else None,
                "mandate_type": obj.get("mandate_type")
                if obj.get("mandate_type") is not None
                else "sales",
                "price": obj.get("price"),
                "fee": obj.get("fee"),
                "fee_type": obj.get("fee_type")
                if obj.get("fee_type") is not None
                else "direct",
            }
        )
        return _obj
