"""visaacceptancemergedspec.

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

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


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

    Attributes:
        quantity (int): Number of units for this order. Must be a non-negative
            integer.  The default is `1`. For an authorization or capture transaction
            (`processingOptions.capture` is set to `true` or `false`), this field is
            required when `orderInformation.lineItems[].productCode` is not `default`
            or one of the other values related to shipping and/or handling.  #### Tax
            Calculation Optional field for U.S., Canadian, international tax, and
            value added taxes.
        unit_price (str): Per-item price of the product. This value for this field
            cannot be negative.  You must include either this field or the
            request-level field `orderInformation.amountDetails.totalAmount` in your
            request.  You can include a decimal point (.), but you cannot include any
            other special characters. The value is truncated to the correct number of
            decimal places.  #### DCC with a Third-Party Provider Set this field to
            the converted amount that was returned by the DCC provider. You must
            include either the 1st line item in the order and this field, or the
            request-level field `orderInformation.amountDetails.totalAmount` in your
            request.  #### Tax Calculation Required field for U.S., Canadian,
            international and value added taxes.  #### Zero Amount Authorizations If
            your processor supports zero amount authorizations, you can set this
            field to 0 for the authorization to check if the card is lost or stolen.
            #### Maximum Field Lengths For GPN and JCN Gateway: Decimal (10) All
            other processors: Decimal (15)
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "quantity": "quantity",
        "unit_price": "unitPrice",
    }

    _optionals = [
        "quantity",
        "unit_price",
    ]

    def __init__(
        self,
        quantity=1,
        unit_price=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a LineItem1 instance."""
        # Initialize members of the class
        self.quantity = quantity
        if unit_price is not APIHelper.SKIP:
            self.unit_price = unit_price

        # 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
        quantity =\
            dictionary.get("quantity")\
            if dictionary.get("quantity")\
                else 1
        unit_price =\
            dictionary.get("unitPrice")\
            if dictionary.get("unitPrice")\
                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(quantity,
                   unit_price,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _quantity=(
            self.quantity
            if hasattr(self, "quantity")
            else None
        )
        _unit_price=(
            self.unit_price
            if hasattr(self, "unit_price")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"quantity={_quantity!r}, "
            f"unit_price={_unit_price!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _quantity=(
            self.quantity
            if hasattr(self, "quantity")
            else None
        )
        _unit_price=(
            self.unit_price
            if hasattr(self, "unit_price")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"quantity={_quantity!s}, "
            f"unit_price={_unit_price!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
