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

"""
paypalserversdk

This file was automatically generated by APIMATIC v3.0 (
 https://www.apimatic.io ).
"""
from paypalserversdk.api_helper import APIHelper


class PaypalWalletStoredCredential(object):

    """Implementation of the 'PayPal Wallet Stored Credential' model.

    Provides additional details to process a payment using the PayPal wallet
    billing agreement or a vaulted payment method that has been stored or is
    intended to be stored.

    Attributes:
        payment_initiator (PaymentInitiator): The person or party who
            initiated or triggered the payment.
        charge_pattern (UsagePattern): DEPRECATED. Expected business/pricing
            model for the billing agreement, Please use usage_pattern instead.
        usage_pattern (UsagePattern): Expected business/pricing model for the
            billing agreement.
        usage (StoredPaymentSourceUsageType): Indicates if this is a `first`
            or `subsequent` payment using a stored payment source (also
            referred to as stored credential or card on file).

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "payment_initiator": 'payment_initiator',
        "charge_pattern": 'charge_pattern',
        "usage_pattern": 'usage_pattern',
        "usage": 'usage'
    }

    _optionals = [
        'charge_pattern',
        'usage_pattern',
        'usage',
    ]

    def __init__(self,
                 payment_initiator=None,
                 charge_pattern=APIHelper.SKIP,
                 usage_pattern=APIHelper.SKIP,
                 usage='DERIVED'):
        """Constructor for the PaypalWalletStoredCredential class"""

        # Initialize members of the class
        self.payment_initiator = payment_initiator 
        if charge_pattern is not APIHelper.SKIP:
            self.charge_pattern = charge_pattern 
        if usage_pattern is not APIHelper.SKIP:
            self.usage_pattern = usage_pattern 
        self.usage = usage 

    @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
        payment_initiator = dictionary.get("payment_initiator") if dictionary.get("payment_initiator") else None
        charge_pattern = dictionary.get("charge_pattern") if dictionary.get("charge_pattern") else APIHelper.SKIP
        usage_pattern = dictionary.get("usage_pattern") if dictionary.get("usage_pattern") else APIHelper.SKIP
        usage = dictionary.get("usage") if dictionary.get("usage") else 'DERIVED'
        # Return an object of this model
        return cls(payment_initiator,
                   charge_pattern,
                   usage_pattern,
                   usage)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'payment_initiator={self.payment_initiator!r}, '
                f'charge_pattern={(self.charge_pattern if hasattr(self, "charge_pattern") else None)!r}, '
                f'usage_pattern={(self.usage_pattern if hasattr(self, "usage_pattern") else None)!r}, '
                f'usage={(self.usage if hasattr(self, "usage") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'payment_initiator={self.payment_initiator!s}, '
                f'charge_pattern={(self.charge_pattern if hasattr(self, "charge_pattern") else None)!s}, '
                f'usage_pattern={(self.usage_pattern if hasattr(self, "usage_pattern") else None)!s}, '
                f'usage={(self.usage if hasattr(self, "usage") else None)!s})')
