"""paypalserversdk.

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

# ruff: noqa: E501
from paypalserversdk.api_helper import APIHelper
from paypalserversdk.models.name import Name
from paypalserversdk.models.phone_with_type import (
    PhoneWithType,
)
from paypalserversdk.models.shipping_details import (
    ShippingDetails,
)
from paypalserversdk.models.subscription_payment_source import (
    SubscriptionPaymentSource,
)


class SubscriberRequest(object):
    """Implementation of the 'Subscriber Request' model.

    The subscriber request information .

    Attributes:
        email_address (str): The internationalized email address. Note: Up to 64
            characters are allowed before and 255 characters are allowed after the @
            sign. However, the generally accepted maximum length for an email address
            is 254 characters. The pattern verifies that an unquoted @ sign exists.
        payer_id (str): The account identifier for a PayPal account.
        name (Name): The name of the party.
        shipping_address (ShippingDetails): The shipping details.
        payment_source (SubscriptionPaymentSource): The payment source definition. To
            be eligible to create subscription using debit or credit card, you will
            need to sign up here
            (https://www.paypal.com/bizsignup/entry/product/ppcp). Please note, its
            available only for non-3DS cards and for merchants in US and AU regions.
        phone (PhoneWithType): The phone information.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "email_address": "email_address",
        "payer_id": "payer_id",
        "name": "name",
        "shipping_address": "shipping_address",
        "payment_source": "payment_source",
        "phone": "phone",
    }

    _optionals = [
        "email_address",
        "payer_id",
        "name",
        "shipping_address",
        "payment_source",
        "phone",
    ]

    def __init__(
        self,
        email_address=APIHelper.SKIP,
        payer_id=APIHelper.SKIP,
        name=APIHelper.SKIP,
        shipping_address=APIHelper.SKIP,
        payment_source=APIHelper.SKIP,
        phone=APIHelper.SKIP):
        """Initialize a SubscriberRequest instance."""
        # Initialize members of the class
        if email_address is not APIHelper.SKIP:
            self.email_address = email_address
        if payer_id is not APIHelper.SKIP:
            self.payer_id = payer_id
        if name is not APIHelper.SKIP:
            self.name = name
        if shipping_address is not APIHelper.SKIP:
            self.shipping_address = shipping_address
        if payment_source is not APIHelper.SKIP:
            self.payment_source = payment_source
        if phone is not APIHelper.SKIP:
            self.phone = phone

    @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
        email_address =\
            dictionary.get("email_address")\
            if dictionary.get("email_address")\
                else APIHelper.SKIP
        payer_id =\
            dictionary.get("payer_id")\
            if dictionary.get("payer_id")\
                else APIHelper.SKIP
        name =\
            Name.from_dictionary(
                dictionary.get("name"))\
                if "name" in dictionary.keys()\
                else APIHelper.SKIP
        shipping_address =\
            ShippingDetails.from_dictionary(
                dictionary.get("shipping_address"))\
                if "shipping_address" in dictionary.keys()\
                else APIHelper.SKIP
        payment_source =\
            SubscriptionPaymentSource.from_dictionary(
                dictionary.get("payment_source"))\
                if "payment_source" in dictionary.keys()\
                else APIHelper.SKIP
        phone =\
            PhoneWithType.from_dictionary(
                dictionary.get("phone"))\
                if "phone" in dictionary.keys()\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(email_address,
                   payer_id,
                   name,
                   shipping_address,
                   payment_source,
                   phone)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _email_address=(
            self.email_address
            if hasattr(self, "email_address")
            else None
        )
        _payer_id=(
            self.payer_id
            if hasattr(self, "payer_id")
            else None
        )
        _name=(
            self.name
            if hasattr(self, "name")
            else None
        )
        _shipping_address=(
            self.shipping_address
            if hasattr(self, "shipping_address")
            else None
        )
        _payment_source=(
            self.payment_source
            if hasattr(self, "payment_source")
            else None
        )
        _phone=(
            self.phone
            if hasattr(self, "phone")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"email_address={_email_address!r}, "
            f"payer_id={_payer_id!r}, "
            f"name={_name!r}, "
            f"shipping_address={_shipping_address!r}, "
            f"payment_source={_payment_source!r}, "
            f"phone={_phone!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _email_address=(
            self.email_address
            if hasattr(self, "email_address")
            else None
        )
        _payer_id=(
            self.payer_id
            if hasattr(self, "payer_id")
            else None
        )
        _name=(
            self.name
            if hasattr(self, "name")
            else None
        )
        _shipping_address=(
            self.shipping_address
            if hasattr(self, "shipping_address")
            else None
        )
        _payment_source=(
            self.payment_source
            if hasattr(self, "payment_source")
            else None
        )
        _phone=(
            self.phone
            if hasattr(self, "phone")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"email_address={_email_address!s}, "
            f"payer_id={_payer_id!s}, "
            f"name={_name!s}, "
            f"shipping_address={_shipping_address!s}, "
            f"payment_source={_payment_source!s}, "
            f"phone={_phone!s}, "
            f")"
        )
