"""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 import (
    AmountDetails,
)
from visaacceptancemergedspec.models.bill_to import (
    BillTo,
)
from visaacceptancemergedspec.models.invoice_details import (
    InvoiceDetails,
)
from visaacceptancemergedspec.models.line_item import (
    LineItem,
)
from visaacceptancemergedspec.models.ship_to import (
    ShipTo,
)
from visaacceptancemergedspec.models.shipping_details_2 import (
    ShippingDetails2,
)


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

    Attributes:
        amount_details (AmountDetails): The model property of type AmountDetails.
        bill_to (BillTo): The model property of type BillTo.
        ship_to (ShipTo): The model property of type ShipTo.
        line_items (List[LineItem]): The model property of type List[LineItem].
        invoice_details (InvoiceDetails): The model property of type InvoiceDetails.
        shipping_details (ShippingDetails2): The model property of type
            ShippingDetails2.
        returns_accepted (bool): This is only needed when you are requesting both
            payment and DM service at same time.  Boolean that indicates whether
            returns are accepted for this order. This field can contain one of the
            following values: - true: Returns are accepted for this order. - false:
            Returns are not accepted for this order.
        is_cryptocurrency_purchase (str): #### Visa Platform Connect : This API will
            contain the Flag that specifies whether the payment is for the purchase
            of cryptocurrency. Additional values to add : This API will contain the
            Flag that specifies whether the payment is for the purchase of
            cryptocurrency. valid values are - Y/y, true - N/n, false
        cutoff_date_time (str): Starting date and time for an event or a journey that
            is independent of which transportation mechanism, in UTC. The
            cutoffDateTime will supersede
            travelInformation.transit.airline.legs[].departureDate and
            travelInformation.transit.airline.legs[].departureTime if these fields
            are supplied in the request. Format: YYYY-MM-DDThh:mm:ssZ. Example
            2016-08-11T22:47:57Z equals August 11, 2016, at 22:47:57 (10:47:57 p.m.).
            The T separates the date and the time. The Z indicates UTC.
        pre_order (str): Indicates whether cardholder is placing an order with a
            future availability or release date. This field can contain one of these
            values: - MERCHANDISE_AVAILABLE: Merchandise available -
            FUTURE_AVAILABILITY: Future availability
        pre_order_date (str): Expected date that a pre-ordered purchase will be
            available. Format: YYYYMMDD
        reordered (bool): Indicates whether the cardholder is reordering previously
            purchased merchandise. This field can contain one of these values: -
            false: First time ordered - true: Reordered
        total_offers_count (str): Total number of articles/items in the order as a
            numeric decimal count. Possible values: 00 - 99
        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",
        "returns_accepted": "returnsAccepted",
        "is_cryptocurrency_purchase": "isCryptocurrencyPurchase",
        "cutoff_date_time": "cutoffDateTime",
        "pre_order": "preOrder",
        "pre_order_date": "preOrderDate",
        "reordered": "reordered",
        "total_offers_count": "totalOffersCount",
    }

    _optionals = [
        "amount_details",
        "bill_to",
        "ship_to",
        "line_items",
        "invoice_details",
        "shipping_details",
        "returns_accepted",
        "is_cryptocurrency_purchase",
        "cutoff_date_time",
        "pre_order",
        "pre_order_date",
        "reordered",
        "total_offers_count",
    ]

    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,
        returns_accepted=APIHelper.SKIP,
        is_cryptocurrency_purchase=APIHelper.SKIP,
        cutoff_date_time=APIHelper.SKIP,
        pre_order=APIHelper.SKIP,
        pre_order_date=APIHelper.SKIP,
        reordered=APIHelper.SKIP,
        total_offers_count=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a OrderInformation 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
        if returns_accepted is not APIHelper.SKIP:
            self.returns_accepted = returns_accepted
        if is_cryptocurrency_purchase is not APIHelper.SKIP:
            self.is_cryptocurrency_purchase = is_cryptocurrency_purchase
        if cutoff_date_time is not APIHelper.SKIP:
            self.cutoff_date_time = cutoff_date_time
        if pre_order is not APIHelper.SKIP:
            self.pre_order = pre_order
        if pre_order_date is not APIHelper.SKIP:
            self.pre_order_date = pre_order_date
        if reordered is not APIHelper.SKIP:
            self.reordered = reordered
        if total_offers_count is not APIHelper.SKIP:
            self.total_offers_count = total_offers_count

        # 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 =\
            AmountDetails.from_dictionary(
                dictionary.get("amountDetails"))\
                if "amountDetails" in dictionary.keys()\
                else APIHelper.SKIP
        bill_to =\
            BillTo.from_dictionary(
                dictionary.get("billTo"))\
                if "billTo" in dictionary.keys()\
                else APIHelper.SKIP
        ship_to =\
            ShipTo.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 = [
                LineItem.from_dictionary(x)
                    for x in dictionary.get("lineItems")
            ]
        else:
            line_items = APIHelper.SKIP
        invoice_details =\
            InvoiceDetails.from_dictionary(
                dictionary.get("invoiceDetails"))\
                if "invoiceDetails" in dictionary.keys()\
                else APIHelper.SKIP
        shipping_details =\
            ShippingDetails2.from_dictionary(
                dictionary.get("shippingDetails"))\
                if "shippingDetails" in dictionary.keys()\
                else APIHelper.SKIP
        returns_accepted =\
            dictionary.get("returnsAccepted")\
            if "returnsAccepted" in dictionary.keys()\
                else APIHelper.SKIP
        is_cryptocurrency_purchase =\
            dictionary.get("isCryptocurrencyPurchase")\
            if dictionary.get("isCryptocurrencyPurchase")\
                else APIHelper.SKIP
        cutoff_date_time =\
            dictionary.get("cutoffDateTime")\
            if dictionary.get("cutoffDateTime")\
                else APIHelper.SKIP
        pre_order =\
            dictionary.get("preOrder")\
            if dictionary.get("preOrder")\
                else APIHelper.SKIP
        pre_order_date =\
            dictionary.get("preOrderDate")\
            if dictionary.get("preOrderDate")\
                else APIHelper.SKIP
        reordered =\
            dictionary.get("reordered")\
            if "reordered" in dictionary.keys()\
                else APIHelper.SKIP
        total_offers_count =\
            dictionary.get("totalOffersCount")\
            if dictionary.get("totalOffersCount")\
                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,
                   returns_accepted,
                   is_cryptocurrency_purchase,
                   cutoff_date_time,
                   pre_order,
                   pre_order_date,
                   reordered,
                   total_offers_count,
                   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
        )
        _returns_accepted=(
            self.returns_accepted
            if hasattr(self, "returns_accepted")
            else None
        )
        _is_cryptocurrency_purchase=(
            self.is_cryptocurrency_purchase
            if hasattr(self, "is_cryptocurrency_purchase")
            else None
        )
        _cutoff_date_time=(
            self.cutoff_date_time
            if hasattr(self, "cutoff_date_time")
            else None
        )
        _pre_order=(
            self.pre_order
            if hasattr(self, "pre_order")
            else None
        )
        _pre_order_date=(
            self.pre_order_date
            if hasattr(self, "pre_order_date")
            else None
        )
        _reordered=(
            self.reordered
            if hasattr(self, "reordered")
            else None
        )
        _total_offers_count=(
            self.total_offers_count
            if hasattr(self, "total_offers_count")
            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"returns_accepted={_returns_accepted!r}, "
            f"is_cryptocurrency_purchase={_is_cryptocurrency_purchase!r}, "
            f"cutoff_date_time={_cutoff_date_time!r}, "
            f"pre_order={_pre_order!r}, "
            f"pre_order_date={_pre_order_date!r}, "
            f"reordered={_reordered!r}, "
            f"total_offers_count={_total_offers_count!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
        )
        _returns_accepted=(
            self.returns_accepted
            if hasattr(self, "returns_accepted")
            else None
        )
        _is_cryptocurrency_purchase=(
            self.is_cryptocurrency_purchase
            if hasattr(self, "is_cryptocurrency_purchase")
            else None
        )
        _cutoff_date_time=(
            self.cutoff_date_time
            if hasattr(self, "cutoff_date_time")
            else None
        )
        _pre_order=(
            self.pre_order
            if hasattr(self, "pre_order")
            else None
        )
        _pre_order_date=(
            self.pre_order_date
            if hasattr(self, "pre_order_date")
            else None
        )
        _reordered=(
            self.reordered
            if hasattr(self, "reordered")
            else None
        )
        _total_offers_count=(
            self.total_offers_count
            if hasattr(self, "total_offers_count")
            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"returns_accepted={_returns_accepted!s}, "
            f"is_cryptocurrency_purchase={_is_cryptocurrency_purchase!s}, "
            f"cutoff_date_time={_cutoff_date_time!s}, "
            f"pre_order={_pre_order!s}, "
            f"pre_order_date={_pre_order_date!s}, "
            f"reordered={_reordered!s}, "
            f"total_offers_count={_total_offers_count!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
