# coding: utf-8

"""
    Fiscal document service API

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: v1
    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, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from cloudbeds_fiscal_document.models.recipient_address import RecipientAddress
from cloudbeds_fiscal_document.models.recipient_company import RecipientCompany
from cloudbeds_fiscal_document.models.recipient_contact_details import RecipientContactDetails
from cloudbeds_fiscal_document.models.recipient_document import RecipientDocument
from cloudbeds_fiscal_document.models.recipient_tax_info import RecipientTaxInfo
from cloudbeds_fiscal_document.models.recipient_type import RecipientType
from typing import Optional, Set
from typing_extensions import Self

class FiscalDocumentRecipient(BaseModel):
    """
    FiscalDocumentRecipient
    """ # noqa: E501
    id: Optional[Annotated[str, Field(min_length=1, strict=True)]] = None
    first_name: Optional[StrictStr] = Field(default=None, alias="firstName")
    last_name: Optional[StrictStr] = Field(default=None, alias="lastName")
    email: Optional[StrictStr] = None
    type: Optional[RecipientType] = None
    address: Optional[RecipientAddress] = None
    company: Optional[RecipientCompany] = None
    tax: Optional[RecipientTaxInfo] = None
    contact_details: Optional[RecipientContactDetails] = Field(default=None, alias="contactDetails")
    document: Optional[RecipientDocument] = None
    country_data: Optional[Dict[str, Any]] = Field(default=None, description="Arbitrary country-specific fields from guest requirements. ", alias="countryData")
    __properties: ClassVar[List[str]] = ["id", "firstName", "lastName", "email", "type", "address", "company", "tax", "contactDetails", "document", "countryData"]

    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 FiscalDocumentRecipient 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 company
        if self.company:
            _dict['company'] = self.company.to_dict()
        # override the default output from pydantic by calling `to_dict()` of tax
        if self.tax:
            _dict['tax'] = self.tax.to_dict()
        # override the default output from pydantic by calling `to_dict()` of contact_details
        if self.contact_details:
            _dict['contactDetails'] = self.contact_details.to_dict()
        # override the default output from pydantic by calling `to_dict()` of document
        if self.document:
            _dict['document'] = self.document.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of FiscalDocumentRecipient 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"),
            "firstName": obj.get("firstName"),
            "lastName": obj.get("lastName"),
            "email": obj.get("email"),
            "type": obj.get("type"),
            "address": RecipientAddress.from_dict(obj["address"]) if obj.get("address") is not None else None,
            "company": RecipientCompany.from_dict(obj["company"]) if obj.get("company") is not None else None,
            "tax": RecipientTaxInfo.from_dict(obj["tax"]) if obj.get("tax") is not None else None,
            "contactDetails": RecipientContactDetails.from_dict(obj["contactDetails"]) if obj.get("contactDetails") is not None else None,
            "document": RecipientDocument.from_dict(obj["document"]) if obj.get("document") is not None else None,
            "countryData": obj.get("countryData")
        })
        return _obj


