"""mindbodypublicapi.

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

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


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

    Attributes:
        agreement_date (datetime): The date and time at which the client agreed to
            the liability waiver for the business.
        is_released (bool): The client’s liability release status.<br />  When
            `true`, indicates that the client has agreed to the liability release for
            the business.<br />  When `false`, indicates that the client has not
            agreed to the liability release for the business.
        released_by (int): An ID indicating who released liability for the client. If
            the client agreed to the liability waiver by signing into an account
            online, this value is `null`. If a staff member marked the waiver as
            signed on behalf of the client, it is the staff member’s ID. `0`
            indicates that the business owner marked the liability waiver as signed
            on behalf of the client.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "agreement_date": "AgreementDate",
        "is_released": "IsReleased",
        "released_by": "ReleasedBy",
    }

    _optionals = [
        "agreement_date",
        "is_released",
        "released_by",
    ]

    def __init__(
        self,
        agreement_date=APIHelper.SKIP,
        is_released=APIHelper.SKIP,
        released_by=APIHelper.SKIP):
        """Initialize a Liability instance."""
        # Initialize members of the class
        if agreement_date is not APIHelper.SKIP:
            self.agreement_date =\
                 APIHelper.apply_datetime_converter(
                agreement_date, APIHelper.RFC3339DateTime)\
                 if agreement_date else None
        if is_released is not APIHelper.SKIP:
            self.is_released = is_released
        if released_by is not APIHelper.SKIP:
            self.released_by = released_by

    @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
        agreement_date = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("AgreementDate")).datetime\
            if dictionary.get("AgreementDate") else APIHelper.SKIP
        is_released =\
            dictionary.get("IsReleased")\
            if "IsReleased" in dictionary.keys()\
                else APIHelper.SKIP
        released_by =\
            dictionary.get("ReleasedBy")\
            if dictionary.get("ReleasedBy")\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(agreement_date,
                   is_released,
                   released_by)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _agreement_date=(
            self.agreement_date
            if hasattr(self, "agreement_date")
            else None
        )
        _is_released=(
            self.is_released
            if hasattr(self, "is_released")
            else None
        )
        _released_by=(
            self.released_by
            if hasattr(self, "released_by")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"agreement_date={_agreement_date!r}, "
            f"is_released={_is_released!r}, "
            f"released_by={_released_by!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _agreement_date=(
            self.agreement_date
            if hasattr(self, "agreement_date")
            else None
        )
        _is_released=(
            self.is_released
            if hasattr(self, "is_released")
            else None
        )
        _released_by=(
            self.released_by
            if hasattr(self, "released_by")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"agreement_date={_agreement_date!s}, "
            f"is_released={_is_released!s}, "
            f"released_by={_released_by!s}, "
            f")"
        )
