"""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.reservation import (
    Reservation,
)
from mindbodypublicapi.models.spot import Spot


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

    Contains information about the PickASpot classes.

    Attributes:
        site_id (int): The unique ID of the Site.
        location_id (int): The unique ID of the Location.
        class_id (str): The unique ID of the Class.
        class_external_id (str): The unique Class external ID.
        class_name (str): Contains the class name.
        class_start_time (datetime): Class start time.
        class_end_time (datetime): Class end time.
        class_maximum_capacity (int): Contains information about the Class maximum
            capacity.
        room_id (str): The unique Room ID.
        spots (Spot): Contains information about the spot details.
        reservations (List[Reservation]): Contains information about the reservation
            collection.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "site_id": "SiteId",
        "location_id": "LocationId",
        "class_id": "ClassId",
        "class_external_id": "ClassExternalId",
        "class_name": "ClassName",
        "class_start_time": "ClassStartTime",
        "class_end_time": "ClassEndTime",
        "class_maximum_capacity": "ClassMaximumCapacity",
        "room_id": "RoomId",
        "spots": "Spots",
        "reservations": "Reservations",
    }

    _optionals = [
        "site_id",
        "location_id",
        "class_id",
        "class_external_id",
        "class_name",
        "class_start_time",
        "class_end_time",
        "class_maximum_capacity",
        "room_id",
        "spots",
        "reservations",
    ]

    def __init__(
        self,
        site_id=APIHelper.SKIP,
        location_id=APIHelper.SKIP,
        class_id=APIHelper.SKIP,
        class_external_id=APIHelper.SKIP,
        class_name=APIHelper.SKIP,
        class_start_time=APIHelper.SKIP,
        class_end_time=APIHelper.SKIP,
        class_maximum_capacity=APIHelper.SKIP,
        room_id=APIHelper.SKIP,
        spots=APIHelper.SKIP,
        reservations=APIHelper.SKIP):
        """Initialize a PickASpotClass instance."""
        # Initialize members of the class
        if site_id is not APIHelper.SKIP:
            self.site_id = site_id
        if location_id is not APIHelper.SKIP:
            self.location_id = location_id
        if class_id is not APIHelper.SKIP:
            self.class_id = class_id
        if class_external_id is not APIHelper.SKIP:
            self.class_external_id = class_external_id
        if class_name is not APIHelper.SKIP:
            self.class_name = class_name
        if class_start_time is not APIHelper.SKIP:
            self.class_start_time =\
                 APIHelper.apply_datetime_converter(
                class_start_time, APIHelper.RFC3339DateTime)\
                 if class_start_time else None
        if class_end_time is not APIHelper.SKIP:
            self.class_end_time =\
                 APIHelper.apply_datetime_converter(
                class_end_time, APIHelper.RFC3339DateTime)\
                 if class_end_time else None
        if class_maximum_capacity is not APIHelper.SKIP:
            self.class_maximum_capacity = class_maximum_capacity
        if room_id is not APIHelper.SKIP:
            self.room_id = room_id
        if spots is not APIHelper.SKIP:
            self.spots = spots
        if reservations is not APIHelper.SKIP:
            self.reservations = reservations

    @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
        site_id =\
            dictionary.get("SiteId")\
            if dictionary.get("SiteId")\
                else APIHelper.SKIP
        location_id =\
            dictionary.get("LocationId")\
            if dictionary.get("LocationId")\
                else APIHelper.SKIP
        class_id =\
            dictionary.get("ClassId")\
            if dictionary.get("ClassId")\
                else APIHelper.SKIP
        class_external_id =\
            dictionary.get("ClassExternalId")\
            if dictionary.get("ClassExternalId")\
                else APIHelper.SKIP
        class_name =\
            dictionary.get("ClassName")\
            if dictionary.get("ClassName")\
                else APIHelper.SKIP
        class_start_time = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("ClassStartTime")).datetime\
            if dictionary.get("ClassStartTime") else APIHelper.SKIP
        class_end_time = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("ClassEndTime")).datetime\
            if dictionary.get("ClassEndTime") else APIHelper.SKIP
        class_maximum_capacity =\
            dictionary.get("ClassMaximumCapacity")\
            if dictionary.get("ClassMaximumCapacity")\
                else APIHelper.SKIP
        room_id =\
            dictionary.get("RoomId")\
            if dictionary.get("RoomId")\
                else APIHelper.SKIP
        spots =\
            Spot.from_dictionary(
                dictionary.get("Spots"))\
                if "Spots" in dictionary.keys()\
                else APIHelper.SKIP
        reservations = None
        if dictionary.get("Reservations") is not None:
            reservations = [
                Reservation.from_dictionary(x)
                    for x in dictionary.get("Reservations")
            ]
        else:
            reservations = APIHelper.SKIP

        # Return an object of this model
        return cls(site_id,
                   location_id,
                   class_id,
                   class_external_id,
                   class_name,
                   class_start_time,
                   class_end_time,
                   class_maximum_capacity,
                   room_id,
                   spots,
                   reservations)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _site_id=(
            self.site_id
            if hasattr(self, "site_id")
            else None
        )
        _location_id=(
            self.location_id
            if hasattr(self, "location_id")
            else None
        )
        _class_id=(
            self.class_id
            if hasattr(self, "class_id")
            else None
        )
        _class_external_id=(
            self.class_external_id
            if hasattr(self, "class_external_id")
            else None
        )
        _class_name=(
            self.class_name
            if hasattr(self, "class_name")
            else None
        )
        _class_start_time=(
            self.class_start_time
            if hasattr(self, "class_start_time")
            else None
        )
        _class_end_time=(
            self.class_end_time
            if hasattr(self, "class_end_time")
            else None
        )
        _class_maximum_capacity=(
            self.class_maximum_capacity
            if hasattr(self, "class_maximum_capacity")
            else None
        )
        _room_id=(
            self.room_id
            if hasattr(self, "room_id")
            else None
        )
        _spots=(
            self.spots
            if hasattr(self, "spots")
            else None
        )
        _reservations=(
            self.reservations
            if hasattr(self, "reservations")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"site_id={_site_id!r}, "
            f"location_id={_location_id!r}, "
            f"class_id={_class_id!r}, "
            f"class_external_id={_class_external_id!r}, "
            f"class_name={_class_name!r}, "
            f"class_start_time={_class_start_time!r}, "
            f"class_end_time={_class_end_time!r}, "
            f"class_maximum_capacity={_class_maximum_capacity!r}, "
            f"room_id={_room_id!r}, "
            f"spots={_spots!r}, "
            f"reservations={_reservations!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _site_id=(
            self.site_id
            if hasattr(self, "site_id")
            else None
        )
        _location_id=(
            self.location_id
            if hasattr(self, "location_id")
            else None
        )
        _class_id=(
            self.class_id
            if hasattr(self, "class_id")
            else None
        )
        _class_external_id=(
            self.class_external_id
            if hasattr(self, "class_external_id")
            else None
        )
        _class_name=(
            self.class_name
            if hasattr(self, "class_name")
            else None
        )
        _class_start_time=(
            self.class_start_time
            if hasattr(self, "class_start_time")
            else None
        )
        _class_end_time=(
            self.class_end_time
            if hasattr(self, "class_end_time")
            else None
        )
        _class_maximum_capacity=(
            self.class_maximum_capacity
            if hasattr(self, "class_maximum_capacity")
            else None
        )
        _room_id=(
            self.room_id
            if hasattr(self, "room_id")
            else None
        )
        _spots=(
            self.spots
            if hasattr(self, "spots")
            else None
        )
        _reservations=(
            self.reservations
            if hasattr(self, "reservations")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"site_id={_site_id!s}, "
            f"location_id={_location_id!s}, "
            f"class_id={_class_id!s}, "
            f"class_external_id={_class_external_id!s}, "
            f"class_name={_class_name!s}, "
            f"class_start_time={_class_start_time!s}, "
            f"class_end_time={_class_end_time!s}, "
            f"class_maximum_capacity={_class_maximum_capacity!s}, "
            f"room_id={_room_id!s}, "
            f"spots={_spots!s}, "
            f"reservations={_reservations!s}, "
            f")"
        )
