"""visaacceptancemergedspec.

This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
"""

# ruff: noqa: E501
from visaacceptancemergedspec.api_helper import (
    APIHelper,
)


class MerchantInitiatedTransactionObject(object):
    """Implementation of the 'merchantInitiatedTransactionObject' model.

    Attributes:
        reason (str): Reason for the merchant-initiated transaction or incremental
            authorization. Possible values: - `1`: Resubmission - `2`: Delayed charge
            - `3`: Reauthorization for split shipment - `4`: No show - `5`: Account
            top up This field is required only for the five kinds of transactions in
            the preceding list. This field is supported only for merchant-initiated
            transactions and incremental authorizations.  #### Visa Acceptance
            through VisaNet The value for this field corresponds to the following
            data in the TC 33 capture file5: - Record: CP01 TCR0 - Position: 160-163
            - Field: Message Reason Code
        previous_transaction_id (str): Network transaction identifier that was
            returned in the payment response field
            _processorInformation.transactionID_ in the reply message for either the
            original merchant-initiated payment in the series or the previous
            merchant-initiated payment in the series.  If the current payment request
            includes a token instead of an account number, the following time limits
            apply for the value of this field: - For a **resubmission**, the
            transaction ID must be less than 14 days old. - For a **delayed charge**
            or **reauthorization**, the transaction ID must be less than 30 days old.
            **NOTE**: The value for this field does not correspond to any data in the
            TC 33 capture file5. This field is supported only for Visa transactions
            on Visa Acceptance through VisaNet.
        original_authorized_amount (str): Amount of the original authorization.  This
            field is supported only for Apple Pay, Google Pay, and Samsung Pay
            transactions with Discover on FDC Nashville Global and Chase Paymentech.
        agreement_id (str): This field contains the predetermined agrement id with
            the merchant
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "reason": "reason",
        "previous_transaction_id": "previousTransactionId",
        "original_authorized_amount": "originalAuthorizedAmount",
        "agreement_id": "agreementId",
    }

    _optionals = [
        "reason",
        "previous_transaction_id",
        "original_authorized_amount",
        "agreement_id",
    ]

    def __init__(
        self,
        reason=APIHelper.SKIP,
        previous_transaction_id=APIHelper.SKIP,
        original_authorized_amount=APIHelper.SKIP,
        agreement_id=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a MerchantInitiatedTransactionObject instance."""
        # Initialize members of the class
        if reason is not APIHelper.SKIP:
            self.reason = reason
        if previous_transaction_id is not APIHelper.SKIP:
            self.previous_transaction_id = previous_transaction_id
        if original_authorized_amount is not APIHelper.SKIP:
            self.original_authorized_amount = original_authorized_amount
        if agreement_id is not APIHelper.SKIP:
            self.agreement_id = agreement_id

        # Add additional model properties to the instance
        if additional_properties is None:
            additional_properties = {}
        self.additional_properties = additional_properties

    @classmethod
    def from_dictionary(cls,
                        dictionary):
        """Create 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
        reason =\
            dictionary.get("reason")\
            if dictionary.get("reason")\
                else APIHelper.SKIP
        previous_transaction_id =\
            dictionary.get("previousTransactionId")\
            if dictionary.get("previousTransactionId")\
                else APIHelper.SKIP
        original_authorized_amount =\
            dictionary.get("originalAuthorizedAmount")\
            if dictionary.get("originalAuthorizedAmount")\
                else APIHelper.SKIP
        agreement_id =\
            dictionary.get("agreementId")\
            if dictionary.get("agreementId")\
                else APIHelper.SKIP

        additional_properties = APIHelper.get_additional_properties(
            dictionary={k: v for k, v in dictionary.items()
                        if k not in cls._names.values()},
            unboxing_function=lambda value: value)

        # Return an object of this model
        return cls(reason,
                   previous_transaction_id,
                   original_authorized_amount,
                   agreement_id,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _reason=(
            self.reason
            if hasattr(self, "reason")
            else None
        )
        _previous_transaction_id=(
            self.previous_transaction_id
            if hasattr(self, "previous_transaction_id")
            else None
        )
        _original_authorized_amount=(
            self.original_authorized_amount
            if hasattr(self, "original_authorized_amount")
            else None
        )
        _agreement_id=(
            self.agreement_id
            if hasattr(self, "agreement_id")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"reason={_reason!r}, "
            f"previous_transaction_id={_previous_transaction_id!r}, "
            f"original_authorized_amount={_original_authorized_amount!r}, "
            f"agreement_id={_agreement_id!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _reason=(
            self.reason
            if hasattr(self, "reason")
            else None
        )
        _previous_transaction_id=(
            self.previous_transaction_id
            if hasattr(self, "previous_transaction_id")
            else None
        )
        _original_authorized_amount=(
            self.original_authorized_amount
            if hasattr(self, "original_authorized_amount")
            else None
        )
        _agreement_id=(
            self.agreement_id
            if hasattr(self, "agreement_id")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"reason={_reason!s}, "
            f"previous_transaction_id={_previous_transaction_id!s}, "
            f"original_authorized_amount={_original_authorized_amount!s}, "
            f"agreement_id={_agreement_id!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
