"""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_9 import (
    AmountDetails9,
)
from visaacceptancemergedspec.models.bill_to_2 import (
    BillTo2,
)
from visaacceptancemergedspec.models.invoice_details_4 import (
    InvoiceDetails4,
)
from visaacceptancemergedspec.models.line_item_4 import (
    LineItem4,
)
from visaacceptancemergedspec.models.ship_to_2 import (
    ShipTo2,
)
from visaacceptancemergedspec.models.shipping_details_1 import (
    ShippingDetails1,
)


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

    Attributes:
        amount_details (AmountDetails9): The model property of type AmountDetails9.
        bill_to (BillTo2): The model property of type BillTo2.
        ship_to (ShipTo2): The model property of type ShipTo2.
        line_items (List[LineItem4]): The model property of type List[LineItem4].
        invoice_details (InvoiceDetails4): The model property of type InvoiceDetails4.
        shipping_details (ShippingDetails1): The model property of type
            ShippingDetails1.
        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",
        "bill_to": "billTo",
        "ship_to": "shipTo",
        "line_items": "lineItems",
        "invoice_details": "invoiceDetails",
        "shipping_details": "shippingDetails",
    }

    _optionals = [
        "amount_details",
        "bill_to",
        "ship_to",
        "line_items",
        "invoice_details",
        "shipping_details",
    ]

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

        # 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 =\
            AmountDetails9.from_dictionary(
                dictionary.get("amountDetails"))\
                if "amountDetails" in dictionary.keys()\
                else APIHelper.SKIP
        bill_to =\
            BillTo2.from_dictionary(
                dictionary.get("billTo"))\
                if "billTo" in dictionary.keys()\
                else APIHelper.SKIP
        ship_to =\
            ShipTo2.from_dictionary(
                dictionary.get("shipTo"))\
                if "shipTo" in dictionary.keys()\
                else APIHelper.SKIP
        line_items = None
        if dictionary.get("lineItems") is not None:
            line_items = [
                LineItem4.from_dictionary(x)
                    for x in dictionary.get("lineItems")
            ]
        else:
            line_items = APIHelper.SKIP
        invoice_details =\
            InvoiceDetails4.from_dictionary(
                dictionary.get("invoiceDetails"))\
                if "invoiceDetails" in dictionary.keys()\
                else APIHelper.SKIP
        shipping_details =\
            ShippingDetails1.from_dictionary(
                dictionary.get("shippingDetails"))\
                if "shippingDetails" in dictionary.keys()\
                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(amount_details,
                   bill_to,
                   ship_to,
                   line_items,
                   invoice_details,
                   shipping_details,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _amount_details=(
            self.amount_details
            if hasattr(self, "amount_details")
            else None
        )
        _bill_to=(
            self.bill_to
            if hasattr(self, "bill_to")
            else None
        )
        _ship_to=(
            self.ship_to
            if hasattr(self, "ship_to")
            else None
        )
        _line_items=(
            self.line_items
            if hasattr(self, "line_items")
            else None
        )
        _invoice_details=(
            self.invoice_details
            if hasattr(self, "invoice_details")
            else None
        )
        _shipping_details=(
            self.shipping_details
            if hasattr(self, "shipping_details")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"amount_details={_amount_details!r}, "
            f"bill_to={_bill_to!r}, "
            f"ship_to={_ship_to!r}, "
            f"line_items={_line_items!r}, "
            f"invoice_details={_invoice_details!r}, "
            f"shipping_details={_shipping_details!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
        )
        _bill_to=(
            self.bill_to
            if hasattr(self, "bill_to")
            else None
        )
        _ship_to=(
            self.ship_to
            if hasattr(self, "ship_to")
            else None
        )
        _line_items=(
            self.line_items
            if hasattr(self, "line_items")
            else None
        )
        _invoice_details=(
            self.invoice_details
            if hasattr(self, "invoice_details")
            else None
        )
        _shipping_details=(
            self.shipping_details
            if hasattr(self, "shipping_details")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"amount_details={_amount_details!s}, "
            f"bill_to={_bill_to!s}, "
            f"ship_to={_ship_to!s}, "
            f"line_items={_line_items!s}, "
            f"invoice_details={_invoice_details!s}, "
            f"shipping_details={_shipping_details!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
