"""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 FulfilledLineItemBase(object):
    """Implementation of the 'FulfilledLineItemBase' model.

    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`.
        title (str): What should be shown as the title of the line item on a receipt
            or billing summary.
        mtype (Type5): The type of line item.  Note that while in [Create
            Order](#tag/Orders/operation/create-order), there are additional fields
            with certain types of line items, on fulfillment -- as this data is
            already known from [Create Order](#tag/Orders/operation/create-order), it
            is unnecessary.  Anything other than a `Discount`, just requires the
            level of details of a normal `Product` type.  <table>   <thead>     <tr>
            <th>Line Item Type</th>       <th>Description</th>     </tr>   </thead>
            <tbody>     <tr>       <td>ACTIVITY</td>       <td>Activities, such as
            tours, museum tickets, etc.</td>     </tr>     <tr>
            <td>AIRLINE_ANCILLARY</td>       <td>Ancillary services offered by
            airlines, such as baggage fees, seat upgrades, etc.</td>     </tr>
            <tr>       <td>AIRLINE_FARE</td>       <td>Fares for a flight.</td>
            </tr>     <tr>       <td>AUTO_RENTAL</td>       <td>Auto rental</td>
            </tr>     <tr>       <td>BUNDLE</td>       <td>A collection of line items
            and products have been packaged together into a single unit.</td>
            </tr>     <tr>       <td>DISCOUNT</td>       <td>Discount</td>     </tr>
            <tr>       <td>LODGING_RESERVATION</td>       <td>Bookings of a room at a
            hotel, hostel, etc.</td>     </tr>     <tr>       <td>PRODUCT</td>
            <td>Product is a catch-all for any other line item type not listed
            here.</td>     </tr>   </tbody> </table>
        authorization_group_id (str): AuthorizationGroup that the line item should be
            part of for splitting authorizations for Aggregate Payments Payments.  If
            this is set, there must be a matching AuthorizationGroup created in the
            PriceSummary.  > NOTE: Items within a Bundle should not have an
            `authorizationGroupId`, they will use the same `authorizationGroupId` as
            the top-level bundle.
        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",
        "title": "title",
        "mtype": "type",
        "fulfilled_price": "fulfilledPrice",
        "authorization_group_id": "authorizationGroupId",
    }

    _optionals = [
        "fulfilled_price",
        "authorization_group_id",
    ]

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

        # 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
        title =\
            dictionary.get("title")\
            if dictionary.get("title")\
                else None
        mtype =\
            dictionary.get("type")\
            if dictionary.get("type")\
                else None
        fulfilled_price =\
            Amount.from_dictionary(
                dictionary.get("fulfilledPrice"))\
                if "fulfilledPrice" in dictionary.keys()\
                else APIHelper.SKIP
        authorization_group_id =\
            dictionary.get("authorizationGroupId")\
            if dictionary.get("authorizationGroupId")\
                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,
                   title,
                   mtype,
                   fulfilled_price,
                   authorization_group_id,
                   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
        )
        _title=self.title
        _mtype=self.mtype
        _authorization_group_id=(
            self.authorization_group_id
            if hasattr(self, "authorization_group_id")
            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"title={_title!r}, "
            f"mtype={_mtype!r}, "
            f"authorization_group_id={_authorization_group_id!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
        )
        _title=self.title
        _mtype=self.mtype
        _authorization_group_id=(
            self.authorization_group_id
            if hasattr(self, "authorization_group_id")
            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"title={_title!s}, "
            f"mtype={_mtype!s}, "
            f"authorization_group_id={_authorization_group_id!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
