"""cellpointapi.

This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
"""

# ruff: noqa: E501
from cellpointapi.api_helper import APIHelper
from cellpointapi.models.phone import Phone
from cellpointapi.models.postal_address import (
    PostalAddress,
)


class Property(object):
    """Implementation of the 'Property' model.

    Details of the property where the lodging is located

    Attributes:
        name (str): Name of the property
        code (str): Code of the property
        address (PostalAddress): Address of the property
        email (str): Email of the property
        phone (Phone): Phone number of the property
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "name": "name",
        "code": "code",
        "address": "address",
        "phone": "phone",
        "email": "email",
    }

    _optionals = [
        "email",
    ]

    def __init__(
        self,
        name=None,
        code=None,
        address=None,
        phone=None,
        email=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a Property instance."""
        # Initialize members of the class
        self.name = name
        self.code = code
        self.address = address
        if email is not APIHelper.SKIP:
            self.email = email
        self.phone = phone

        # Add additional model properties to the instance
        if additional_properties is None:
            additional_properties = {}
        self.additional_properties = additional_properties

    @classmethod
    def from_dictionary(cls,
                        dictionary):
        """Create an instance of this model from a dictionary

        Args:
            dictionary (dictionary): A dictionary representation of the object
            as obtained from the deserialization of the server's response. The
            keys MUST match property names in the API description.

        Returns:
            object: An instance of this structure class.

        """
        if not isinstance(dictionary, dict) or dictionary is None:
            return None

        # Extract variables from the dictionary
        name =\
            dictionary.get("name")\
            if dictionary.get("name")\
                else None
        code =\
            dictionary.get("code")\
            if dictionary.get("code")\
                else None
        address =\
            PostalAddress.from_dictionary(
                dictionary.get("address"))\
                if dictionary.get("address") else None
        phone =\
            Phone.from_dictionary(
                dictionary.get("phone"))\
                if dictionary.get("phone") else None
        email =\
            dictionary.get("email")\
            if dictionary.get("email")\
                else APIHelper.SKIP

        additional_properties = APIHelper.get_additional_properties(
            dictionary={k: v for k, v in dictionary.items()
                        if k not in cls._names.values()},
            unboxing_function=lambda value: value)

        # Return an object of this model
        return cls(name,
                   code,
                   address,
                   phone,
                   email,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _name=self.name
        _code=self.code
        _address=self.address
        _email=(
            self.email
            if hasattr(self, "email")
            else None
        )
        _phone=self.phone
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"name={_name!r}, "
            f"code={_code!r}, "
            f"address={_address!r}, "
            f"email={_email!r}, "
            f"phone={_phone!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _name=self.name
        _code=self.code
        _address=self.address
        _email=(
            self.email
            if hasattr(self, "email")
            else None
        )
        _phone=self.phone
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"name={_name!s}, "
            f"code={_code!s}, "
            f"address={_address!s}, "
            f"email={_email!s}, "
            f"phone={_phone!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
