"""cellpointapi.

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

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


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

    Represents a note associated with a specific entity, such as a transaction or
    order.

    Attributes:
        id (str): Unique identifier for the note.
        entity_type (str): Type of the entity associated with the note, such as
            "PAYMENT_EVENT" or "ORDER".
        entity_id (str): Unique identifier of the entity associated with the note,
            such as an order or transaction.
        text (str): The text content of the note.
        created_at (datetime): The date and time when the note was created.
        created_by (str): Identifier of the user or system that created the note.
        action_type (str): Type of action associated with the note, such as "CREATE",
            "UPDATE", or "DELETE".
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "id": "id",
        "entity_type": "entityType",
        "entity_id": "entityId",
        "text": "text",
        "created_at": "createdAt",
        "created_by": "createdBy",
        "action_type": "actionType",
    }

    _optionals = [
        "action_type",
    ]

    def __init__(
        self,
        id=None,
        entity_type=None,
        entity_id=None,
        text=None,
        created_at=None,
        created_by=None,
        action_type=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a Note instance."""
        # Initialize members of the class
        self.id = id
        self.entity_type = entity_type
        self.entity_id = entity_id
        self.text = text
        self.created_at =\
             APIHelper.apply_datetime_converter(
            created_at, APIHelper.RFC3339DateTime)\
             if created_at else None
        self.created_by = created_by
        if action_type is not APIHelper.SKIP:
            self.action_type = action_type

        # Add additional model properties to the instance
        if additional_properties is None:
            additional_properties = {}
        self.additional_properties = additional_properties

    @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 None
        entity_type =\
            dictionary.get("entityType")\
            if dictionary.get("entityType")\
                else None
        entity_id =\
            dictionary.get("entityId")\
            if dictionary.get("entityId")\
                else None
        text =\
            dictionary.get("text")\
            if dictionary.get("text")\
                else None
        created_at = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("createdAt")).datetime\
            if dictionary.get("createdAt") else None
        created_by =\
            dictionary.get("createdBy")\
            if dictionary.get("createdBy")\
                else None
        action_type =\
            dictionary.get("actionType")\
            if dictionary.get("actionType")\
                else APIHelper.SKIP

        additional_properties = APIHelper.get_additional_properties(
            dictionary={k: v for k, v in dictionary.items()
                        if k not in cls._names.values()},
            unboxing_function=lambda value: value)

        # Return an object of this model
        return cls(id,
                   entity_type,
                   entity_id,
                   text,
                   created_at,
                   created_by,
                   action_type,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _id=self.id
        _entity_type=self.entity_type
        _entity_id=self.entity_id
        _text=self.text
        _created_at=self.created_at
        _created_by=self.created_by
        _action_type=(
            self.action_type
            if hasattr(self, "action_type")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"id={_id!r}, "
            f"entity_type={_entity_type!r}, "
            f"entity_id={_entity_id!r}, "
            f"text={_text!r}, "
            f"created_at={_created_at!r}, "
            f"created_by={_created_by!r}, "
            f"action_type={_action_type!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _id=self.id
        _entity_type=self.entity_type
        _entity_id=self.entity_id
        _text=self.text
        _created_at=self.created_at
        _created_by=self.created_by
        _action_type=(
            self.action_type
            if hasattr(self, "action_type")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"id={_id!s}, "
            f"entity_type={_entity_type!s}, "
            f"entity_id={_entity_id!s}, "
            f"text={_text!s}, "
            f"created_at={_created_at!s}, "
            f"created_by={_created_by!s}, "
            f"action_type={_action_type!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
