"""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.pagination import (
    Pagination,
)
from mindbodypublicapi.models.reservation import (
    Reservation,
)
from mindbodypublicapi.models.response_details import (
    ResponseDetails,
)


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

    Contains information about the get reservation response

    Attributes:
        reservations (List[Reservation]): Contains information about the reservation
            details.
        pagination (Pagination): Contains information about the pagination used.
        response_details (ResponseDetails): Contains information about the response
            message detail.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "reservations": "Reservations",
        "pagination": "Pagination",
        "response_details": "ResponseDetails",
    }

    _optionals = [
        "reservations",
        "pagination",
        "response_details",
    ]

    def __init__(
        self,
        reservations=APIHelper.SKIP,
        pagination=APIHelper.SKIP,
        response_details=APIHelper.SKIP):
        """Initialize a GetReservationResponse instance."""
        # Initialize members of the class
        if reservations is not APIHelper.SKIP:
            self.reservations = reservations
        if pagination is not APIHelper.SKIP:
            self.pagination = pagination
        if response_details is not APIHelper.SKIP:
            self.response_details = response_details

    @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
        reservations = None
        if dictionary.get("Reservations") is not None:
            reservations = [
                Reservation.from_dictionary(x)
                    for x in dictionary.get("Reservations")
            ]
        else:
            reservations = APIHelper.SKIP
        pagination =\
            Pagination.from_dictionary(
                dictionary.get("Pagination"))\
                if "Pagination" in dictionary.keys()\
                else APIHelper.SKIP
        response_details =\
            ResponseDetails.from_dictionary(
                dictionary.get("ResponseDetails"))\
                if "ResponseDetails" in dictionary.keys()\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(reservations,
                   pagination,
                   response_details)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _reservations=(
            self.reservations
            if hasattr(self, "reservations")
            else None
        )
        _pagination=(
            self.pagination
            if hasattr(self, "pagination")
            else None
        )
        _response_details=(
            self.response_details
            if hasattr(self, "response_details")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"reservations={_reservations!r}, "
            f"pagination={_pagination!r}, "
            f"response_details={_response_details!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _reservations=(
            self.reservations
            if hasattr(self, "reservations")
            else None
        )
        _pagination=(
            self.pagination
            if hasattr(self, "pagination")
            else None
        )
        _response_details=(
            self.response_details
            if hasattr(self, "response_details")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"reservations={_reservations!s}, "
            f"pagination={_pagination!s}, "
            f"response_details={_response_details!s}, "
            f")"
        )
