o
    e6U                     @   s   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ G d	d
 d
e
ZG dd deZG dd deZG dd deZdS )za
This code was generated by
\ / _    _  _|   _  _
 | (_)\/(_)(_|\/| |(/_  v1.0.0
      /       /
    )deserialize)	serialize)values)InstanceContext)InstanceResource)ListResource)Pagec                       s   e Zd Z fddZejejejejejejejejfddZejddfddZejddfdd	Zejejejejfd
dZ	dd Z
dd Zdd Zdd Z  ZS )MessageListc                    s4   t t| | ||d| _djdi | j| _dS )a  
        Initialize the MessageList

        :param Version version: Version that contains the resource
        :param service_sid: The SID of the Service that the resource is associated with
        :param channel_sid: The SID of the Channel the Message resource belongs to

        :returns: twilio.rest.chat.v2.service.channel.message.MessageList
        :rtype: twilio.rest.chat.v2.service.channel.message.MessageList
        service_sidchannel_sidz7/Services/{service_sid}/Channels/{channel_sid}/MessagesN )superr	   __init__	_solutionformat_uri)selfversionr   r   	__class__r   ^/var/www/html/venv/lib/python3.10/site-packages/twilio/rest/chat/v2/service/channel/message.pyr      s   zMessageList.__init__c	              
   C   sh   t ||t|t||||d}	t d|i}
| jjd| j|	|
d}t| j|| jd | jd dS )a  
        Create the MessageInstance

        :param unicode from_: The Identity of the new message's author
        :param unicode attributes: A valid JSON string that contains application-specific data
        :param datetime date_created: The ISO 8601 date and time in GMT when the resource was created
        :param datetime date_updated: The ISO 8601 date and time in GMT when the resource was updated
        :param unicode last_updated_by: The Identity of the User who last updated the Message
        :param unicode body: The message to send to the channel
        :param unicode media_sid:  The Media Sid to be attached to the new Message
        :param MessageInstance.WebhookEnabledType x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header

        :returns: The created MessageInstance
        :rtype: twilio.rest.chat.v2.service.channel.message.MessageInstance
        )From
AttributesDateCreatedDateUpdatedLastUpdatedByBodyMediaSidX-Twilio-Webhook-EnabledPOSTmethoduridataheadersr   r   r
   )	r   ofr   iso8601_datetime_versioncreater   MessageInstancer   )r   from_
attributesdate_createddate_updatedlast_updated_bybody	media_sidx_twilio_webhook_enabledr$   r%   payloadr   r   r   r)   %   s"   	zMessageList.createNc                 C   s2   | j ||}| j||d d}| j ||d S )a  
        Streams MessageInstance records from the API as a generator stream.
        This operation lazily loads records as efficiently as possible until the limit
        is reached.
        The results are returned as a generator, so this operation is memory efficient.

        :param MessageInstance.OrderType order: The sort order of the returned messages
        :param int limit: Upper limit for the number of records to return. stream()
                          guarantees to never return more than limit.  Default is no limit
        :param int page_size: Number of records to fetch per request, when not set will use
                              the default value of 50 records.  If no page_size is defined
                              but a limit is defined, stream() will attempt to read the
                              limit with the most efficient page size, i.e. min(limit, 1000)

        :returns: Generator that will yield up to limit results
        :rtype: list[twilio.rest.chat.v2.service.channel.message.MessageInstance]
        	page_size)orderr4   limit)r(   read_limitspagestream)r   r5   r6   r4   limitsr8   r   r   r   r9   L   s   zMessageList.streamc                 C   s   t | j|||dS )a  
        Lists MessageInstance records from the API as a list.
        Unlike stream(), this operation is eager and will load `limit` records into
        memory before returning.

        :param MessageInstance.OrderType order: The sort order of the returned messages
        :param int limit: Upper limit for the number of records to return. list() guarantees
                          never to return more than limit.  Default is no limit
        :param int page_size: Number of records to fetch per request, when not set will use
                              the default value of 50 records.  If no page_size is defined
                              but a limit is defined, list() will attempt to read the limit
                              with the most efficient page size, i.e. min(limit, 1000)

        :returns: Generator that will yield up to limit results
        :rtype: list[twilio.rest.chat.v2.service.channel.message.MessageInstance]
        )r5   r6   r4   )listr9   )r   r5   r6   r4   r   r   r   r;   d   s   zMessageList.listc                 C   s8   t ||||d}| jjd| j|d}t| j|| jS )a  
        Retrieve a single page of MessageInstance records from the API.
        Request is executed immediately

        :param MessageInstance.OrderType order: The sort order of the returned messages
        :param str page_token: PageToken provided by the API
        :param int page_number: Page Number, this value is simply for client state
        :param int page_size: Number of records to return, defaults to 50

        :returns: Page of MessageInstance
        :rtype: twilio.rest.chat.v2.service.channel.message.MessagePage
        )Order	PageTokenr   PageSizeGET)r"   r#   params)r   r&   r(   r8   r   MessagePager   )r   r5   
