# -*- 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.subscription_amount_with_breakdown import SubscriptionAmountWithBreakdown
from paypalserversdk.models.subscription_payer_name import SubscriptionPayerName


class SubscriptionTransactionDetails(object):

    """Implementation of the 'Subscription Transaction Details' model.

    The transaction details.

    Attributes:
        status (CaptureStatus): The status of the captured payment.
        id (str): The PayPal-generated transaction ID.
        amount_with_breakdown (SubscriptionAmountWithBreakdown): The breakdown
            details for the amount. Includes the gross, tax, fee, and shipping
            amounts.
        payer_name (SubscriptionPayerName): The name of the party.
        payer_email (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.
        time (str): The date and time, in [Internet date and time
            format](https://tools.ietf.org/html/rfc3339#section-5.6). Seconds
            are required while fractional seconds are optional. Note: The
            regular expression provides guidance but does not reject all
            invalid dates.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "id": 'id',
        "amount_with_breakdown": 'amount_with_breakdown',
        "time": 'time',
        "status": 'status',
        "payer_name": 'payer_name',
        "payer_email": 'payer_email'
    }

    _optionals = [
        'status',
        'payer_name',
        'payer_email',
    ]

    def __init__(self,
                 id=None,
                 amount_with_breakdown=None,
                 time=None,
                 status=APIHelper.SKIP,
                 payer_name=APIHelper.SKIP,
                 payer_email=APIHelper.SKIP):
        """Constructor for the SubscriptionTransactionDetails class"""

        # Initialize members of the class
        if status is not APIHelper.SKIP:
            self.status = status 
        self.id = id 
        self.amount_with_breakdown = amount_with_breakdown 
        if payer_name is not APIHelper.SKIP:
            self.payer_name = payer_name 
        if payer_email is not APIHelper.SKIP:
            self.payer_email = payer_email 
        self.time = time 

    @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
        id = dictionary.get("id") if dictionary.get("id") else None
        amount_with_breakdown = SubscriptionAmountWithBreakdown.from_dictionary(dictionary.get('amount_with_breakdown')) if dictionary.get('amount_with_breakdown') else None
        time = dictionary.get("time") if dictionary.get("time") else None
        status = dictionary.get("status") if dictionary.get("status") else APIHelper.SKIP
        payer_name = SubscriptionPayerName.from_dictionary(dictionary.get('payer_name')) if 'payer_name' in dictionary.keys() else APIHelper.SKIP
        payer_email = dictionary.get("payer_email") if dictionary.get("payer_email") else APIHelper.SKIP
        # Return an object of this model
        return cls(id,
                   amount_with_breakdown,
                   time,
                   status,
                   payer_name,
                   payer_email)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'status={(self.status if hasattr(self, "status") else None)!r}, '
                f'id={self.id!r}, '
                f'amount_with_breakdown={self.amount_with_breakdown!r}, '
                f'payer_name={(self.payer_name if hasattr(self, "payer_name") else None)!r}, '
                f'payer_email={(self.payer_email if hasattr(self, "payer_email") else None)!r}, '
                f'time={self.time!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'status={(self.status if hasattr(self, "status") else None)!s}, '
                f'id={self.id!s}, '
                f'amount_with_breakdown={self.amount_with_breakdown!s}, '
                f'payer_name={(self.payer_name if hasattr(self, "payer_name") else None)!s}, '
                f'payer_email={(self.payer_email if hasattr(self, "payer_email") else None)!s}, '
                f'time={self.time!s})')
