"""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.amount import Amount


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

    Additional information that is sent with line items/tax lines on fulfillment.

    Attributes:
        fulfillment_status (FulfillmentStatus): Result of the fulfillment.  On
            `PARTIAL`, the amount that was fulfilled must be specified.
        fulfilled_price (Amount): Conditional property that should be sent if
            `fulfillmentStatus` is `PARTIAL`.  `fulfilledPrice` must be less than or
            equal to original `price`.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "fulfillment_status": "fulfillmentStatus",
        "fulfilled_price": "fulfilledPrice",
    }

    _optionals = [
        "fulfilled_price",
    ]

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

        # 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
        fulfillment_status =\
            dictionary.get("fulfillmentStatus")\
            if dictionary.get("fulfillmentStatus")\
                else None
        fulfilled_price =\
            Amount.from_dictionary(
                dictionary.get("fulfilledPrice"))\
                if "fulfilledPrice" 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(fulfillment_status,
                   fulfilled_price,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _fulfillment_status=self.fulfillment_status
        _fulfilled_price=(
            self.fulfilled_price
            if hasattr(self, "fulfilled_price")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"fulfillment_status={_fulfillment_status!r}, "
            f"fulfilled_price={_fulfilled_price!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _fulfillment_status=self.fulfillment_status
        _fulfilled_price=(
            self.fulfilled_price
            if hasattr(self, "fulfilled_price")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"fulfillment_status={_fulfillment_status!s}, "
            f"fulfilled_price={_fulfilled_price!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
