"""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.sub_category import (
    SubCategory,
)


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

    Attributes:
        id (int): The category Id used for api calls.
        category_name (str): Category Name
        description (str): Category Description
        service (bool): Category service
        active (bool): Check if Category is active.
        is_primary (bool): Check if Category is of primary type.
        is_secondary (bool): Check if Category is of secondary type.
        created_date_time_utc (datetime): Category Created DateTime UTC
        modified_date_time_utc (datetime): Category Modified DateTime UTC
        sub_categories (List[SubCategory]): Contains the SubCategory objects, each of
            which describes the subcategories for a category.
        total_count (int): Get total number of rows

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "id": "Id",
        "category_name": "CategoryName",
        "description": "Description",
        "service": "Service",
        "active": "Active",
        "is_primary": "IsPrimary",
        "is_secondary": "IsSecondary",
        "created_date_time_utc": "CreatedDateTimeUTC",
        "modified_date_time_utc": "ModifiedDateTimeUTC",
        "sub_categories": "SubCategories",
        "total_count": "TotalCount",
    }

    _optionals = [
        "id",
        "category_name",
        "description",
        "service",
        "active",
        "is_primary",
        "is_secondary",
        "created_date_time_utc",
        "modified_date_time_utc",
        "sub_categories",
        "total_count",
    ]

    def __init__(
        self,
        id=APIHelper.SKIP,
        category_name=APIHelper.SKIP,
        description=APIHelper.SKIP,
        service=APIHelper.SKIP,
        active=APIHelper.SKIP,
        is_primary=APIHelper.SKIP,
        is_secondary=APIHelper.SKIP,
        created_date_time_utc=APIHelper.SKIP,
        modified_date_time_utc=APIHelper.SKIP,
        sub_categories=APIHelper.SKIP,
        total_count=APIHelper.SKIP):
        """Initialize a Category instance."""
        # Initialize members of the class
        if id is not APIHelper.SKIP:
            self.id = id
        if category_name is not APIHelper.SKIP:
            self.category_name = category_name
        if description is not APIHelper.SKIP:
            self.description = description
        if service is not APIHelper.SKIP:
            self.service = service
        if active is not APIHelper.SKIP:
            self.active = active
        if is_primary is not APIHelper.SKIP:
            self.is_primary = is_primary
        if is_secondary is not APIHelper.SKIP:
            self.is_secondary = is_secondary
        if created_date_time_utc is not APIHelper.SKIP:
            self.created_date_time_utc =\
                 APIHelper.apply_datetime_converter(
                created_date_time_utc, APIHelper.RFC3339DateTime)\
                 if created_date_time_utc else None
        if modified_date_time_utc is not APIHelper.SKIP:
            self.modified_date_time_utc =\
                 APIHelper.apply_datetime_converter(
                modified_date_time_utc, APIHelper.RFC3339DateTime)\
                 if modified_date_time_utc else None
        if sub_categories is not APIHelper.SKIP:
            self.sub_categories = sub_categories
        if total_count is not APIHelper.SKIP:
            self.total_count = total_count

    @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
        category_name =\
            dictionary.get("CategoryName")\
            if dictionary.get("CategoryName")\
                else APIHelper.SKIP
        description =\
            dictionary.get("Description")\
            if dictionary.get("Description")\
                else APIHelper.SKIP
        service =\
            dictionary.get("Service")\
            if "Service" in dictionary.keys()\
                else APIHelper.SKIP
        active =\
            dictionary.get("Active")\
            if "Active" in dictionary.keys()\
                else APIHelper.SKIP
        is_primary =\
            dictionary.get("IsPrimary")\
            if "IsPrimary" in dictionary.keys()\
                else APIHelper.SKIP
        is_secondary =\
            dictionary.get("IsSecondary")\
            if "IsSecondary" in dictionary.keys()\
                else APIHelper.SKIP
        created_date_time_utc = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("CreatedDateTimeUTC")).datetime\
            if dictionary.get("CreatedDateTimeUTC") else APIHelper.SKIP
        modified_date_time_utc = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("ModifiedDateTimeUTC")).datetime\
            if dictionary.get("ModifiedDateTimeUTC") else APIHelper.SKIP
        sub_categories = None
        if dictionary.get("SubCategories") is not None:
            sub_categories = [
                SubCategory.from_dictionary(x)
                    for x in dictionary.get("SubCategories")
            ]
        else:
            sub_categories = APIHelper.SKIP
        total_count =\
            dictionary.get("TotalCount")\
            if dictionary.get("TotalCount")\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(id,
                   category_name,
                   description,
                   service,
                   active,
                   is_primary,
                   is_secondary,
                   created_date_time_utc,
                   modified_date_time_utc,
                   sub_categories,
                   total_count)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _id=(
            self.id
            if hasattr(self, "id")
            else None
        )
        _category_name=(
            self.category_name
            if hasattr(self, "category_name")
            else None
        )
        _description=(
            self.description
            if hasattr(self, "description")
            else None
        )
        _service=(
            self.service
            if hasattr(self, "service")
            else None
        )
        _active=(
            self.active
            if hasattr(self, "active")
            else None
        )
        _is_primary=(
            self.is_primary
            if hasattr(self, "is_primary")
            else None
        )
        _is_secondary=(
            self.is_secondary
            if hasattr(self, "is_secondary")
            else None
        )
        _created_date_time_utc=(
            self.created_date_time_utc
            if hasattr(self, "created_date_time_utc")
            else None
        )
        _modified_date_time_utc=(
            self.modified_date_time_utc
            if hasattr(self, "modified_date_time_utc")
            else None
        )
        _sub_categories=(
            self.sub_categories
            if hasattr(self, "sub_categories")
            else None
        )
        _total_count=(
            self.total_count
            if hasattr(self, "total_count")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"id={_id!r}, "
            f"category_name={_category_name!r}, "
            f"description={_description!r}, "
            f"service={_service!r}, "
            f"active={_active!r}, "
            f"is_primary={_is_primary!r}, "
            f"is_secondary={_is_secondary!r}, "
            f"created_date_time_utc={_created_date_time_utc!r}, "
            f"modified_date_time_utc={_modified_date_time_utc!r}, "
            f"sub_categories={_sub_categories!r}, "
            f"total_count={_total_count!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _id=(
            self.id
            if hasattr(self, "id")
            else None
        )
        _category_name=(
            self.category_name
            if hasattr(self, "category_name")
            else None
        )
        _description=(
            self.description
            if hasattr(self, "description")
            else None
        )
        _service=(
            self.service
            if hasattr(self, "service")
            else None
        )
        _active=(
            self.active
            if hasattr(self, "active")
            else None
        )
        _is_primary=(
            self.is_primary
            if hasattr(self, "is_primary")
            else None
        )
        _is_secondary=(
            self.is_secondary
            if hasattr(self, "is_secondary")
            else None
        )
        _created_date_time_utc=(
            self.created_date_time_utc
            if hasattr(self, "created_date_time_utc")
            else None
        )
        _modified_date_time_utc=(
            self.modified_date_time_utc
            if hasattr(self, "modified_date_time_utc")
            else None
        )
        _sub_categories=(
            self.sub_categories
            if hasattr(self, "sub_categories")
            else None
        )
        _total_count=(
            self.total_count
            if hasattr(self, "total_count")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"id={_id!s}, "
            f"category_name={_category_name!s}, "
            f"description={_description!s}, "
            f"service={_service!s}, "
            f"active={_active!s}, "
            f"is_primary={_is_primary!s}, "
            f"is_secondary={_is_secondary!s}, "
            f"created_date_time_utc={_created_date_time_utc!s}, "
            f"modified_date_time_utc={_modified_date_time_utc!s}, "
            f"sub_categories={_sub_categories!s}, "
            f"total_count={_total_count!s}, "
            f")"
        )
