"""cellpointapi.

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

# ruff: noqa: E501
from cellpointapi.api_helper import APIHelper


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

    Line item base. Represents the common fields shared across all
    billable items on an order.

    Attributes:
        title (str): What should be shown as the title of the line item on a receipt
            or billing summary.
        mtype (LineItemType): The type of line item.
        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 = {
        "title": "title",
        "mtype": "type",
        "authorization_group_id": "authorizationGroupId",
    }

    _optionals = [
        "authorization_group_id",
    ]

    def __init__(
        self,
        title=None,
        mtype=None,
        authorization_group_id=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a LineItemBase instance."""
        # Initialize members of the class
        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
        title =\
            dictionary.get("title")\
            if dictionary.get("title")\
                else None
        mtype =\
            dictionary.get("type")\
            if dictionary.get("type")\
                else None
        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(title,
                   mtype,
                   authorization_group_id,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _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"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."""
        _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"title={_title!s}, "
            f"mtype={_mtype!s}, "
            f"authorization_group_id={_authorization_group_id!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
