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

"""
pqapiv2

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


class ReceiptBase(object):

    """Implementation of the 'receiptBase' model.

    Base for the receipt

    Attributes:
        formatted_amount (string): Formatted monetary amount
        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.
        created_on (datetime): Time at which the object was created.
        token (string): Token representing the resource, prefixed with
            <i>user-</i>, <i>dest-</i>, <i>xfer-</i>, <i>acct-</i>,
            <i>pmnt-</i>, or <i>docu-</i>.
        status (TransferStatusTypesEnum): Current status of a transfer

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "amount": 'amount',
        "currency": 'currency',
        "formatted_amount": 'formattedAmount',
        "source_token": 'sourceToken',
        "destination_token": 'destinationToken',
        "created_on": 'createdOn',
        "token": 'token',
        "status": 'status'
    }

    def __init__(self,
                 amount=None,
                 currency=None,
                 formatted_amount=None,
                 source_token=None,
                 destination_token=None,
                 created_on=None,
                 token=None,
                 status=None):
        """Constructor for the ReceiptBase class"""

        # Initialize members of the class
        self.formatted_amount = formatted_amount
        self.amount = amount
        self.currency = currency
        self.source_token = source_token
        self.destination_token = destination_token
        self.created_on = APIHelper.RFC3339DateTime(created_on) if created_on else None
        self.token = token
        self.status = status

    @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')
        formatted_amount = dictionary.get('formattedAmount')
        source_token = dictionary.get('sourceToken')
        destination_token = dictionary.get('destinationToken')
        created_on = APIHelper.RFC3339DateTime.from_value(dictionary.get("createdOn")).datetime if dictionary.get("createdOn") else None
        token = dictionary.get('token')
        status = dictionary.get('status')

        # Return an object of this model
        return cls(amount,
                   currency,
                   formatted_amount,
                   source_token,
                   destination_token,
                   created_on,
                   token,
                   status)
