o
    ˷e                     @   s<   d Z ddlmZ ddlmZ ddlmZ G dd deZdS )a  
The Conversation Messages API endpoint

Note: This is a paid feature

Documentation: http://developer.mailchimp.com/documentation/mailchimp/reference/conversations/messages/
Schema: https://api.mailchimp.com/schema/3.0/Conversations/Messages/Instance.json
    )unicode_literals)BaseApi)check_emailc                       s8   e Zd ZdZ fddZdd Zdd Zdd	 Z  ZS )
ConversationMessagesz>
    Manage messages in a specific campaign conversation.
    c                    s,   t t| j|i | d| _d| _d| _dS )z)
        Initialize the endpoint
        conversationsN)superr   __init__endpointconversation_id
message_id)selfargskwargs	__class__ _/var/www/ideatree/venv/lib/python3.10/site-packages/mailchimp3/entities/conversationmessages.pyr      s   
zConversationMessages.__init__c                 C   s~   || _ d|vrtdt|d  d|vrtd|d dvr#td| jj| |d|d}|d	ur:|d
 | _|S d	| _|S )a\  
        Post a new message to a conversation.

        :param conversation_id: The unique id for the conversation.
        :type conversation_id: :py:class:`str`
        :param data: The request body parameters
        :type data: :py:class:`dict`
        data = {
            "from_email": string*,
            "read": boolean*
        }
        
from_emailz/The conversation message must have a from_emailreadz)The conversation message must have a read)TFz3The conversation message read must be True or Falsemessages)urldataNid)r
   KeyErrorr   	TypeError
_mc_client_post_build_pathr   )r   r
   r   responser   r   r   create   s   
zConversationMessages.createc                 K   s*   || _ d| _| jjdd| |di|S )aX  
        Get messages from a specific conversation.

        This endpoint does not currently support count and offset, preventing
        it from having the get_all parameter that most all() methods have

        :param conversation_id: The unique id for the conversation.
        :type conversation_id: :py:class:`str`
        :param queryparams: The query string parameters
        queryparams['fields'] = []
        queryparams['exclude_fields'] = p[
        queryparams['is_read'] = string
        queryparams['before_timestamp'] = string
        queryparams['since_timestamp'] = string
        Nr   r   r   r
   r   r   _getr   )r   r
   queryparamsr   r   r   all=   s   zConversationMessages.allc                 K   s,   || _ || _| jjdd| |d|i|S )a  
        Get an individual message in a conversation.

        :param conversation_id: The unique id for the conversation.
        :type conversation_id: :py:class:`str`
        :param message_id: The unique id for the conversation message.
        :type message_id: :py:class:`str`
        :param queryparams: The query string parameters
        queryparams['fields'] = []
        queryparams['exclude_fields'] = []
        r   r   Nr   r    )r   r
   r   r"   r   r   r   getS   s    zConversationMessages.get)	__name__
__module____qualname____doc__r   r   r#   r$   __classcell__r   r   r   r   r      s    r   N)r(   
__future__r   mailchimp3.baseapir   mailchimp3.helpersr   r   r   r   r   r   <module>   s
   