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

import earthport-rest-api-client.models.monetary_value
import earthport-rest-api-client.models.fx_rate
import earthport-rest-api-client.models.fx_ticket_id

class FXExecutedRate(object):

    """Implementation of the 'FXExecutedRate' model.

    Holds details of an executed FX conversion that has occured as part of a
    financial transaction. The FX that occured was from the sellCurrency to
    the buyCurrency at a particular rate. The rate may have been requested via
    an FX Quote (fxTicketID). An FX conversion fee may have been applied to
    certain transaction types.

    Attributes:
        fx_fee_amount (MonetaryValue): Represents a monetary value containing
            a decimal amount value along with a currency code. The currency
            code is a three letter ISO 4217 code. E.g. GBP for British
            sterling pounds.
        fx_rate (FXRate): Represents an FX rate between two currencies, the
            rate is restricted to 6 decimal places. The currency code is a
            three letter ISO 4217 code. E.g. GBP for British sterling pounds.
        fx_ticket_id (FXTicketID): The unique FX Ticket ID generated by the
            Earthport payment system.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "fx_rate":'fxRate',
        "fx_fee_amount":'fxFeeAmount',
        "fx_ticket_id":'fxTicketID'
    }

    def __init__(self,
                 fx_rate=None,
                 fx_fee_amount=None,
                 fx_ticket_id=None):
        """Constructor for the FXExecutedRate class"""

        # Initialize members of the class
        self.fx_fee_amount = fx_fee_amount
        self.fx_rate = fx_rate
        self.fx_ticket_id = fx_ticket_id


    @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
        fx_rate = earthport-rest-api-client.models.fx_rate.FXRate.from_dictionary(dictionary.get('fxRate')) if dictionary.get('fxRate') else None
        fx_fee_amount = earthport-rest-api-client.models.monetary_value.MonetaryValue.from_dictionary(dictionary.get('fxFeeAmount')) if dictionary.get('fxFeeAmount') else None
        fx_ticket_id = earthport-rest-api-client.models.fx_ticket_id.FXTicketID.from_dictionary(dictionary.get('fxTicketID')) if dictionary.get('fxTicketID') else None

        # Return an object of this model
        return cls(fx_rate,
                   fx_fee_amount,
                   fx_ticket_id)