page_tokenpage_numberr4   r$   responser   r   r   r8   w   s   zMessageList.pagec                 C   s"   | j jjd|}t| j || jS )a?  
        Retrieve a specific page of MessageInstance records from the API.
        Request is executed immediately

        :param str target_url: API-generated URL for the requested results page

        :returns: Page of MessageInstance
        :rtype: twilio.rest.chat.v2.service.channel.message.MessagePage
        r?   )r(   domaintwiliorequestrA   r   )r   
target_urlrD   r   r   r   get_page   s
   

zMessageList.get_pagec                 C      t | j| jd | jd |dS a  
        Constructs a MessageContext

        :param sid: The SID of the Message resource to fetch

        :returns: twilio.rest.chat.v2.service.channel.message.MessageContext
        :rtype: twilio.rest.chat.v2.service.channel.message.MessageContext
        r   r   r   r   sidMessageContextr(   r   r   rM   r   r   r   get      	zMessageList.getc                 C   rJ   rK   rN   rP   r   r   r   __call__   rR   zMessageList.__call__c                 C      dS )z
        Provide a friendly representation

        :returns: Machine friendly representation
        :rtype: str
        z<Twilio.Chat.V2.MessageList>r   r   r   r   r   __repr__      zMessageList.__repr__)__name__
__module____qualname__r   r   unsetr)   r9   r;   r8   rI   rQ   rS   rW   __classcell__r   r   r   r   r	      s     
'
r	   c                       s,   e Zd Z fddZdd Zdd Z  ZS )rA   c                    s   t t| || || _dS )a  
        Initialize the MessagePage

        :param Version version: Version that contains the resource
        :param Response response: Response from the API
        :param service_sid: The SID of the Service that the resource is associated with
        :param channel_sid: The SID of the Channel the Message resource belongs to

        :returns: twilio.rest.chat.v2.service.channel.message.MessagePage
        :rtype: twilio.rest.chat.v2.service.channel.message.MessagePage
        N)r   rA   r   r   )r   r   rD   solutionr   r   r   r      s   
zMessagePage.__init__c                 C   s   t | j|| jd | jd dS )a  
        Build an instance of MessageInstance

        :param dict payload: Payload response from the API

        :returns: twilio.rest.chat.v2.service.channel.message.MessageInstance
        :rtype: twilio.rest.chat.v2.service.channel.message.MessageInstance
        r   r   r
   )r*   r(   r   r   r3   r   r   r   get_instance   s   	zMessagePage.get_instancec                 C   rT   )rU   z<Twilio.Chat.V2.MessagePage>r   rV   r   r   r   rW      rX   zMessagePage.__repr__)rY   rZ   r[   r   r`   rW   r]   r   r   r   r   rA      s    rA   c                       s`   e Zd Z fddZdd ZejfddZejejejejejejejfddZd	d
 Z	  Z
S )rO   c                    s6   t t| | |||d| _djdi | j| _dS )a  
        Initialize the MessageContext

        :param Version version: Version that contains the resource
        :param service_sid: The SID of the Service to fetch the resource from
        :param channel_sid: The SID of the Channel the message to fetch belongs to
        :param sid: The SID of the Message resource to fetch

        :returns: twilio.rest.chat.v2.service.channel.message.MessageContext
        :rtype: twilio.rest.chat.v2.service.channel.message.MessageContext
        rL   z=/Services/{service_sid}/Channels/{channel_sid}/Messages/{sid}Nr   )r   rO   r   r   r   r   )r   r   r   r   rM   r   r   r   r      s   zMessageContext.__init__c                 C   s8   | j jd| jd}t| j || jd | jd | jd dS )
        Fetch the MessageInstance

        :returns: The fetched MessageInstance
        :rtype: twilio.rest.chat.v2.service.channel.message.MessageInstance
        r?   )r"   r#   r   r   rM   rL   )r(   fetchr   r*   r   r_   r   r   r   rb     s   zMessageContext.fetchc                 C   s"   t d|i}| jjd| j|dS )
        Deletes the MessageInstance

        :param MessageInstance.WebhookEnabledType x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header

        :returns: True if delete succeeds, False otherwise
        :rtype: bool
        r   DELETE)r"   r#   r%   )r   r&   r(   deleter   )r   r2   r%   r   r   r   re     s   	zMessageContext.deletec              	   C   sn   t ||t|t|||d}t d|i}	| jjd| j||	d}
