"""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.spot import Spot


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

    Contains information about the reservation.

    Attributes:
        reservation_id (str): The unique reservation ID.
        reservation_external_id (str): The unique reservation external ID.
        class_id (str): The unique class ID.
        class_external_id (str): The unique class external ID.
        member_external_id (str): The unique member external ID.
        reservation_type (str): Contains information about the reservation type.
        spots (Spot): Contains information about the spot details.
        is_confirmed (bool): Boolean value whether it is confirmed.
        confirmation_date (datetime): Contains information about the confirmation
            date.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "reservation_id": "ReservationId",
        "reservation_external_id": "ReservationExternalId",
        "class_id": "ClassId",
        "class_external_id": "ClassExternalId",
        "member_external_id": "MemberExternalId",
        "reservation_type": "ReservationType",
        "spots": "Spots",
        "is_confirmed": "IsConfirmed",
        "confirmation_date": "ConfirmationDate",
    }

    _optionals = [
        "reservation_id",
        "reservation_external_id",
        "class_id",
        "class_external_id",
        "member_external_id",
        "reservation_type",
        "spots",
        "is_confirmed",
        "confirmation_date",
    ]

    def __init__(
        self,
        reservation_id=APIHelper.SKIP,
        reservation_external_id=APIHelper.SKIP,
        class_id=APIHelper.SKIP,
        class_external_id=APIHelper.SKIP,
        member_external_id=APIHelper.SKIP,
        reservation_type=APIHelper.SKIP,
        spots=APIHelper.SKIP,
        is_confirmed=APIHelper.SKIP,
        confirmation_date=APIHelper.SKIP):
        """Initialize a Reservation instance."""
        # Initialize members of the class
        if reservation_id is not APIHelper.SKIP:
            self.reservation_id = reservation_id
        if reservation_external_id is not APIHelper.SKIP:
            self.reservation_external_id = reservation_external_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 member_external_id is not APIHelper.SKIP:
            self.member_external_id = member_external_id
        if reservation_type is not APIHelper.SKIP:
            self.reservation_type = reservation_type
        if spots is not APIHelper.SKIP:
            self.spots = spots
        if is_confirmed is not APIHelper.SKIP:
            self.is_confirmed = is_confirmed
        if confirmation_date is not APIHelper.SKIP:
            self.confirmation_date =\
                 APIHelper.apply_datetime_converter(
                confirmation_date, APIHelper.RFC3339DateTime)\
                 if confirmation_date else None

    @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
        reservation_id =\
            dictionary.get("ReservationId")\
            if dictionary.get("ReservationId")\
                else APIHelper.SKIP
        reservation_external_id =\
            dictionary.get("ReservationExternalId")\
            if dictionary.get("ReservationExternalId")\
                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
        member_external_id =\
            dictionary.get("MemberExternalId")\
            if dictionary.get("MemberExternalId")\
                else APIHelper.SKIP
        reservation_type =\
            dictionary.get("ReservationType")\
            if dictionary.get("ReservationType")\
                else APIHelper.SKIP
        spots =\
            Spot.from_dictionary(
                dictionary.get("Spots"))\
                if "Spots" in dictionary.keys()\
                else APIHelper.SKIP
        is_confirmed =\
            dictionary.get("IsConfirmed")\
            if "IsConfirmed" in dictionary.keys()\
                else APIHelper.SKIP
        confirmation_date = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("ConfirmationDate")).datetime\
            if dictionary.get("ConfirmationDate") else APIHelper.SKIP

        # Return an object of this model
        return cls(reservation_id,
                   reservation_external_id,
                   class_id,
                   class_external_id,
                   member_external_id,
                   reservation_type,
                   spots,
                   is_confirmed,
                   confirmation_date)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _reservation_id=(
            self.reservation_id
            if hasattr(self, "reservation_id")
            else None
        )
        _reservation_external_id=(
            self.reservation_external_id
            if hasattr(self, "reservation_external_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
        )
        _member_external_id=(
            self.member_external_id
            if hasattr(self, "member_external_id")
            else None
        )
        _reservation_type=(
            self.reservation_type
            if hasattr(self, "reservation_type")
            else None
        )
        _spots=(
            self.spots
            if hasattr(self, "spots")
            else None
        )
        _is_confirmed=(
            self.is_confirmed
            if hasattr(self, "is_confirmed")
            else None
        )
        _confirmation_date=(
            self.confirmation_date
            if hasattr(self, "confirmation_date")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"reservation_id={_reservation_id!r}, "
            f"reservation_external_id={_reservation_external_id!r}, "
            f"class_id={_class_id!r}, "
            f"class_external_id={_class_external_id!r}, "
            f"member_external_id={_member_external_id!r}, "
            f"reservation_type={_reservation_type!r}, "
            f"spots={_spots!r}, "
            f"is_confirmed={_is_confirmed!r}, "
            f"confirmation_date={_confirmation_date!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _reservation_id=(
            self.reservation_id
            if hasattr(self, "reservation_id")
            else None
        )
        _reservation_external_id=(
            self.reservation_external_id
            if hasattr(self, "reservation_external_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
        )
        _member_external_id=(
            self.member_external_id
            if hasattr(self, "member_external_id")
            else None
        )
        _reservation_type=(
            self.reservation_type
            if hasattr(self, "reservation_type")
            else None
        )
        _spots=(
            self.spots
            if hasattr(self, "spots")
            else None
        )
        _is_confirmed=(
            self.is_confirmed
            if hasattr(self, "is_confirmed")
            else None
        )
        _confirmation_date=(
            self.confirmation_date
            if hasattr(self, "confirmation_date")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"reservation_id={_reservation_id!s}, "
            f"reservation_external_id={_reservation_external_id!s}, "
            f"class_id={_class_id!s}, "
            f"class_external_id={_class_external_id!s}, "
            f"member_external_id={_member_external_id!s}, "
            f"reservation_type={_reservation_type!s}, "
            f"spots={_spots!s}, "
            f"is_confirmed={_is_confirmed!s}, "
            f"confirmation_date={_confirmation_date!s}, "
            f")"
        )
