"""mindbodypublicapi.

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

# ruff: noqa: E501
from mindbodypublicapi.api_helper import APIHelper
from mindbodypublicapi.models.client_index_value import (
    ClientIndexValue,
)


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

    A client index.

    Attributes:
        id (int): The unique ID of the client index.
        name (str): The name of the client index.
        required_business_mode (bool): When `true`, indicates that the index is
            required when creating profiles in business mode.
        required_consumer_mode (bool): When `true`, indicates that the index is
            required when creating profiles in consumer mode.
        values (List[ClientIndexValue]): Contains a list with a single object
            representing the index value assigned to the client index.
        action (Action8Enum): The action performed on this object.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "id": "Id",
        "name": "Name",
        "required_business_mode": "RequiredBusinessMode",
        "required_consumer_mode": "RequiredConsumerMode",
        "values": "Values",
        "action": "Action",
    }

    _optionals = [
        "id",
        "name",
        "required_business_mode",
        "required_consumer_mode",
        "values",
        "action",
    ]

    def __init__(
        self,
        id=APIHelper.SKIP,
        name=APIHelper.SKIP,
        required_business_mode=APIHelper.SKIP,
        required_consumer_mode=APIHelper.SKIP,
        values=APIHelper.SKIP,
        action=APIHelper.SKIP):
        """Initialize a ClientIndex 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 required_business_mode is not APIHelper.SKIP:
            self.required_business_mode = required_business_mode
        if required_consumer_mode is not APIHelper.SKIP:
            self.required_consumer_mode = required_consumer_mode
        if values is not APIHelper.SKIP:
            self.values = values
        if action is not APIHelper.SKIP:
            self.action = action

    @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
        required_business_mode =\
            dictionary.get("RequiredBusinessMode")\
            if "RequiredBusinessMode" in dictionary.keys()\
                else APIHelper.SKIP
        required_consumer_mode =\
            dictionary.get("RequiredConsumerMode")\
            if "RequiredConsumerMode" in dictionary.keys()\
                else APIHelper.SKIP
        values = None
        if dictionary.get("Values") is not None:
            values = [
                ClientIndexValue.from_dictionary(x)
                    for x in dictionary.get("Values")
            ]
        else:
            values = APIHelper.SKIP
        action =\
            dictionary.get("Action")\
            if dictionary.get("Action")\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(id,
                   name,
                   required_business_mode,
                   required_consumer_mode,
                   values,
                   action)

    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
        )
        _required_business_mode=(
            self.required_business_mode
            if hasattr(self, "required_business_mode")
            else None
        )
        _required_consumer_mode=(
            self.required_consumer_mode
            if hasattr(self, "required_consumer_mode")
            else None
        )
        _values=(
            self.values
            if hasattr(self, "values")
            else None
        )
        _action=(
            self.action
            if hasattr(self, "action")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"id={_id!r}, "
            f"name={_name!r}, "
            f"required_business_mode={_required_business_mode!r}, "
            f"required_consumer_mode={_required_consumer_mode!r}, "
            f"values={_values!r}, "
            f"action={_action!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
        )
        _required_business_mode=(
            self.required_business_mode
            if hasattr(self, "required_business_mode")
            else None
        )
        _required_consumer_mode=(
            self.required_consumer_mode
            if hasattr(self, "required_consumer_mode")
            else None
        )
        _values=(
            self.values
            if hasattr(self, "values")
            else None
        )
        _action=(
            self.action
            if hasattr(self, "action")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"id={_id!s}, "
            f"name={_name!s}, "
            f"required_business_mode={_required_business_mode!s}, "
            f"required_consumer_mode={_required_consumer_mode!s}, "
            f"values={_values!s}, "
            f"action={_action!s}, "
            f")"
        )
