"""visaacceptancemergedspec.

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

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


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

    Attributes:
        product_code (str): Type of product. This value is used to determine the
            category that the product is in: electronic, handling, physical, service,
            or shipping. The default value is **default**.  For a payment, when you
            set this field to a value other than default or any of the values related
            to shipping and handling, below fields _quantity_, _productName_, and
            _productSKU_ are required.
        product_name (str): For PAYMENT and CAPTURE API, this field is required when
            above _productCode_ is not **default** or one of the values related to
            shipping and handling.
        product_sku (str): Identification code for the product. For Payment and
            Capture APIs, this field is required when above `productCode` is not
            **default** or one of the values related to shipping and/or handling.
        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.  This field is frequently used for Level
            II and Level III transactions.
        quantity (int): For a payment or capture, this field is required when
            _productCode_ is not **default** or one of the values related to shipping
            and handling.
        unit_price (str): Per-item price of the product. This value cannot be
            negative. You can include a decimal point (.), but you cannot include any
            other special characters. Visa Acceptance truncates the amount to the
            correct number of decimal places.
        fulfillment_type (str): The description for this field is not available.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "product_code": "productCode",
        "product_name": "productName",
        "product_sku": "productSku",
        "tax_amount": "taxAmount",
        "quantity": "quantity",
        "unit_price": "unitPrice",
        "fulfillment_type": "fulfillmentType",
    }

    _optionals = [
        "product_code",
        "product_name",
        "product_sku",
        "tax_amount",
        "quantity",
        "unit_price",
        "fulfillment_type",
    ]

    def __init__(
        self,
        product_code=APIHelper.SKIP,
        product_name=APIHelper.SKIP,
        product_sku=APIHelper.SKIP,
        tax_amount=APIHelper.SKIP,
        quantity=1,
        unit_price=APIHelper.SKIP,
        fulfillment_type=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a LineItem11 instance."""
        # Initialize members of the class
        if product_code is not APIHelper.SKIP:
            self.product_code = product_code
        if product_name is not APIHelper.SKIP:
            self.product_name = product_name
        if product_sku is not APIHelper.SKIP:
            self.product_sku = product_sku
        if tax_amount is not APIHelper.SKIP:
            self.tax_amount = tax_amount
        self.quantity = quantity
        if unit_price is not APIHelper.SKIP:
            self.unit_price = unit_price
        if fulfillment_type is not APIHelper.SKIP:
            self.fulfillment_type = fulfillment_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
        product_code =\
            dictionary.get("productCode")\
            if dictionary.get("productCode")\
                else APIHelper.SKIP
        product_name =\
            dictionary.get("productName")\
            if dictionary.get("productName")\
                else APIHelper.SKIP
        product_sku =\
            dictionary.get("productSku")\
            if dictionary.get("productSku")\
                else APIHelper.SKIP
        tax_amount =\
            dictionary.get("taxAmount")\
            if dictionary.get("taxAmount")\
                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
        fulfillment_type =\
            dictionary.get("fulfillmentType")\
            if dictionary.get("fulfillmentType")\
                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_code,
                   product_name,
                   product_sku,
                   tax_amount,
                   quantity,
                   unit_price,
                   fulfillment_type,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _product_code=(
            self.product_code
            if hasattr(self, "product_code")
            else None
        )
        _product_name=(
            self.product_name
            if hasattr(self, "product_name")
            else None
        )
        _product_sku=(
            self.product_sku
            if hasattr(self, "product_sku")
            else None
        )
        _tax_amount=(
            self.tax_amount
            if hasattr(self, "tax_amount")
            else None
        )
        _quantity=(
            self.quantity
            if hasattr(self, "quantity")
            else None
        )
        _unit_price=(
            self.unit_price
            if hasattr(self, "unit_price")
            else None
        )
        _fulfillment_type=(
            self.fulfillment_type
            if hasattr(self, "fulfillment_type")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"product_code={_product_code!r}, "
            f"product_name={_product_name!r}, "
            f"product_sku={_product_sku!r}, "
            f"tax_amount={_tax_amount!r}, "
            f"quantity={_quantity!r}, "
            f"unit_price={_unit_price!r}, "
            f"fulfillment_type={_fulfillment_type!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _product_code=(
            self.product_code
            if hasattr(self, "product_code")
            else None
        )
        _product_name=(
            self.product_name
            if hasattr(self, "product_name")
            else None
        )
        _product_sku=(
            self.product_sku
            if hasattr(self, "product_sku")
            else None
        )
        _tax_amount=(
            self.tax_amount
            if hasattr(self, "tax_amount")
            else None
        )
        _quantity=(
            self.quantity
            if hasattr(self, "quantity")
            else None
        )
        _unit_price=(
            self.unit_price
            if hasattr(self, "unit_price")
            else None
        )
        _fulfillment_type=(
            self.fulfillment_type
            if hasattr(self, "fulfillment_type")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"product_code={_product_code!s}, "
            f"product_name={_product_name!s}, "
            f"product_sku={_product_sku!s}, "
            f"tax_amount={_tax_amount!s}, "
            f"quantity={_quantity!s}, "
            f"unit_price={_unit_price!s}, "
            f"fulfillment_type={_fulfillment_type!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
