"""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.informational_price_row import (
    InformationalPriceRow,
)
from cellpointapi.models.total_row import TotalRow


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

    Section of the informational price breakdown.

    Attributes:
        mtype (str): Optional type of row that can be passed.  Depending on where
            this displayed, this field may or may not be used.
        rows (List[InformationalPriceRow]): The model property of type
            List[InformationalPriceRow].
        total_row (TotalRow): The model property of type TotalRow.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "rows": "rows",
        "total_row": "totalRow",
        "mtype": "type",
    }

    _optionals = [
        "mtype",
    ]

    def __init__(
        self,
        rows=None,
        total_row=None,
        mtype=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a InformationalPriceSection instance."""
        # Initialize members of the class
        if mtype is not APIHelper.SKIP:
            self.mtype = mtype
        self.rows = rows
        self.total_row = total_row

        # 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
        rows = None
        if dictionary.get("rows") is not None:
            rows = [
                InformationalPriceRow.from_dictionary(x)
                    for x in dictionary.get("rows")
            ]
        total_row =\
            TotalRow.from_dictionary(
                dictionary.get("totalRow"))\
                if dictionary.get("totalRow") else None
        mtype =\
            dictionary.get("type")\
            if dictionary.get("type")\
                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(rows,
                   total_row,
                   mtype,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _mtype=(
            self.mtype
            if hasattr(self, "mtype")
            else None
        )
        _rows=self.rows
        _total_row=self.total_row
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"mtype={_mtype!r}, "
            f"rows={_rows!r}, "
            f"total_row={_total_row!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _mtype=(
            self.mtype
            if hasattr(self, "mtype")
            else None
        )
        _rows=self.rows
        _total_row=self.total_row
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"mtype={_mtype!s}, "
            f"rows={_rows!s}, "
            f"total_row={_total_row!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
