# coding: utf-8

"""
    Eazyrent core API

    EazyRent Core API ====================  Description -------------  The EazyRent API is a powerful tool, designed to automate and streamline the tenant application process for professionals in the real estate and insurance sectors.  Our API leverages advanced technologies like Optical Character Recognition (OCR) and Machine Learning to collect, analyze, and verify tenant application documents.  The API helps clients detect fraudulent submissions and assess the reliability of potential tenants, ensuring a secure and efficient tenant selection process.  Target Audience ----------------   * **Real Estate Agencies and Social Housing Providers:** Professionals who need a reliable solution to evaluate tenant applications quickly and accurately.   * **Rent Guarantee Insurers:** Companies seeking to verify the credibility of tenant applications and assess eligibility for rent payment guarantees.   Purpose --------  The purpose of the EazyRent API is to enable seamless interaction with our tenant application system. It allows clients to integrate our automated document collection, analysis, and verification capabilities directly into their own workflows. By using our API, businesses can streamline operations, reduce fraud risk, and make well-informed decisions in the tenant selection process.   How to use this API ---------------------  To start using the EazyRent API, please refer to our comprehensive online documentation, which includes detailed information on API endpoints, authentication, and integration examples. You can access the documentation [here](https://docs.eazyrent.fr). This resource will guide you through the steps needed to integrate our API into your existing systems and maximize its capabilities.  

    The version of the OpenAPI document: 2
    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.core.v2.models.product_photo import ProductPhoto
from eazyrent.core.v2.models.product_type import ProductType
from typing import Optional, Set
from typing_extensions import Self


class ListProductsProjection(BaseModel):
    """
    ListProductsProjection
    """  # 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
    id: StrictStr = Field(alias="_id")
    tenant: StrictStr
    created_at: datetime
    updated_at: datetime
    mandate_type: Optional[StrictStr] = Field(
        default="management", 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).",
    )
    photo: Optional[ProductPhoto] = None
    incoming_requests: Optional[StrictInt] = 0
    rent_amount: Optional[Union[StrictFloat, StrictInt]] = None
    monthly_charges: Optional[Union[StrictFloat, StrictInt]] = None
    furnished: Optional[StrictBool] = Field(
        default=False, description="Indicates whether the property is furnished."
    )
    warranty_amount: Optional[Union[StrictFloat, StrictInt]] = None
    agency_fees: Optional[Union[StrictFloat, StrictInt]] = None
    unpaid_rent_insurance: Optional[StrictBool] = None
    __properties: ClassVar[List[str]] = [
        "achived_at",
        "category",
        "title",
        "description",
        "reference",
        "available",
        "availability",
        "exclusivity",
        "disable_spontaneous_applications",
        "managers",
        "meta",
        "_id",
        "tenant",
        "created_at",
        "updated_at",
        "mandate_type",
        "price",
        "fee",
        "fee_type",
        "photo",
        "incoming_requests",
        "rent_amount",
        "monthly_charges",
        "furnished",
        "warranty_amount",
        "agency_fees",
        "unpaid_rent_insurance",
    ]

    @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(["management", "sales"]):
            raise ValueError("must be one of enum values ('management', '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 ListProductsProjection 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 photo
        if self.photo:
            _dict["photo"] = self.photo.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 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

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

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

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

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

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

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

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of ListProductsProjection 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"),
                "_id": obj.get("_id"),
                "tenant": obj.get("tenant"),
                "created_at": obj.get("created_at"),
                "updated_at": obj.get("updated_at"),
                "mandate_type": obj.get("mandate_type")
                if obj.get("mandate_type") is not None
                else "management",
                "price": obj.get("price"),
                "fee": obj.get("fee"),
                "fee_type": obj.get("fee_type")
                if obj.get("fee_type") is not None
                else "direct",
                "photo": ProductPhoto.from_dict(obj["photo"])
                if obj.get("photo") is not None
                else None,
                "incoming_requests": obj.get("incoming_requests")
                if obj.get("incoming_requests") is not None
                else 0,
                "rent_amount": obj.get("rent_amount"),
                "monthly_charges": obj.get("monthly_charges"),
                "furnished": obj.get("furnished")
                if obj.get("furnished") is not None
                else False,
                "warranty_amount": obj.get("warranty_amount"),
                "agency_fees": obj.get("agency_fees"),
                "unpaid_rent_insurance": obj.get("unpaid_rent_insurance"),
            }
        )
        return _obj
