"""mindbodypublicapi.

This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
"""

# ruff: noqa: E501
from mindbodypublicapi.api_helper import APIHelper


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

    An availability of a resource

    Attributes:
        resource_id (int): Id
        start_date_time (datetime): Starts
        end_date_time (datetime): Ends
        session_type_ids (List[int]): List of SessionTypeIds that this availability
            is restricted to. If empty, no restrictions.
        program_ids (List[int]): List of ProgramIds that this availability is
            restricted to. If empty, no restrictions.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "resource_id": "ResourceId",
        "start_date_time": "StartDateTime",
        "end_date_time": "EndDateTime",
        "session_type_ids": "SessionTypeIds",
        "program_ids": "ProgramIds",
    }

    _optionals = [
        "resource_id",
        "start_date_time",
        "end_date_time",
        "session_type_ids",
        "program_ids",
    ]

    def __init__(
        self,
        resource_id=APIHelper.SKIP,
        start_date_time=APIHelper.SKIP,
        end_date_time=APIHelper.SKIP,
        session_type_ids=APIHelper.SKIP,
        program_ids=APIHelper.SKIP):
        """Initialize a ResourceAvailability1 instance."""
        # Initialize members of the class
        if resource_id is not APIHelper.SKIP:
            self.resource_id = resource_id
        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 session_type_ids is not APIHelper.SKIP:
            self.session_type_ids = session_type_ids
        if program_ids is not APIHelper.SKIP:
            self.program_ids = program_ids

    @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
        resource_id =\
            dictionary.get("ResourceId")\
            if dictionary.get("ResourceId")\
                else 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
        session_type_ids =\
            dictionary.get("SessionTypeIds")\
            if dictionary.get("SessionTypeIds")\
                else APIHelper.SKIP
        program_ids =\
            dictionary.get("ProgramIds")\
            if dictionary.get("ProgramIds")\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(resource_id,
                   start_date_time,
                   end_date_time,
                   session_type_ids,
                   program_ids)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _resource_id=(
            self.resource_id
            if hasattr(self, "resource_id")
            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
        )
        _session_type_ids=(
            self.session_type_ids
            if hasattr(self, "session_type_ids")
            else None
        )
        _program_ids=(
            self.program_ids
            if hasattr(self, "program_ids")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"resource_id={_resource_id!r}, "
            f"start_date_time={_start_date_time!r}, "
            f"end_date_time={_end_date_time!r}, "
            f"session_type_ids={_session_type_ids!r}, "
            f"program_ids={_program_ids!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _resource_id=(
            self.resource_id
            if hasattr(self, "resource_id")
            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
        )
        _session_type_ids=(
            self.session_type_ids
            if hasattr(self, "session_type_ids")
            else None
        )
        _program_ids=(
            self.program_ids
            if hasattr(self, "program_ids")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"resource_id={_resource_id!s}, "
            f"start_date_time={_start_date_time!s}, "
            f"end_date_time={_end_date_time!s}, "
            f"session_type_ids={_session_type_ids!s}, "
            f"program_ids={_program_ids!s}, "
            f")"
        )
