"""visaacceptancemergedspec.

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

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


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

    Attributes:
        payment_method (str): This value is a 2-digit code indicating the payment
            method. Use Payment Method Code value that applies to the tranasction. -
            10 (One-time payment) - 21, 22, 23, 24  (Bonus(one-time)payment) - 61
            (Installment payment) - 31, 32, 33, 34  (Integrated (Bonus +
            Installment)payment) - 80 (Revolving payment)
        terminal_id (str): Unique Japan Credit Card Association (JCCA) terminal
            identifier.  The difference between this field and the
            `pointOfSaleInformation.terminalID` field is that you can define
            `pointOfSaleInformation.terminalID`, but
            `processingInformation.japanPaymentOptions.terminalId` is defined by the
            JCCA and is used only in Japan.  This field is supported only on Visa
            Acceptance through VisaNet and JCN Gateway.  Optional field.
        business_name (str): Business name in Japanese characters. This field is
            supported only on JCN Gateway and for the Sumitomo Mitsui Card Co.
            acquirer on Visa Acceptance through VisaNet.
        business_name_katakana (str): Business name in Katakana characters. This
            field is supported only on JCN Gateway and for the Sumitomo Mitsui Card
            Co. acquirer on Visa Acceptance through VisaNet.
        business_name_english (str): Business name in English characters. This field
            is supported only on JCN Gateway and for the Sumitomo Mitsui Card Co.
            acquirer on Visa Acceptance through VisaNet.
        bonuses (List[Bonuse]): An array of objects, each of which contains a bonus
            month and bonus amount.  Length of bonuses array is equal to the number
            of bonuses.  Max length = 6.  In case of bonus month and amount not
            specified, null objects to be returned in the array. Example: bonuses : [
            {"month": "1","amount": "200"}, {"month": "3","amount": "2500"}, null]
        first_billing_month (str): Billing month in MM format.
        number_of_installments (str): Number of Installments.
        pre_approval_type (str): This will contain the details of the kind of
            transaction that has been processe. Used only for Japan. Possible Values:
            - 0 = Normal (authorization with amount and clearing/settlement; data
            capture or paper draft) - 1 = Negative card authorization
            (authorization-only with 0 or 1 amount) - 2 = Reservation of
            authorization (authorization-only with amount) - 3 = Cancel transaction -
            4 = Merchant-initiated reversal/refund transactions - 5 = Cancel
            reservation of authorization - 6 = Post authorization
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "payment_method": "paymentMethod",
        "terminal_id": "terminalId",
        "business_name": "businessName",
        "business_name_katakana": "businessNameKatakana",
        "business_name_english": "businessNameEnglish",
        "bonuses": "bonuses",
        "first_billing_month": "firstBillingMonth",
        "number_of_installments": "numberOfInstallments",
        "pre_approval_type": "preApprovalType",
    }

    _optionals = [
        "payment_method",
        "terminal_id",
        "business_name",
        "business_name_katakana",
        "business_name_english",
        "bonuses",
        "first_billing_month",
        "number_of_installments",
        "pre_approval_type",
    ]

    def __init__(
        self,
        payment_method=APIHelper.SKIP,
        terminal_id=APIHelper.SKIP,
        business_name=APIHelper.SKIP,
        business_name_katakana=APIHelper.SKIP,
        business_name_english=APIHelper.SKIP,
        bonuses=APIHelper.SKIP,
        first_billing_month=APIHelper.SKIP,
        number_of_installments=APIHelper.SKIP,
        pre_approval_type=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a JapanPaymentOptions2 instance."""
        # Initialize members of the class
        if payment_method is not APIHelper.SKIP:
            self.payment_method = payment_method
        if terminal_id is not APIHelper.SKIP:
            self.terminal_id = terminal_id
        if business_name is not APIHelper.SKIP:
            self.business_name = business_name
        if business_name_katakana is not APIHelper.SKIP:
            self.business_name_katakana = business_name_katakana
        if business_name_english is not APIHelper.SKIP:
            self.business_name_english = business_name_english
        if bonuses is not APIHelper.SKIP:
            self.bonuses = bonuses
        if first_billing_month is not APIHelper.SKIP:
            self.first_billing_month = first_billing_month
        if number_of_installments is not APIHelper.SKIP:
            self.number_of_installments = number_of_installments
        if pre_approval_type is not APIHelper.SKIP:
            self.pre_approval_type = pre_approval_type

        # 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
        payment_method =\
            dictionary.get("paymentMethod")\
            if dictionary.get("paymentMethod")\
                else APIHelper.SKIP
        terminal_id =\
            dictionary.get("terminalId")\
            if dictionary.get("terminalId")\
                else APIHelper.SKIP
        business_name =\
            dictionary.get("businessName")\
            if dictionary.get("businessName")\
                else APIHelper.SKIP
        business_name_katakana =\
            dictionary.get("businessNameKatakana")\
            if dictionary.get("businessNameKatakana")\
                else APIHelper.SKIP
        business_name_english =\
            dictionary.get("businessNameEnglish")\
            if dictionary.get("businessNameEnglish")\
                else APIHelper.SKIP
        bonuses = None
        if dictionary.get("bonuses") is not None:
            bonuses = [
                Bonuse.from_dictionary(x)
                    for x in dictionary.get("bonuses")
            ]
        else:
            bonuses = APIHelper.SKIP
        first_billing_month =\
            dictionary.get("firstBillingMonth")\
            if dictionary.get("firstBillingMonth")\
                else APIHelper.SKIP
        number_of_installments =\
            dictionary.get("numberOfInstallments")\
            if dictionary.get("numberOfInstallments")\
                else APIHelper.SKIP
        pre_approval_type =\
            dictionary.get("preApprovalType")\
            if dictionary.get("preApprovalType")\
                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(payment_method,
                   terminal_id,
                   business_name,
                   business_name_katakana,
                   business_name_english,
                   bonuses,
                   first_billing_month,
                   number_of_installments,
                   pre_approval_type,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _payment_method=(
            self.payment_method
            if hasattr(self, "payment_method")
            else None
        )
        _terminal_id=(
            self.terminal_id
            if hasattr(self, "terminal_id")
            else None
        )
        _business_name=(
            self.business_name
            if hasattr(self, "business_name")
            else None
        )
        _business_name_katakana=(
            self.business_name_katakana
            if hasattr(self, "business_name_katakana")
            else None
        )
        _business_name_english=(
            self.business_name_english
            if hasattr(self, "business_name_english")
            else None
        )
        _bonuses=(
            self.bonuses
            if hasattr(self, "bonuses")
            else None
        )
        _first_billing_month=(
            self.first_billing_month
            if hasattr(self, "first_billing_month")
            else None
        )
        _number_of_installments=(
            self.number_of_installments
            if hasattr(self, "number_of_installments")
            else None
        )
        _pre_approval_type=(
            self.pre_approval_type
            if hasattr(self, "pre_approval_type")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"payment_method={_payment_method!r}, "
            f"terminal_id={_terminal_id!r}, "
            f"business_name={_business_name!r}, "
            f"business_name_katakana={_business_name_katakana!r}, "
            f"business_name_english={_business_name_english!r}, "
            f"bonuses={_bonuses!r}, "
            f"first_billing_month={_first_billing_month!r}, "
            f"number_of_installments={_number_of_installments!r}, "
            f"pre_approval_type={_pre_approval_type!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _payment_method=(
            self.payment_method
            if hasattr(self, "payment_method")
            else None
        )
        _terminal_id=(
            self.terminal_id
            if hasattr(self, "terminal_id")
            else None
        )
        _business_name=(
            self.business_name
            if hasattr(self, "business_name")
            else None
        )
        _business_name_katakana=(
            self.business_name_katakana
            if hasattr(self, "business_name_katakana")
            else None
        )
        _business_name_english=(
            self.business_name_english
            if hasattr(self, "business_name_english")
            else None
        )
        _bonuses=(
            self.bonuses
            if hasattr(self, "bonuses")
            else None
        )
        _first_billing_month=(
            self.first_billing_month
            if hasattr(self, "first_billing_month")
            else None
        )
        _number_of_installments=(
            self.number_of_installments
            if hasattr(self, "number_of_installments")
            else None
        )
        _pre_approval_type=(
            self.pre_approval_type
            if hasattr(self, "pre_approval_type")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"payment_method={_payment_method!s}, "
            f"terminal_id={_terminal_id!s}, "
            f"business_name={_business_name!s}, "
            f"business_name_katakana={_business_name_katakana!s}, "
            f"business_name_english={_business_name_english!s}, "
            f"bonuses={_bonuses!s}, "
            f"first_billing_month={_first_billing_month!s}, "
            f"number_of_installments={_number_of_installments!s}, "
            f"pre_approval_type={_pre_approval_type!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
