"""visaacceptancemergedspec.

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

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


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

    List of the line items from the order, which are included in an invoice.

    Attributes:
        product_sku (str): Product identifier code. Also known as the Stock Keeping
            Unit (SKU) code for the product.  For an authorization or capture
            transaction (`processingOptions.capture` is set to `true` or `false`),
            this field is required when `orderInformation.lineItems[].productCode` is
            not set to **default** or one of the other values that are related to
            shipping and/or handling.  #### Tax Calculation Optional field for U.S.
            and Canadian taxes. Not applicable to international and value added
            taxes. 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 values related to shipping and/or handling.
        product_name (str): For an authorization or capture transaction
            (`processingOptions.capture` is `true` or `false`), this field is
            required when `orderInformation.lineItems[].productCode` is not `default`
            or one of the other values that are related to shipping and/or handling.
            #### Tax Calculation Optional field for U.S., Canadian, international
            tax, and value added taxes.
        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)
        discount_amount (str): Discount applied to the item.
        discount_rate (str): Rate the item is discounted. Maximum of 2 decimal
            places.  Example 5.25 (=5.25%)
        tax_amount (str): Total tax to apply to the product. This value cannot be
            negative. The tax amount and the offer amount must be in the same
            currency. The tax amount field is additive.  The following example uses a
            two-exponent currency such as USD:   1. You include each line item in
            your request.  ..- 1st line item has amount=10.00, quantity=1, and
            taxAmount=0.80  ..- 2nd line item has amount=20.00, quantity=1, and
            taxAmount=1.60  2. The total amount authorized will be 32.40, not 30.00
            with 2.40 of tax included.  Optional field.  #### Airlines processing Tax
            portion of the order amount. This value cannot exceed 99999999999999
            (fourteen 9s). Format: English characters only. Optional request field
            for a line item.  #### Tax Calculation Optional field for U.S., Canadian,
            international tax, and value added taxes.  Note if you send this field in
            your tax request, the value in the field will override the tax engine
        tax_rate (str): Tax rate applied to the item.  **Visa**: Valid range is 0.01
            to 0.99 (1% to 99%, with only whole percentage values accepted; values
            with additional decimal places will be truncated).  **Mastercard**: Valid
            range is 0.00001 to 0.99999 (0.001% to 99.999%).
        total_amount (str): Total amount for the item. Normally calculated as the
            unit price times quantity.  When
            `orderInformation.lineItems[].productCode` is "gift_card", this is the
            purchase amount total for prepaid gift cards in major units.  Example:
            123.45 USD = 123
        product_code (str): Type of product. The value for this field is used to
            identify the product category (electronic, handling, physical, service,
            or shipping). The default value is `default`.  If you are performing an
            authorization transaction (`processingOptions.capture` is set to
            `false`), and you set this field to a value other than `default` or one
            of the values related to shipping and/or handling, then
            `orderInformation.lineItems[].quantity`,
            `orderInformation.lineItems[].productName`, and
            `orderInformation.lineItems[].productSku` fields are required.  Optional
            field.  #### Tax Calculation Optional field for U.S., Canadian,
            international tax, and value added taxes.  The Product Codes for the tax
            service are located in the Visa Acceptance Tax Codes guide. Contact
            Customer Support to request the guide. If you don’t send a tax service
            Product Code in your tax request, product-based rules or exemptions will
            not be applied and the transaction will default to fully taxable in the
            locations where you’ve indicated you need to collect tax [by way of
            nexus, no nexus, or seller registration number fields].
        product_description (str): Brief description of item.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "product_sku": "productSku",
        "product_name": "productName",
        "quantity": "quantity",
        "unit_price": "unitPrice",
        "discount_amount": "discountAmount",
        "discount_rate": "discountRate",
        "tax_amount": "taxAmount",
        "tax_rate": "taxRate",
        "total_amount": "totalAmount",
        "product_code": "productCode",
        "product_description": "productDescription",
    }

    _optionals = [
        "product_sku",
        "product_name",
        "quantity",
        "unit_price",
        "discount_amount",
        "discount_rate",
        "tax_amount",
        "tax_rate",
        "total_amount",
        "product_code",
        "product_description",
    ]

    def __init__(
        self,
        product_sku=APIHelper.SKIP,
        product_name=APIHelper.SKIP,
        quantity=1,
        unit_price=APIHelper.SKIP,
        discount_amount=APIHelper.SKIP,
        discount_rate=APIHelper.SKIP,
        tax_amount=APIHelper.SKIP,
        tax_rate=APIHelper.SKIP,
        total_amount=APIHelper.SKIP,
        product_code=APIHelper.SKIP,
        product_description=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a LineItem7 instance."""
        # Initialize members of the class
        if product_sku is not APIHelper.SKIP:
            self.product_sku = product_sku
        if product_name is not APIHelper.SKIP:
            self.product_name = product_name
        self.quantity = quantity
        if unit_price is not APIHelper.SKIP:
            self.unit_price = unit_price
        if discount_amount is not APIHelper.SKIP:
            self.discount_amount = discount_amount
        if discount_rate is not APIHelper.SKIP:
            self.discount_rate = discount_rate
        if tax_amount is not APIHelper.SKIP:
            self.tax_amount = tax_amount
        if tax_rate is not APIHelper.SKIP:
            self.tax_rate = tax_rate
        if total_amount is not APIHelper.SKIP:
            self.total_amount = total_amount
        if product_code is not APIHelper.SKIP:
            self.product_code = product_code
        if product_description is not APIHelper.SKIP:
            self.product_description = product_description

        # 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
        product_sku =\
            dictionary.get("productSku")\
            if dictionary.get("productSku")\
                else APIHelper.SKIP
        product_name =\
            dictionary.get("productName")\
            if dictionary.get("productName")\
                else APIHelper.SKIP
        quantity =\
            dictionary.get("quantity")\
            if dictionary.get("quantity")\
                else 1
        unit_price =\
            dictionary.get("unitPrice")\
            if dictionary.get("unitPrice")\
                else APIHelper.SKIP
        discount_amount =\
            dictionary.get("discountAmount")\
            if dictionary.get("discountAmount")\
                else APIHelper.SKIP
        discount_rate =\
            dictionary.get("discountRate")\
            if dictionary.get("discountRate")\
                else APIHelper.SKIP
        tax_amount =\
            dictionary.get("taxAmount")\
            if dictionary.get("taxAmount")\
                else APIHelper.SKIP
        tax_rate =\
            dictionary.get("taxRate")\
            if dictionary.get("taxRate")\
                else APIHelper.SKIP
        total_amount =\
            dictionary.get("totalAmount")\
            if dictionary.get("totalAmount")\
                else APIHelper.SKIP
        product_code =\
            dictionary.get("productCode")\
            if dictionary.get("productCode")\
                else APIHelper.SKIP
        product_description =\
            dictionary.get("productDescription")\
            if dictionary.get("productDescription")\
                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(product_sku,
                   product_name,
                   quantity,
                   unit_price,
                   discount_amount,
                   discount_rate,
                   tax_amount,
                   tax_rate,
                   total_amount,
                   product_code,
                   product_description,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _product_sku=(
            self.product_sku
            if hasattr(self, "product_sku")
            else None
        )
        _product_name=(
            self.product_name
            if hasattr(self, "product_name")
            else None
        )
        _quantity=(
            self.quantity
            if hasattr(self, "quantity")
            else None
        )
        _unit_price=(
            self.unit_price
            if hasattr(self, "unit_price")
            else None
        )
        _discount_amount=(
            self.discount_amount
            if hasattr(self, "discount_amount")
            else None
        )
        _discount_rate=(
            self.discount_rate
            if hasattr(self, "discount_rate")
            else None
        )
        _tax_amount=(
            self.tax_amount
            if hasattr(self, "tax_amount")
            else None
        )
        _tax_rate=(
            self.tax_rate
            if hasattr(self, "tax_rate")
            else None
        )
        _total_amount=(
            self.total_amount
            if hasattr(self, "total_amount")
            else None
        )
        _product_code=(
            self.product_code
            if hasattr(self, "product_code")
            else None
        )
        _product_description=(
            self.product_description
            if hasattr(self, "product_description")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"product_sku={_product_sku!r}, "
            f"product_name={_product_name!r}, "
            f"quantity={_quantity!r}, "
            f"unit_price={_unit_price!r}, "
            f"discount_amount={_discount_amount!r}, "
            f"discount_rate={_discount_rate!r}, "
            f"tax_amount={_tax_amount!r}, "
            f"tax_rate={_tax_rate!r}, "
            f"total_amount={_total_amount!r}, "
            f"product_code={_product_code!r}, "
            f"product_description={_product_description!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _product_sku=(
            self.product_sku
            if hasattr(self, "product_sku")
            else None
        )
        _product_name=(
            self.product_name
            if hasattr(self, "product_name")
            else None
        )
        _quantity=(
            self.quantity
            if hasattr(self, "quantity")
            else None
        )
        _unit_price=(
            self.unit_price
            if hasattr(self, "unit_price")
            else None
        )
        _discount_amount=(
            self.discount_amount
            if hasattr(self, "discount_amount")
            else None
        )
        _discount_rate=(
            self.discount_rate
            if hasattr(self, "discount_rate")
            else None
        )
        _tax_amount=(
            self.tax_amount
            if hasattr(self, "tax_amount")
            else None
        )
        _tax_rate=(
            self.tax_rate
            if hasattr(self, "tax_rate")
            else None
        )
        _total_amount=(
            self.total_amount
            if hasattr(self, "total_amount")
            else None
        )
        _product_code=(
            self.product_code
            if hasattr(self, "product_code")
            else None
        )
        _product_description=(
            self.product_description
            if hasattr(self, "product_description")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"product_sku={_product_sku!s}, "
            f"product_name={_product_name!s}, "
            f"quantity={_quantity!s}, "
            f"unit_price={_unit_price!s}, "
            f"discount_amount={_discount_amount!s}, "
            f"discount_rate={_discount_rate!s}, "
            f"tax_amount={_tax_amount!s}, "
            f"tax_rate={_tax_rate!s}, "
            f"total_amount={_total_amount!s}, "
            f"product_code={_product_code!s}, "
            f"product_description={_product_description!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
