# 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 pydantic import BaseModel, ConfigDict, StrictInt, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from eazyrent.core.v2.models.file import File
from eazyrent.core.v2.models.images import Images
from eazyrent.core.v2.models.thumbnail import Thumbnail
from typing import Optional, Set
from typing_extensions import Self


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

    file_id: StrictStr
    file: File
    thumbnail: Thumbnail
    images: Images
    pages: Optional[List[StrictInt]] = None
    __properties: ClassVar[List[str]] = [
        "file_id",
        "file",
        "thumbnail",
        "images",
        "pages",
    ]

    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 DocumentSlice 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 file
        if self.file:
            _dict["file"] = self.file.to_dict()
        # override the default output from pydantic by calling `to_dict()` of thumbnail
        if self.thumbnail:
            _dict["thumbnail"] = self.thumbnail.to_dict()
        # override the default output from pydantic by calling `to_dict()` of images
        if self.images:
            _dict["images"] = self.images.to_dict()
        return _dict

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

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

        _obj = cls.model_validate(
            {
                "file_id": obj.get("file_id"),
                "file": File.from_dict(obj["file"])
                if obj.get("file") is not None
                else None,
                "thumbnail": Thumbnail.from_dict(obj["thumbnail"])
                if obj.get("thumbnail") is not None
                else None,
                "images": Images.from_dict(obj["images"])
                if obj.get("images") is not None
                else None,
                "pages": obj.get("pages"),
            }
        )
        return _obj
