"""cellpointapi.

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

# ruff: noqa: E501
from cellpointapi.api_helper import APIHelper
from cellpointapi.models.buyer import Buyer
from cellpointapi.models.hpp_data import HppData
from cellpointapi.models.industry_data import (
    IndustryData,
)
from cellpointapi.models.price_summary import (
    PriceSummary,
)
from cellpointapi.models.reward import Reward


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

    Order extended with additional information.

    Attributes:
        price_summary (PriceSummary): Summary or breakdown of the pricing of each
            individual item being purchased as part of an order, along with the total
            cost to the Buyer.
        buyer (Buyer): Buyer information.
        industry_data (IndustryData): Industry specific data required based on
            agreements between merchant and acquirers and for fraud detection.
        rewards (List[Reward]): The model property of type List[Reward].
        sales_channel (SalesChannel): - IBE - Internet Booking Engine - CC - Customer
            Care
        hpp_data (HppData): HPP data for the order.
        custom (Dict[str, str]): Custom data to attach to the order for tracking and
            analytical reasons by a merchant.  **No sensitive data should ever be
            passed in custom fields.**  > Note: These properties are not used by
            CellPoint Digital for any payment processing and will not be passed to
            any acquirers.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "price_summary": "priceSummary",
        "sales_channel": "salesChannel",
        "hpp_data": "hppData",
        "buyer": "buyer",
        "industry_data": "industryData",
        "rewards": "rewards",
        "custom": "custom",
    }

    _optionals = [
        "buyer",
        "industry_data",
        "rewards",
        "custom",
    ]

    def __init__(
        self,
        price_summary=None,
        sales_channel=None,
        hpp_data=None,
        buyer=APIHelper.SKIP,
        industry_data=APIHelper.SKIP,
        rewards=APIHelper.SKIP,
        custom=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a OrderExtended instance."""
        # Initialize members of the class
        self.price_summary = price_summary
        if buyer is not APIHelper.SKIP:
            self.buyer = buyer
        if industry_data is not APIHelper.SKIP:
            self.industry_data = industry_data
        if rewards is not APIHelper.SKIP:
            self.rewards = rewards
        self.sales_channel = sales_channel
        self.hpp_data = hpp_data
        if custom is not APIHelper.SKIP:
            self.custom = custom

        # 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
        price_summary =\
            PriceSummary.from_dictionary(
                dictionary.get("priceSummary"))\
                if dictionary.get("priceSummary") else None
        sales_channel =\
            dictionary.get("salesChannel")\
            if dictionary.get("salesChannel")\
                else None
        hpp_data =\
            HppData.from_dictionary(
                dictionary.get("hppData"))\
                if dictionary.get("hppData") else None
        buyer =\
            Buyer.from_dictionary(
                dictionary.get("buyer"))\
                if "buyer" in dictionary.keys()\
                else APIHelper.SKIP
        industry_data =\
            IndustryData.from_dictionary(
                dictionary.get("industryData"))\
                if "industryData" in dictionary.keys()\
                else APIHelper.SKIP
        rewards = None
        if dictionary.get("rewards") is not None:
            rewards = [
                Reward.from_dictionary(x)
                    for x in dictionary.get("rewards")
            ]
        else:
            rewards = APIHelper.SKIP
        custom =\
            dictionary.get("custom")\
            if dictionary.get("custom")\
                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(price_summary,
                   sales_channel,
                   hpp_data,
                   buyer,
                   industry_data,
                   rewards,
                   custom,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _price_summary=self.price_summary
        _buyer=(
            self.buyer
            if hasattr(self, "buyer")
            else None
        )
        _industry_data=(
            self.industry_data
            if hasattr(self, "industry_data")
            else None
        )
        _rewards=(
            self.rewards
            if hasattr(self, "rewards")
            else None
        )
        _sales_channel=self.sales_channel
        _hpp_data=self.hpp_data
        _custom=(
            self.custom
            if hasattr(self, "custom")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"price_summary={_price_summary!r}, "
            f"buyer={_buyer!r}, "
            f"industry_data={_industry_data!r}, "
            f"rewards={_rewards!r}, "
            f"sales_channel={_sales_channel!r}, "
            f"hpp_data={_hpp_data!r}, "
            f"custom={_custom!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _price_summary=self.price_summary
        _buyer=(
            self.buyer
            if hasattr(self, "buyer")
            else None
        )
        _industry_data=(
            self.industry_data
            if hasattr(self, "industry_data")
            else None
        )
        _rewards=(
            self.rewards
            if hasattr(self, "rewards")
            else None
        )
        _sales_channel=self.sales_channel
        _hpp_data=self.hpp_data
        _custom=(
            self.custom
            if hasattr(self, "custom")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"price_summary={_price_summary!s}, "
            f"buyer={_buyer!s}, "
            f"industry_data={_industry_data!s}, "
            f"rewards={_rewards!s}, "
            f"sales_channel={_sales_channel!s}, "
            f"hpp_data={_hpp_data!s}, "
            f"custom={_custom!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
