"""cellpointapi.

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

# ruff: noqa: E501
from cellpointapi.api_helper import APIHelper


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

    Telephone number.

    Attributes:
        phone_number (str): The model property of type str.
        is_phone_verified (bool): The model property of type bool.
        phone_country_code (str): The codes are defined by the ITU-T in standards
            E.123 and E.164.  The prefixes enable international direct dialing (IDD)
            and  are also referred to as international subscriber dialing (ISD)
            codes. Country codes are a component of the international telephone
            numbering plan and  are necessary only when dialing a telephone number to
            establish a call to another country.  Country codes are dialed before the
            national telephone number.  By convention, international telephone
            numbers are represented by prefixing the country code with a plus sign
            (+). Only a plus sign and digits should be used in this field, despite
            some country codes often are written in formats with other characters,
            for instance use +1767 for Dominica and not +1-767, +1 767 or +1(767).
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "phone_number": "phoneNumber",
        "phone_country_code": "phoneCountryCode",
        "is_phone_verified": "isPhoneVerified",
    }

    _optionals = [
        "is_phone_verified",
    ]

    def __init__(
        self,
        phone_number=None,
        phone_country_code=None,
        is_phone_verified=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a Phone instance."""
        # Initialize members of the class
        self.phone_number = phone_number
        if is_phone_verified is not APIHelper.SKIP:
            self.is_phone_verified = is_phone_verified
        self.phone_country_code = phone_country_code

        # 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
        phone_number =\
            dictionary.get("phoneNumber")\
            if dictionary.get("phoneNumber")\
                else None
        phone_country_code =\
            dictionary.get("phoneCountryCode")\
            if dictionary.get("phoneCountryCode")\
                else None
        is_phone_verified =\
            dictionary.get("isPhoneVerified")\
            if "isPhoneVerified" in dictionary.keys()\
                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(phone_number,
                   phone_country_code,
                   is_phone_verified,
                   additional_properties)

    @classmethod
    def validate(cls, dictionary):
        """Validate dictionary against class required properties

        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:
            boolean : if dictionary is valid contains required properties.

        """
        if isinstance(dictionary, cls):
            return APIHelper.is_valid_type(
                    value=dictionary.phone_number,
                    type_callable=lambda value:
                        isinstance(
                        value,
                        str,
                )) \
                and APIHelper.is_valid_type(
                    value=dictionary.phone_country_code,
                    type_callable=lambda value:
                        isinstance(
                        value,
                        str,
                ))

        if not isinstance(dictionary, dict):
            return False

        return APIHelper.is_valid_type(
                value=dictionary.get("phoneNumber"),
                type_callable=lambda value:
                    isinstance(
                    value,
                    str,
            )) \
            and APIHelper.is_valid_type(
                value=dictionary.get("phoneCountryCode"),
                type_callable=lambda value:
                    isinstance(
                    value,
                    str,
            ))

    def __repr__(self):
        """Return a unambiguous string representation."""
        _phone_number=self.phone_number
        _is_phone_verified=(
            self.is_phone_verified
            if hasattr(self, "is_phone_verified")
            else None
        )
        _phone_country_code=self.phone_country_code
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"phone_number={_phone_number!r}, "
            f"is_phone_verified={_is_phone_verified!r}, "
            f"phone_country_code={_phone_country_code!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _phone_number=self.phone_number
        _is_phone_verified=(
            self.is_phone_verified
            if hasattr(self, "is_phone_verified")
            else None
        )
        _phone_country_code=self.phone_country_code
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"phone_number={_phone_number!s}, "
            f"is_phone_verified={_is_phone_verified!s}, "
            f"phone_country_code={_phone_country_code!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
