"""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.staff import Staff


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

    A contact log comment.

    Attributes:
        id (int): The comment’s ID.
        text (str): The comment’s body text.
        created_date_time (datetime): The local time when the comment was created.
        created_by (Staff): The Staff

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "id": "Id",
        "text": "Text",
        "created_date_time": "CreatedDateTime",
        "created_by": "CreatedBy",
    }

    _optionals = [
        "id",
        "text",
        "created_date_time",
        "created_by",
    ]

    def __init__(
        self,
        id=APIHelper.SKIP,
        text=APIHelper.SKIP,
        created_date_time=APIHelper.SKIP,
        created_by=APIHelper.SKIP):
        """Initialize a ContactLogComment instance."""
        # Initialize members of the class
        if id is not APIHelper.SKIP:
            self.id = id
        if text is not APIHelper.SKIP:
            self.text = text
        if created_date_time is not APIHelper.SKIP:
            self.created_date_time =\
                 APIHelper.apply_datetime_converter(
                created_date_time, APIHelper.RFC3339DateTime)\
                 if created_date_time else None
        if created_by is not APIHelper.SKIP:
            self.created_by = created_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
        id =\
            dictionary.get("Id")\
            if dictionary.get("Id")\
                else APIHelper.SKIP
        text =\
            dictionary.get("Text")\
            if dictionary.get("Text")\
                else APIHelper.SKIP
        created_date_time = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("CreatedDateTime")).datetime\
            if dictionary.get("CreatedDateTime") else APIHelper.SKIP
        created_by =\
            Staff.from_dictionary(
                dictionary.get("CreatedBy"))\
                if "CreatedBy" in dictionary.keys()\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(id,
                   text,
                   created_date_time,
                   created_by)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _id=(
            self.id
            if hasattr(self, "id")
            else None
        )
        _text=(
            self.text
            if hasattr(self, "text")
            else None
        )
        _created_date_time=(
            self.created_date_time
            if hasattr(self, "created_date_time")
            else None
        )
        _created_by=(
            self.created_by
            if hasattr(self, "created_by")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"id={_id!r}, "
            f"text={_text!r}, "
            f"created_date_time={_created_date_time!r}, "
            f"created_by={_created_by!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _id=(
            self.id
            if hasattr(self, "id")
            else None
        )
        _text=(
            self.text
            if hasattr(self, "text")
            else None
        )
        _created_date_time=(
            self.created_date_time
            if hasattr(self, "created_date_time")
            else None
        )
        _created_by=(
            self.created_by
            if hasattr(self, "created_by")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"id={_id!s}, "
            f"text={_text!s}, "
            f"created_date_time={_created_date_time!s}, "
            f"created_by={_created_by!s}, "
            f")"
        )
