"""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.amount_details_6 import (
    AmountDetails6,
)
from visaacceptancemergedspec.models.line_item_1 import (
    LineItem1,
)


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

    Attributes:
        amount_details (AmountDetails6): The model property of type AmountDetails6.
        line_items (List[LineItem1]): The model property of type List[LineItem1].
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "amount_details": "amountDetails",
        "line_items": "lineItems",
    }

    _optionals = [
        "amount_details",
        "line_items",
    ]

    def __init__(
        self,
        amount_details=APIHelper.SKIP,
        line_items=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a OrderInformation4 instance."""
        # Initialize members of the class
        if amount_details is not APIHelper.SKIP:
            self.amount_details = amount_details
        if line_items is not APIHelper.SKIP:
            self.line_items = line_items

        # 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
        amount_details =\
            AmountDetails6.from_dictionary(
                dictionary.get("amountDetails"))\
                if "amountDetails" in dictionary.keys()\
                else APIHelper.SKIP
        line_items = None
        if dictionary.get("lineItems") is not None:
            line_items = [
                LineItem1.from_dictionary(x)
                    for x in dictionary.get("lineItems")
            ]
        else:
            line_items = 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(amount_details,
                   line_items,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _amount_details=(
            self.amount_details
            if hasattr(self, "amount_details")
            else None
        )
        _line_items=(
            self.line_items
            if hasattr(self, "line_items")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"amount_details={_amount_details!r}, "
            f"line_items={_line_items!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _amount_details=(
            self.amount_details
            if hasattr(self, "amount_details")
            else None
        )
        _line_items=(
            self.line_items
            if hasattr(self, "line_items")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"amount_details={_amount_details!s}, "
            f"line_items={_line_items!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