t| j|
| jd | jd | jd dS )	@  
        Update the MessageInstance

        :param unicode body: The message to send to the channel
        :param unicode attributes: A valid JSON string that contains application-specific data
        :param datetime date_created: The ISO 8601 date and time in GMT when the resource was created
        :param datetime date_updated: The ISO 8601 date and time in GMT when the resource was updated
        :param unicode last_updated_by: The Identity of the User who last updated the Message, if applicable
        :param unicode from_: The Identity of the message's author
        :param MessageInstance.WebhookEnabledType x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header

        :returns: The updated MessageInstance
        :rtype: twilio.rest.chat.v2.service.channel.message.MessageInstance
        )r   r   r   r   r   r   r   r    r!   r   r   rM   rL   )	r   r&   r   r'   r(   updater   r*   r   )r   r0   r,   r-   r.   r/   r+   r2   r$   r%   r3   r   r   r   rg   *  s"   zMessageContext.updatec                 C   $   d dd | j D }d|S )rU    c                 s        | ]\}}d  ||V  qdS z{}={}Nr   .0kvr   r   r   	<genexpr>W      z*MessageContext.__repr__.<locals>.<genexpr>z"<Twilio.Chat.V2.MessageContext {}>joinr   itemsr   r   contextr   r   r   rW   P     
zMessageContext.__repr__)rY   rZ   r[   r   rb   r   r\   re   rg   rW   r]   r   r   r   r   rO      s    
&rO   c                       sN  e Zd ZG dd deZG dd deZd2 fdd	Zedd	 Zed
d Z	edd Z
edd Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zedd Zed d! Zed"d# Zed$d% Zed&d' Zed(d) Zd*d+ Zejfd,d-Zejejejejejejejfd.d/Zd0d1 Z  ZS )3r*   c                   @      e Zd ZdZdZdS )zMessageInstance.OrderTypeascdescN)rY   rZ   r[   ASCDESCr   r   r   r   	OrderType]      r~   c                   @   ry   )z"MessageInstance.WebhookEnabledTypetruefalseN)rY   rZ   r[   TRUEFALSEr   r   r   r   WebhookEnabledTypea  r   r   Nc                    s
  t t| | i d|dd|dd|dd|dd|dd|ddt|ddt|dd	|d	d
|d
d|dd|ddt|dd|dd|dd|d| _d| _|||p| jd d| _	dS )z
        Initialize the MessageInstance

        :returns: twilio.rest.chat.v2.service.channel.message.MessageInstance
        :rtype: twilio.rest.chat.v2.service.channel.message.MessageInstance
        rM   account_sidr,   r   tor   r-   r.   r/   
was_editedr+   fromr0   indextypemediaurlNrL   )
r   r*   r   rQ   r   r'   integer_properties_contextr   )r   r   r3   r   r   rM   r   r   r   r   e  sN   






	






zMessageInstance.__init__c                 C   s6   | j du rt| j| jd | jd | jd d| _ | j S )a5  
        Generate an instance context for the instance, the context is capable of
        performing various actions.  All instance actions are proxied to the context

        :returns: MessageContext for this MessageInstance
        :rtype: twilio.rest.chat.v2.service.channel.message.MessageContext
        Nr   r   rM   rL   )r   rO   r(   r   rV   r   r   r   _proxy  s   
	zMessageInstance._proxyc                 C   
   | j d S )zb
        :returns: The unique string that identifies the resource
        :rtype: unicode
        rM   r   rV   r   r   r   rM        
