"""paypalserversdk.

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

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


class PhoneNumberWithOptionalCountryCode(object):
    """Implementation of the 'Phone Number With Optional Country Code' model.

    The phone number in its canonical international [E.164 numbering plan
    format](https://www.itu.int/rec/T-REC-E.164/en).

    Attributes:
        country_code (str): The country calling code (CC), in its canonical
            international [E.164 numbering plan
            format](https://www.itu.int/rec/T-REC-E.164/en). The combined length of
            the CC and the national number must not be greater than 15 digits. The
            national number consists of a national destination code (NDC) and
            subscriber number (SN).
        national_number (str): The national number, in its canonical international
            [E.164 numbering plan format](https://www.itu.int/rec/T-REC-E.164/en).
            The combined length of the country calling code (CC) and the national
            number must not be greater than 15 digits. The national number consists
            of a national destination code (NDC) and subscriber number (SN).

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "national_number": "national_number",
        "country_code": "country_code",
    }

    _optionals = [
        "country_code",
    ]

    def __init__(
        self,
        national_number=None,
        country_code=APIHelper.SKIP):
        """Initialize a PhoneNumberWithOptionalCountryCode instance."""
        # Initialize members of the class
        if country_code is not APIHelper.SKIP:
            self.country_code = country_code
        self.national_number = national_number

    @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
        national_number =\
            dictionary.get("national_number")\
            if dictionary.get("national_number")\
                else None
        country_code =\
            dictionary.get("country_code")\
            if dictionary.get("country_code")\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(national_number,
                   country_code)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _country_code=(
            self.country_code
            if hasattr(self, "country_code")
            else None
        )
        _national_number=self.national_number
        return (
            f"{self.__class__.__name__}("
            f"country_code={_country_code!r}, "
            f"national_number={_national_number!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _country_code=(
            self.country_code
            if hasattr(self, "country_code")
            else None
        )
        _national_number=self.national_number
        return (
            f"{self.__class__.__name__}("
            f"country_code={_country_code!s}, "
            f"national_number={_national_number!s}, "
            f")"
        )
