"""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.client import (
    Client,
)
from mindbodypublicapi.models.contact_log_comment import (
    ContactLogComment,
)
from mindbodypublicapi.models.contact_log_type import (
    ContactLogType,
)
from mindbodypublicapi.models.staff import Staff


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

    A contact log.

    Attributes:
        id (int): The contact log’s ID.
        text (str): The contact log’s body text.
        created_date_time (datetime): The local date and time when the contact log
            was created.
        followup_by_date (datetime): The date by which the assigned staff member
            should close or follow up on this contact log.
        contact_method (str): The method by which the client wants to be contacted.
        contact_name (str): The name of the client to contact.
        client (Client): The Client.
        created_by (Staff): The Staff
        assigned_to (Staff): The Staff
        comments (List[ContactLogComment]): Information about the comment.
        types (List[ContactLogType]): Information about the type of contact log.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "id": "Id",
        "text": "Text",
        "created_date_time": "CreatedDateTime",
        "followup_by_date": "FollowupByDate",
        "contact_method": "ContactMethod",
        "contact_name": "ContactName",
        "client": "Client",
        "created_by": "CreatedBy",
        "assigned_to": "AssignedTo",
        "comments": "Comments",
        "types": "Types",
    }

    _optionals = [
        "id",
        "text",
        "created_date_time",
        "followup_by_date",
        "contact_method",
        "contact_name",
        "client",
        "created_by",
        "assigned_to",
        "comments",
        "types",
    ]

    def __init__(
        self,
        id=APIHelper.SKIP,
        text=APIHelper.SKIP,
        created_date_time=APIHelper.SKIP,
        followup_by_date=APIHelper.SKIP,
        contact_method=APIHelper.SKIP,
        contact_name=APIHelper.SKIP,
        client=APIHelper.SKIP,
        created_by=APIHelper.SKIP,
        assigned_to=APIHelper.SKIP,
        comments=APIHelper.SKIP,
        types=APIHelper.SKIP):
        """Initialize a ContactLog 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 followup_by_date is not APIHelper.SKIP:
            self.followup_by_date =\
                 APIHelper.apply_datetime_converter(
                followup_by_date, APIHelper.RFC3339DateTime)\
                 if followup_by_date else None
        if contact_method is not APIHelper.SKIP:
            self.contact_method = contact_method
        if contact_name is not APIHelper.SKIP:
            self.contact_name = contact_name
        if client is not APIHelper.SKIP:
            self.client = client
        if created_by is not APIHelper.SKIP:
            self.created_by = created_by
        if assigned_to is not APIHelper.SKIP:
            self.assigned_to = assigned_to
        if comments is not APIHelper.SKIP:
            self.comments = comments
        if types is not APIHelper.SKIP:
            self.types = types

    @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
        followup_by_date = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("FollowupByDate")).datetime\
            if dictionary.get("FollowupByDate") else APIHelper.SKIP
        contact_method =\
            dictionary.get("ContactMethod")\
            if dictionary.get("ContactMethod")\
                else APIHelper.SKIP
        contact_name =\
            dictionary.get("ContactName")\
            if dictionary.get("ContactName")\
                else APIHelper.SKIP
        client =\
            Client.from_dictionary(
                dictionary.get("Client"))\
                if "Client" in dictionary.keys()\
                else APIHelper.SKIP
        created_by =\
            Staff.from_dictionary(
                dictionary.get("CreatedBy"))\
                if "CreatedBy" in dictionary.keys()\
                else APIHelper.SKIP
        assigned_to =\
            Staff.from_dictionary(
                dictionary.get("AssignedTo"))\
                if "AssignedTo" in dictionary.keys()\
                else APIHelper.SKIP
        comments = None
        if dictionary.get("Comments") is not None:
            comments = [
                ContactLogComment.from_dictionary(x)
                    for x in dictionary.get("Comments")
            ]
        else:
            comments = APIHelper.SKIP
        types = None
        if dictionary.get("Types") is not None:
            types = [
                ContactLogType.from_dictionary(x)
                    for x in dictionary.get("Types")
            ]
        else:
            types = APIHelper.SKIP

        # Return an object of this model
        return cls(id,
                   text,
                   created_date_time,
                   followup_by_date,
                   contact_method,
                   contact_name,
                   client,
                   created_by,
                   assigned_to,
                   comments,
                   types)

    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
        )
        _followup_by_date=(
            self.followup_by_date
            if hasattr(self, "followup_by_date")
            else None
        )
        _contact_method=(
            self.contact_method
            if hasattr(self, "contact_method")
            else None
        )
        _contact_name=(
            self.contact_name
            if hasattr(self, "contact_name")
            else None
        )
        _client=(
            self.client
            if hasattr(self, "client")
            else None
        )
        _created_by=(
            self.created_by
            if hasattr(self, "created_by")
            else None
        )
        _assigned_to=(
            self.assigned_to
            if hasattr(self, "assigned_to")
            else None
        )
        _comments=(
            self.comments
            if hasattr(self, "comments")
            else None
        )
        _types=(
            self.types
            if hasattr(self, "types")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"id={_id!r}, "
            f"text={_text!r}, "
            f"created_date_time={_created_date_time!r}, "
            f"followup_by_date={_followup_by_date!r}, "
            f"contact_method={_contact_method!r}, "
            f"contact_name={_contact_name!r}, "
            f"client={_client!r}, "
            f"created_by={_created_by!r}, "
            f"assigned_to={_assigned_to!r}, "
            f"comments={_comments!r}, "
            f"types={_types!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
        )
        _followup_by_date=(
            self.followup_by_date
            if hasattr(self, "followup_by_date")
            else None
        )
        _contact_method=(
            self.contact_method
            if hasattr(self, "contact_method")
            else None
        )
        _contact_name=(
            self.contact_name
            if hasattr(self, "contact_name")
            else None
        )
        _client=(
            self.client
            if hasattr(self, "client")
            else None
        )
        _created_by=(
            self.created_by
            if hasattr(self, "created_by")
            else None
        )
        _assigned_to=(
            self.assigned_to
            if hasattr(self, "assigned_to")
            else None
        )
        _comments=(
            self.comments
            if hasattr(self, "comments")
            else None
        )
        _types=(
            self.types
            if hasattr(self, "types")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"id={_id!s}, "
            f"text={_text!s}, "
            f"created_date_time={_created_date_time!s}, "
            f"followup_by_date={_followup_by_date!s}, "
            f"contact_method={_contact_method!s}, "
            f"contact_name={_contact_name!s}, "
            f"client={_client!s}, "
            f"created_by={_created_by!s}, "
            f"assigned_to={_assigned_to!s}, "
            f"comments={_comments!s}, "
            f"types={_types!s}, "
            f")"
        )