zMessageInstance.sidc                 C   r   )zd
        :returns: The SID of the Account that created the resource
        :rtype: unicode
        r   r   rV   r   r   r   r     r   zMessageInstance.account_sidc                 C   r   )zi
        :returns: The JSON string that stores application-specific data
        :rtype: unicode
        r,   r   rV   r   r   r   r,     r   zMessageInstance.attributesc                 C   r   )zo
        :returns: The SID of the Service that the resource is associated with
        :rtype: unicode
        r   r   rV   r   r   r   r     r   zMessageInstance.service_sidc                 C   r   )zg
        :returns: The SID of the Channel that the message was sent to
        :rtype: unicode
        r   r   rV   r   r   r   r     r   zMessageInstance.toc                 C   r   )zj
        :returns: The SID of the Channel the Message resource belongs to
        :rtype: unicode
        r   r   rV   r   r   r   r     r   zMessageInstance.channel_sidc                 C   r   )zt
        :returns: The RFC 2822 date and time in GMT when the resource was created
        :rtype: datetime
        r-   r   rV   r   r   r   r-     r   zMessageInstance.date_createdc                 C   r   )zy
        :returns: The RFC 2822 date and time in GMT when the resource was last updated
        :rtype: datetime
        r.   r   rV   r   r   r   r.     r   zMessageInstance.date_updatedc                 C   r   )zi
        :returns: The Identity of the User who last updated the Message
        :rtype: unicode
        r/   r   rV   r   r   r   r/     r   zMessageInstance.last_updated_byc                 C   r   )zj
        :returns: Whether the message has been edited since  it was created
        :rtype: bool
        r   r   rV   r   r   r   r     r   zMessageInstance.was_editedc                 C   r   )zX
        :returns: The Identity of the message's author
        :rtype: unicode
        r+   r   rV   r   r   r   r+     r   zMessageInstance.from_c                 C   r   )zN
        :returns: The content of the message
        :rtype: unicode
        r0   r   rV   r   r   r   r0     r   zMessageInstance.bodyc                 C   r   )z_
        :returns: The index of the message within the Channel
        :rtype: unicode
        r   r   rV   r   r   r   r     r   zMessageInstance.indexc                 C   r   )zD
        :returns: The Message type
        :rtype: unicode
        r   r   rV   r   r   r   r     r   zMessageInstance.typec                 C   r   )z
        :returns: A Media object that describes the Message's media if attached; otherwise, null
        :rtype: dict
        r   r   rV   r   r   r   r     r   zMessageInstance.mediac                 C   r   )z\
        :returns: The absolute URL of the Message resource
        :rtype: unicode
        r   r   rV   r   r   r   r     r   zMessageInstance.urlc                 C   s
   | j  S )ra   )r   rb   rV   r   r   r   rb     s   
zMessageInstance.fetchc                 C   s   | j j|dS )rc   )r2   )r   re   )r   r2   r   r   r   re   %  s   	zMessageInstance.deletec              	   C   s   | j j|||||||dS )rf   )r0   r,   r-   r.   r/   r+   r2   )r   rg   )r   r0   r,   r-   r.   r/   r+   r2   r   r   r   rg   0  s   zMessageInstance.updatec                 C   rh   )rU   ri   c                 s   rj   rk   rl   rm   r   r   r   rq   S  rr   z+MessageInstance.__repr__.<locals>.<genexpr>z#<Twilio.Chat.V2.MessageInstance {}>rs   rv   r   r   r   rW   L  rx   zMessageInstance.__repr__)N) rY   rZ   r[   objectr~   r   r   propertyr   rM   r   r,   r   r   r   r-   r.   r/   r   r+   r0   r   r   r   r   rb   r   r\   re   rg   rW   r]   r   r   r   r   r*   [  s\    %
















	
r*   N)__doc__twilio.baser   r   r   twilio.base.instance_contextr   twilio.base.instance_resourcer   twilio.base.list_resourcer   twilio.base.pager   r	   rA   rO   r*   r   r   r   r   <module>   s    :-c