"""mindbodypublicapi.

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

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


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

    Attributes:
        id (str): The ID of the item.
        name (str): The name of the item.
        description (str): A description of the item.
        mtype (str): The type of the item.
        price (float): The price of the item.
        quantity (int): The quantity of the item.
        one_time_item (bool): When `true`, indicates that the item is charged only
            once.<br />  When `false`, indicates that the item is charged multiple
            times.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "id": "Id",
        "name": "Name",
        "description": "Description",
        "mtype": "Type",
        "price": "Price",
        "quantity": "Quantity",
        "one_time_item": "OneTimeItem",
    }

    _optionals = [
        "id",
        "name",
        "description",
        "mtype",
        "price",
        "quantity",
        "one_time_item",
    ]

    def __init__(
        self,
        id=APIHelper.SKIP,
        name=APIHelper.SKIP,
        description=APIHelper.SKIP,
        mtype=APIHelper.SKIP,
        price=APIHelper.SKIP,
        quantity=APIHelper.SKIP,
        one_time_item=APIHelper.SKIP):
        """Initialize a ContractItem instance."""
        # Initialize members of the class
        if id is not APIHelper.SKIP:
            self.id = id
        if name is not APIHelper.SKIP:
            self.name = name
        if description is not APIHelper.SKIP:
            self.description = description
        if mtype is not APIHelper.SKIP:
            self.mtype = mtype
        if price is not APIHelper.SKIP:
            self.price = price
        if quantity is not APIHelper.SKIP:
            self.quantity = quantity
        if one_time_item is not APIHelper.SKIP:
            self.one_time_item = one_time_item

    @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
        id =\
            dictionary.get("Id")\
            if dictionary.get("Id")\
                else APIHelper.SKIP
        name =\
            dictionary.get("Name")\
            if dictionary.get("Name")\
                else APIHelper.SKIP
        description =\
            dictionary.get("Description")\
            if dictionary.get("Description")\
                else APIHelper.SKIP
        mtype =\
            dictionary.get("Type")\
            if dictionary.get("Type")\
                else APIHelper.SKIP
        price =\
            dictionary.get("Price")\
            if dictionary.get("Price")\
                else APIHelper.SKIP
        quantity =\
            dictionary.get("Quantity")\
            if dictionary.get("Quantity")\
                else APIHelper.SKIP
        one_time_item =\
            dictionary.get("OneTimeItem")\
            if "OneTimeItem" in dictionary.keys()\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(id,
                   name,
                   description,
                   mtype,
                   price,
                   quantity,
                   one_time_item)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _id=(
            self.id
            if hasattr(self, "id")
            else None
        )
        _name=(
            self.name
            if hasattr(self, "name")
            else None
        )
        _description=(
            self.description
            if hasattr(self, "description")
            else None
        )
        _mtype=(
            self.mtype
            if hasattr(self, "mtype")
            else None
        )
        _price=(
            self.price
            if hasattr(self, "price")
            else None
        )
        _quantity=(
            self.quantity
            if hasattr(self, "quantity")
            else None
        )
        _one_time_item=(
            self.one_time_item
            if hasattr(self, "one_time_item")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"id={_id!r}, "
            f"name={_name!r}, "
            f"description={_description!r}, "
            f"mtype={_mtype!r}, "
            f"price={_price!r}, "
            f"quantity={_quantity!r}, "
            f"one_time_item={_one_time_item!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _id=(
            self.id
            if hasattr(self, "id")
            else None
        )
        _name=(
            self.name
            if hasattr(self, "name")
            else None
        )
        _description=(
            self.description
            if hasattr(self, "description")
            else None
        )
        _mtype=(
            self.mtype
            if hasattr(self, "mtype")
            else None
        )
        _price=(
            self.price
            if hasattr(self, "price")
            else None
        )
        _quantity=(
            self.quantity
            if hasattr(self, "quantity")
            else None
        )
        _one_time_item=(
            self.one_time_item
            if hasattr(self, "one_time_item")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"id={_id!s}, "
            f"name={_name!s}, "
            f"description={_description!s}, "
            f"mtype={_mtype!s}, "
            f"price={_price!s}, "
            f"quantity={_quantity!s}, "
            f"one_time_item={_one_time_item!s}, "
            f")"
        )
