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

"""
pqapiv2

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


class PaymentRequest(object):

    """Implementation of the 'payment-Request' model.

    Payment request

    Attributes:
        amount (float): Amount of the transfer in the specified currency.
        currency (CurrencyTypesEnum): Currency code type for the object
        source_token (string): Unique identifier representing the source of
            funds.
        destination_token (string): Unique identifier representing the
            destination of funds.
        notes (string): Optional comments visible to the user.
        memo (string): Optional internal memo not visible to the user.
        purpose (PaymentPurposeTypesEnum): Used to identify the purpose of a
            payment and impacts reporting and calculated taxable earnings (if
            utilizing tax services)
        client_payment_id (string): Unique value provided by the client for
            the payment.
        auto_accept_quote (bool): Determines whether the quote is
            automatically accepted or if a POST utilizing the token for the
            quote is required.
        not_before (datetime): Transfer is scheduled and will not process
            before this time.
        not_after (datetime): Transfer expires if not completed prior to this
            time.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "amount": 'amount',
        "currency": 'currency',
        "source_token": 'sourceToken',
        "destination_token": 'destinationToken',
        "notes": 'notes',
        "memo": 'memo',
        "purpose": 'purpose',
        "client_payment_id": 'clientPaymentId',
        "auto_accept_quote": 'autoAcceptQuote',
        "not_before": 'notBefore',
        "not_after": 'notAfter'
    }

    def __init__(self,
                 amount=None,
                 currency=None,
                 source_token=None,
                 destination_token=None,
                 notes=None,
                 memo=None,
                 purpose=None,
                 client_payment_id=None,
                 auto_accept_quote=None,
                 not_before=None,
                 not_after=None):
        """Constructor for the PaymentRequest class"""

        # Initialize members of the class
        self.amount = amount
        self.currency = currency
        self.source_token = source_token
        self.destination_token = destination_token
        self.notes = notes
        self.memo = memo
        self.purpose = purpose
        self.client_payment_id = client_payment_id
        self.auto_accept_quote = auto_accept_quote
        self.not_before = APIHelper.RFC3339DateTime(not_before) if not_before else None
        self.not_after = APIHelper.RFC3339DateTime(not_after) if not_after else None

    @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 dictionary is None:
            return None

        # Extract variables from the dictionary
        amount = dictionary.get('amount')
        currency = dictionary.get('currency')
        source_token = dictionary.get('sourceToken')
        destination_token = dictionary.get('destinationToken')
        notes = dictionary.get('notes')
        memo = dictionary.get('memo')
        purpose = dictionary.get('purpose')
        client_payment_id = dictionary.get('clientPaymentId')
        auto_accept_quote = dictionary.get('autoAcceptQuote')
        not_before = APIHelper.RFC3339DateTime.from_value(dictionary.get("notBefore")).datetime if dictionary.get("notBefore") else None
        not_after = APIHelper.RFC3339DateTime.from_value(dictionary.get("notAfter")).datetime if dictionary.get("notAfter") else None

        # Return an object of this model
        return cls(amount,
                   currency,
                   source_token,
                   destination_token,
                   notes,
                   memo,
                   purpose,
                   client_payment_id,
                   auto_accept_quote,
                   not_before,
                   not_after)
