"""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.location_1 import (
    Location1,
)
from mindbodypublicapi.models.program_1 import (
    Program1,
)
from mindbodypublicapi.models.resource_availability_1 import (
    ResourceAvailability1,
)
from mindbodypublicapi.models.session_type_1 import (
    SessionType1,
)
from mindbodypublicapi.models.staff_1 import (
    Staff1,
)


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

    The availability of a specific staff

    Attributes:
        id (int): Id of the availability
        staff (Staff1): The model property of type Staff1.
        session_type (SessionType1): The model property of type SessionType1.
        programs (List[Program1]): Availabilities program list.
        start_date_time (datetime): Availabilities start date and time.
        end_date_time (datetime): Availabilities end date and time.
        bookable_end_date_time (datetime): Availabilities bookable end date and time.
        location (Location1): The model property of type Location1.
        prep_time (int): Appointment prep time
        finish_time (int): Appointment finish time
        is_masked (bool): The model property of type bool.
        show_public (bool): The model property of type bool.
        resource_availabilities (List[ResourceAvailability1]): List of resource
            availabilities that can be booked with this session type.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "id": "Id",
        "staff": "Staff",
        "session_type": "SessionType",
        "programs": "Programs",
        "start_date_time": "StartDateTime",
        "end_date_time": "EndDateTime",
        "bookable_end_date_time": "BookableEndDateTime",
        "location": "Location",
        "prep_time": "PrepTime",
        "finish_time": "FinishTime",
        "is_masked": "IsMasked",
        "show_public": "ShowPublic",
        "resource_availabilities": "ResourceAvailabilities",
    }

    _optionals = [
        "id",
        "staff",
        "session_type",
        "programs",
        "start_date_time",
        "end_date_time",
        "bookable_end_date_time",
        "location",
        "prep_time",
        "finish_time",
        "is_masked",
        "show_public",
        "resource_availabilities",
    ]

    def __init__(
        self,
        id=APIHelper.SKIP,
        staff=APIHelper.SKIP,
        session_type=APIHelper.SKIP,
        programs=APIHelper.SKIP,
        start_date_time=APIHelper.SKIP,
        end_date_time=APIHelper.SKIP,
        bookable_end_date_time=APIHelper.SKIP,
        location=APIHelper.SKIP,
        prep_time=APIHelper.SKIP,
        finish_time=APIHelper.SKIP,
        is_masked=APIHelper.SKIP,
        show_public=APIHelper.SKIP,
        resource_availabilities=APIHelper.SKIP):
        """Initialize a Availability1 instance."""
        # Initialize members of the class
        if id is not APIHelper.SKIP:
            self.id = id
        if staff is not APIHelper.SKIP:
            self.staff = staff
        if session_type is not APIHelper.SKIP:
            self.session_type = session_type
        if programs is not APIHelper.SKIP:
            self.programs = programs
        if start_date_time is not APIHelper.SKIP:
            self.start_date_time =\
                 APIHelper.apply_datetime_converter(
                start_date_time, APIHelper.RFC3339DateTime)\
                 if start_date_time else None
        if end_date_time is not APIHelper.SKIP:
            self.end_date_time =\
                 APIHelper.apply_datetime_converter(
                end_date_time, APIHelper.RFC3339DateTime)\
                 if end_date_time else None
        if bookable_end_date_time is not APIHelper.SKIP:
            self.bookable_end_date_time =\
                 APIHelper.apply_datetime_converter(
                bookable_end_date_time, APIHelper.RFC3339DateTime)\
                 if bookable_end_date_time else None
        if location is not APIHelper.SKIP:
            self.location = location
        if prep_time is not APIHelper.SKIP:
            self.prep_time = prep_time
        if finish_time is not APIHelper.SKIP:
            self.finish_time = finish_time
        if is_masked is not APIHelper.SKIP:
            self.is_masked = is_masked
        if show_public is not APIHelper.SKIP:
            self.show_public = show_public
        if resource_availabilities is not APIHelper.SKIP:
            self.resource_availabilities = resource_availabilities

    @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
        staff =\
            Staff1.from_dictionary(
                dictionary.get("Staff"))\
                if "Staff" in dictionary.keys()\
                else APIHelper.SKIP
        session_type =\
            SessionType1.from_dictionary(
                dictionary.get("SessionType"))\
                if "SessionType" in dictionary.keys()\
                else APIHelper.SKIP
        programs = None
        if dictionary.get("Programs") is not None:
            programs = [
                Program1.from_dictionary(x)
                    for x in dictionary.get("Programs")
            ]
        else:
            programs = APIHelper.SKIP
        start_date_time = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("StartDateTime")).datetime\
            if dictionary.get("StartDateTime") else APIHelper.SKIP
        end_date_time = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("EndDateTime")).datetime\
            if dictionary.get("EndDateTime") else APIHelper.SKIP
        bookable_end_date_time = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("BookableEndDateTime")).datetime\
            if dictionary.get("BookableEndDateTime") else APIHelper.SKIP
        location =\
            Location1.from_dictionary(
                dictionary.get("Location"))\
                if "Location" in dictionary.keys()\
                else APIHelper.SKIP
        prep_time =\
            dictionary.get("PrepTime")\
            if dictionary.get("PrepTime")\
                else APIHelper.SKIP
        finish_time =\
            dictionary.get("FinishTime")\
            if dictionary.get("FinishTime")\
                else APIHelper.SKIP
        is_masked =\
            dictionary.get("IsMasked")\
            if "IsMasked" in dictionary.keys()\
                else APIHelper.SKIP
        show_public =\
            dictionary.get("ShowPublic")\
            if "ShowPublic" in dictionary.keys()\
                else APIHelper.SKIP
        resource_availabilities = None
        if dictionary.get("ResourceAvailabilities") is not None:
            resource_availabilities = [
                ResourceAvailability1.from_dictionary(x)
                    for x in dictionary.get("ResourceAvailabilities")
            ]
        else:
            resource_availabilities = APIHelper.SKIP

        # Return an object of this model
        return cls(id,
                   staff,
                   session_type,
                   programs,
                   start_date_time,
                   end_date_time,
                   bookable_end_date_time,
                   location,
                   prep_time,
                   finish_time,
                   is_masked,
                   show_public,
                   resource_availabilities)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _id=(
            self.id
            if hasattr(self, "id")
            else None
        )
        _staff=(
            self.staff
            if hasattr(self, "staff")
            else None
        )
        _session_type=(
            self.session_type
            if hasattr(self, "session_type")
            else None
        )
        _programs=(
            self.programs
            if hasattr(self, "programs")
            else None
        )
        _start_date_time=(
            self.start_date_time
            if hasattr(self, "start_date_time")
            else None
        )
        _end_date_time=(
            self.end_date_time
            if hasattr(self, "end_date_time")
            else None
        )
        _bookable_end_date_time=(
            self.bookable_end_date_time
            if hasattr(self, "bookable_end_date_time")
            else None
        )
        _location=(
            self.location
            if hasattr(self, "location")
            else None
        )
        _prep_time=(
            self.prep_time
            if hasattr(self, "prep_time")
            else None
        )
        _finish_time=(
            self.finish_time
            if hasattr(self, "finish_time")
            else None
        )
        _is_masked=(
            self.is_masked
            if hasattr(self, "is_masked")
            else None
        )
        _show_public=(
            self.show_public
            if hasattr(self, "show_public")
            else None
        )
        _resource_availabilities=(
            self.resource_availabilities
            if hasattr(self, "resource_availabilities")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"id={_id!r}, "
            f"staff={_staff!r}, "
            f"session_type={_session_type!r}, "
            f"programs={_programs!r}, "
            f"start_date_time={_start_date_time!r}, "
            f"end_date_time={_end_date_time!r}, "
            f"bookable_end_date_time={_bookable_end_date_time!r}, "
            f"location={_location!r}, "
            f"prep_time={_prep_time!r}, "
            f"finish_time={_finish_time!r}, "
            f"is_masked={_is_masked!r}, "
            f"show_public={_show_public!r}, "
            f"resource_availabilities={_resource_availabilities!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _id=(
            self.id
            if hasattr(self, "id")
            else None
        )
        _staff=(
            self.staff
            if hasattr(self, "staff")
            else None
        )
        _session_type=(
            self.session_type
            if hasattr(self, "session_type")
            else None
        )
        _programs=(
            self.programs
            if hasattr(self, "programs")
            else None
        )
        _start_date_time=(
            self.start_date_time
            if hasattr(self, "start_date_time")
            else None
        )
        _end_date_time=(
            self.end_date_time
            if hasattr(self, "end_date_time")
            else None
        )
        _bookable_end_date_time=(
            self.bookable_end_date_time
            if hasattr(self, "bookable_end_date_time")
            else None
        )
        _location=(
            self.location
            if hasattr(self, "location")
            else None
        )
        _prep_time=(
            self.prep_time
            if hasattr(self, "prep_time")
            else None
        )
        _finish_time=(
            self.finish_time
            if hasattr(self, "finish_time")
            else None
        )
        _is_masked=(
            self.is_masked
            if hasattr(self, "is_masked")
            else None
        )
        _show_public=(
            self.show_public
            if hasattr(self, "show_public")
            else None
        )
        _resource_availabilities=(
            self.resource_availabilities
            if hasattr(self, "resource_availabilities")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"id={_id!s}, "
            f"staff={_staff!s}, "
            f"session_type={_session_type!s}, "
            f"programs={_programs!s}, "
            f"start_date_time={_start_date_time!s}, "
            f"end_date_time={_end_date_time!s}, "
            f"bookable_end_date_time={_bookable_end_date_time!s}, "
            f"location={_location!s}, "
            f"prep_time={_prep_time!s}, "
            f"finish_time={_finish_time!s}, "
            f"is_masked={_is_masked!s}, "
            f"show_public={_show_public!s}, "
            f"resource_availabilities={_resource_availabilities!s}, "
            f")"
        )
