# -*- coding: utf-8 -*-

"""
paypalserversdk

This file was automatically generated by APIMATIC v3.0 (
 https://www.apimatic.io ).
"""
from paypalserversdk.api_helper import APIHelper
from paypalserversdk.models.name import Name
from paypalserversdk.models.shipping_details import ShippingDetails
from paypalserversdk.models.subscription_payment_source_response import SubscriptionPaymentSourceResponse


class Subscriber(object):

    """Implementation of the 'Subscriber' model.

    The subscriber response information.

    Attributes:
        name (Name): The name of the party.
        shipping_address (ShippingDetails): The shipping details.
        payment_source (SubscriptionPaymentSourceResponse): The payment source
            used to fund the payment.

    """

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

    _optionals = [
        'name',
        'shipping_address',
        'payment_source',
    ]

    def __init__(self,
                 name=APIHelper.SKIP,
                 shipping_address=APIHelper.SKIP,
                 payment_source=APIHelper.SKIP):
        """Constructor for the Subscriber class"""

        # Initialize members of the class
        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 

    @classmethod
    def from_dictionary(cls,
                        dictionary):
        """Creates 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 = 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 = SubscriptionPaymentSourceResponse.from_dictionary(dictionary.get('payment_source')) if 'payment_source' in dictionary.keys() else APIHelper.SKIP
        # Return an object of this model
        return cls(name,
                   shipping_address,
                   payment_source)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'name={(self.name if hasattr(self, "name") else None)!r}, '
                f'shipping_address={(self.shipping_address if hasattr(self, "shipping_address") else None)!r}, '
                f'payment_source={(self.payment_source if hasattr(self, "payment_source") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'name={(self.name if hasattr(self, "name") else None)!s}, '
                f'shipping_address={(self.shipping_address if hasattr(self, "shipping_address") else None)!s}, '
                f'payment_source={(self.payment_source if hasattr(self, "payment_source") else None)!s})')
