o
    f>h                     @   s   d Z ddlmZ ddlmZmZmZmZmZmZm	Z	 ddl
mZmZ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 )a  
    This code was generated by
   ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
    |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
    |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \

    Twilio - Chat
    This is the public Twilio REST API.

    NOTE: This class is auto generated by OpenAPI Generator.
    https://openapi-generator.tech
    Do not edit the class manually.
    )datetime)AnyDictListOptionalUnionIteratorAsyncIterator)deserialize	serializevalues)InstanceContext)InstanceResource)ListResource)Version)Pagec                       s  e Zd ZG dd deZG dd deZ	 	d'dedeee	f ded	ed
e
e f
 fddZed(ddZejfdedef defddZejfdedef defddZd)ddZd)ddZejejejejejejejfdedef deeef deeef deeef deeef deeef d eeef dd fd!d"Zejejejejejejejfdedef deeef deeef deeef deeef deeef d eeef dd fd#d$Zdefd%d&Z  ZS )*MessageInstancec                   @      e Zd ZdZdZdS )MessageInstance.OrderTypeascdescN)__name__
__module____qualname__ASCDESC r   r   ^/var/www/html/venv/lib/python3.10/site-packages/twilio/rest/chat/v2/service/channel/message.py	OrderType       r   c                   @   r   )"MessageInstance.WebhookEnabledTypetruefalseN)r   r   r   TRUEFALSEr   r   r   r   WebhookEnabledType   r   r%   Nversionpayloadservice_sidchannel_sidsidc                    s   t  | |d| _|d| _|d| _|d| _|d| _|d| _t	
|d| _t	
|d| _|d	| _|d
| _|d| _|d| _t	|d| _|d| _|d| _|d| _|||pu| jd| _d | _d S )Nr*   account_sid
attributesr(   tor)   date_createddate_updatedlast_updated_by
was_editedfrombodyindextypemediaurlr(   r)   r*   )super__init__getr*   r+   r,   r(   r-   r)   r
   iso8601_datetimer.   r/   r0   r1   _fromr3   integerr4   r5   r6   r7   	_solution_context)selfr&   r'   r(   r)   r*   	__class__r   r   r:   6   s4   
zMessageInstance.__init__returnMessageContextc                 C   s6   | j du rt| j| jd | jd | jd d| _ | j S )z
        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
        Nr(   r)   r*   r8   )r@   rE   _versionr?   rA   r   r   r   _proxy\   s   
zMessageInstance._proxyx_twilio_webhook_enabledr    c                 C   s   | j j|dS )
        Deletes the MessageInstance

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

        :returns: True if delete succeeds, False otherwise
        rI   )rH   deleterA   rI   r   r   r   rL   m   s   zMessageInstance.deletec                    s   | j j|dI dH S )
        Asynchronous coroutine that deletes the MessageInstance

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

        :returns: True if delete succeeds, False otherwise
        rK   N)rH   delete_asyncrM   r   r   r   rO   ~   s   zMessageInstance.delete_asyncc                 C   s
   | j  S )[
        Fetch the MessageInstance


        :returns: The fetched MessageInstance
        )rH   fetchrG   r   r   r   rQ      s   
zMessageInstance.fetchc                    s   | j  I dH S )u
        Asynchronous coroutine to fetch the MessageInstance


        :returns: The fetched MessageInstance
        N)rH   fetch_asyncrG   r   r   r   rS      s   zMessageInstance.fetch_asyncr3   r,   r.   r/   r0   from_c              	   C   s   | j j|||||||dS )  
        Update the MessageInstance

        :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
        :param body: The message to send to the channel. Can be an empty string or `null`, which sets the value as an empty string. You can send structured data in the body by serializing it as a string.
        :param attributes: A valid JSON string that contains application-specific data.
        :param date_created: The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was created. The default value is the current time set by the Chat service. This parameter should only be used when a Chat's history is being recreated from a backup/separate source.
        :param date_updated: The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was last updated.
        :param last_updated_by: The [Identity](https://www.twilio.com/docs/chat/identity) of the User who last updated the Message, if applicable.
        :param from_: The [Identity](https://www.twilio.com/docs/chat/identity) of the message's author.

        :returns: The updated MessageInstance
        rI   r3   r,   r.   r/   r0   rT   )rH   updaterA   rI   r3   r,   r.   r/   r0   rT   r   r   r   rW      s   zMessageInstance.updatec              	      s"   | j j|||||||dI dH S )  
        Asynchronous coroutine to update the MessageInstance

        :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
        :param body: The message to send to the channel. Can be an empty string or `null`, which sets the value as an empty string. You can send structured data in the body by serializing it as a string.
        :param attributes: A valid JSON string that contains application-specific data.
        :param date_created: The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was created. The default value is the current time set by the Chat service. This parameter should only be used when a Chat's history is being recreated from a backup/separate source.
        :param date_updated: The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was last updated.
        :param last_updated_by: The [Identity](https://www.twilio.com/docs/chat/identity) of the User who last updated the Message, if applicable.
        :param from_: The [Identity](https://www.twilio.com/docs/chat/identity) of the message's author.

        :returns: The updated MessageInstance
        rV   N)rH   update_asyncrX   r   r   r   rZ      s   zMessageInstance.update_asyncc                 C   $   d dd | j D }d|S )f
        Provide a friendly representation

        :returns: Machine friendly representation
         c                 s        | ]\}}d  ||V  qdS z{}={}Nformat.0kvr   r   r   	<genexpr>       z+MessageInstance.__repr__.<locals>.<genexpr>z#<Twilio.Chat.V2.MessageInstance {}>joinr?   itemsra   rA   contextr   r   r   __repr__      
zMessageInstance.__repr__N)rD   rE   )rD   r   )r   r   r   objectr   r%   r   r   strr   r   r:   propertyrH   r   unsetr   boolrL   rO   rQ   rS   r   rW   rZ   rm   __classcell__r   r   rB   r   r      s    
&



	




	


'




	


#r   c                       s  e Zd Zdedededef fddZejfdede	f d	e
fd
dZejfdede	f d	e
fddZd	efddZd	efddZejejejejejejejfdede	f deee	f deee	f deee	f deee	f deee	f deee	f d	efddZejejejejejejejfdede	f deee	f deee	f deee	f deee	f deee	f deee	f d	efddZd	efddZ  ZS )rE   r&   r(   r)   r*   c                    s2   t  | |||d| _djdi | j| _dS )a  
        Initialize the MessageContext

        :param version: Version that contains the resource
        :param service_sid: The SID of the [Service](https://www.twilio.com/docs/chat/rest/service-resource) to update the Message resource in.
        :param channel_sid: The SID of the [Channel](https://www.twilio.com/docs/chat/channels) the Message resource to update belongs to. This value can be the Channel resource's `sid` or `unique_name`.
        :param sid: The SID of the Message resource to update.
        r8   z=/Services/{service_sid}/Channels/{channel_sid}/Messages/{sid}Nr   r9   r:   r?   ra   _uri)rA   r&   r(   r)   r*   rB   r   r   r:      s   	zMessageContext.__init__rI   r    rD   c                 C   s,   t d|i}t i }| jjd| j|dS )rJ   X-Twilio-Webhook-EnabledDELETEmethoduriheaders)r   ofrF   rL   rw   rA   rI   r}   r   r   r   rL   
  s   
zMessageContext.deletec                    s4   t d|i}t i }| jjd| j|dI dH S )rN   rx   ry   rz   N)r   r~   rF   rO   rw   r   r   r   r   rO   !  s   
zMessageContext.delete_asyncc                 C   sL   t i }d|d< | jjd| j|d}t| j|| jd | jd | jd dS )	rP   application/jsonAcceptGETrz   r(   r)   r*   r8   )r   r~   rF   rQ   rw   r   r?   rA   r}   r'   r   r   r   rQ   :  s   
zMessageContext.fetchc                    sT   t i }d|d< | jjd| j|dI dH }t| j|| jd | jd | jd d	S )
rR   r   r   r   rz   Nr(   r)   r*   r8   )r   r~   rF   rS   rw   r   r?   r   r   r   r   rS   P  s   
zMessageContext.fetch_asyncr3   r,   r.   r/   r0   rT   c              	   C   s   t ||t|t|||d}t i }	|t ju s't|tr#|r'||	d< d|	d< d|	d< | jjd| j	||	d}
t
| j|
| jd	 | jd
 | jd dS )rU   Body
AttributesDateCreatedDateUpdatedLastUpdatedByFromrx   !application/x-www-form-urlencodedContent-Typer   r   POSTr{   r|   datar}   r(   r)   r*   r8   )r   r~   r   r<   rs   
isinstancerq   rF   rW   rw   r   r?   rA   rI   r3   r,   r.   r/   r0   rT   r   r}   r'   r   r   r   rW   h  s8   



zMessageContext.updatec              	      s   t ||t|t|||d}t i }	|t ju s(t|tr$|r(||	d< d|	d< d|	d< | jjd| j	||	dI d	H }
t
| j|
| jd
 | jd | jd dS )rY   r   rx   r   r   r   r   r   r   Nr(   r)   r*   r8   )r   r~   r   r<   rs   r   rq   rF   rZ   rw   r   r?   r   r   r   r   rZ     s:   



zMessageContext.update_asyncc                 C   r[   )r\   r]   c                 s   r^   r_   r`   rb   r   r   r   rf     rg   z*MessageContext.__repr__.<locals>.<genexpr>z"<Twilio.Chat.V2.MessageContext {}>rh   rk   r   r   r   rm     rn   zMessageContext.__repr__)r   r   r   r   rq   r:   r   rs   r   rp   rt   rL   rO   r   rQ   rS   r   rW   rZ   rm   ru   r   r   rB   r   rE      s    






	


C




	


?rE   c                   @   s4   e Zd Zdeeef defddZdefddZdS )MessagePager'   rD   c                 C   s   t | j|| jd | jd dS )zm
        Build an instance of MessageInstance

        :param payload: Payload response from the API
        r(   r)   r(   r)   )r   rF   r?   )rA   r'   r   r   r   get_instance  s   zMessagePage.get_instancec                 C      dS )r\   z<Twilio.Chat.V2.MessagePage>r   rG   r   r   r   rm        zMessagePage.__repr__N)	r   r   r   r   rq   r   r   r   rm   r   r   r   r   r     s    r   c                       s   e Zd Zdededef fddZejejejejejejejejfdede	f deee	f d	eee	f d
ee
e	f dee
e	f deee	f deee	f deee	f defddZejejejejejejejejfdede	f deee	f d	eee	f d
ee
e	f dee
e	f deee	f deee	f deee	f defddZejddfdede	f dee dee dee fddZejddfdede	f dee dee dee fddZejddfdede	f dee dee dee fddZejddfdede	f dee dee dee fdd Zejejejejfdede	f d!eee	f d"eee	f deee	f def
d#d$Zejejejejfdede	f d!eee	f d"eee	f deee	f def
d%d&Zd'edefd(d)Zd'edefd*d+Zd,edefd-d.Zd,edefd/d0Zdefd1d2Z  Z S )3MessageListr&   r(   r)   c                    s0   t  | ||d| _djdi | j| _dS )a  
        Initialize the MessageList

        :param version: Version that contains the resource
        :param service_sid: The SID of the [Service](https://www.twilio.com/docs/chat/rest/service-resource) to read the Message resources from.
        :param channel_sid: The SID of the [Channel](https://www.twilio.com/docs/chat/channels) the Message resource to read belongs to. This value can be the Channel resource's `sid` or `unique_name`.

        r   z7/Services/{service_sid}/Channels/{channel_sid}/MessagesNr   rv   )rA   r&   r(   r)   rB   r   r   r:   
  s   	zMessageList.__init__rI   r    rT   r,   r.   r/   r0   r3   	media_sidrD   c	              
   C   sz   t ||t|t||||d}	t |dd}
d|
d< d|
d< | jjd| j|	|
d}t| j|| jd	 | jd
 dS )an  
        Create the MessageInstance

        :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
        :param from_: The [Identity](https://www.twilio.com/docs/chat/identity) of the new message's author. The default value is `system`.
        :param attributes: A valid JSON string that contains application-specific data.
        :param date_created: The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was created. The default value is the current time set by the Chat service. This parameter should only be used when a Chat's history is being recreated from a backup/separate source.
        :param date_updated: The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was last updated.
        :param last_updated_by: The [Identity](https://www.twilio.com/docs/chat/identity) of the User who last updated the Message, if applicable.
        :param body: The message to send to the channel. Can be an empty string or `null`, which sets the value as an empty string. You can send structured data in the body by serializing it as a string.
        :param media_sid: The SID of the [Media](https://www.twilio.com/docs/chat/rest/media) to attach to the new Message.

        :returns: The created MessageInstance
        r   r   r   r   r   r   MediaSidr   rx   r   r   r   r   r   r   r(   r)   r   )	r   r~   r   r<   rF   createrw   r   r?   rA   rI   rT   r,   r.   r/   r0   r3   r   r   r}   r'   r   r   r   r     s4   
zMessageList.createc	              
      s   t ||t|t||||d}	t |dd}
d|
d< d|
d< | jjd| j|	|
dI d	H }t| j|| jd
 | jd dS )a}  
        Asynchronously create the MessageInstance

        :param x_twilio_webhook_enabled: The X-Twilio-Webhook-Enabled HTTP request header
        :param from_: The [Identity](https://www.twilio.com/docs/chat/identity) of the new message's author. The default value is `system`.
        :param attributes: A valid JSON string that contains application-specific data.
        :param date_created: The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was created. The default value is the current time set by the Chat service. This parameter should only be used when a Chat's history is being recreated from a backup/separate source.
        :param date_updated: The date, specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was last updated.
        :param last_updated_by: The [Identity](https://www.twilio.com/docs/chat/identity) of the User who last updated the Message, if applicable.
        :param body: The message to send to the channel. Can be an empty string or `null`, which sets the value as an empty string. You can send structured data in the body by serializing it as a string.
        :param media_sid: The SID of the [Media](https://www.twilio.com/docs/chat/rest/media) to attach to the new Message.

        :returns: The created MessageInstance
        r   r   r   r   r   r   r   r   Nr(   r)   r   )	r   r~   r   r<   rF   create_asyncrw   r   r?   r   r   r   r   r   [  s6   
zMessageList.create_asyncNorderr   limit	page_sizec                 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 &quot;MessageInstance.OrderType&quot; order: The sort order of the returned messages. Can be: `asc` (ascending) or `desc` (descending) with `asc` as the default.
        :param limit: Upper limit for the number of records to return. stream()
                      guarantees to never return more than limit.  Default is no limit
        :param 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
        r   r   r   r   )rF   read_limitspagestreamrA   r   r   r   limitsr   r   r   r   r     s   zMessageList.streamc                    s:   | j ||}| j||d dI dH }| j ||d S )a  
        Asynchronously 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 &quot;MessageInstance.OrderType&quot; order: The sort order of the returned messages. Can be: `asc` (ascending) or `desc` (descending) with `asc` as the default.
        :param limit: Upper limit for the number of records to return. stream()
                      guarantees to never return more than limit.  Default is no limit
        :param 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
        r   r   Nr   )rF   r   
page_asyncstream_asyncr   r   r   r   r     s   zMessageList.stream_asyncc                 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 &quot;MessageInstance.OrderType&quot; order: The sort order of the returned messages. Can be: `asc` (ascending) or `desc` (descending) with `asc` as the default.
        :param limit: Upper limit for the number of records to return. list() guarantees
                      never to return more than limit.  Default is no limit
        :param 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: list that will contain up to limit results
        r   r   r   )listr   rA   r   r   r   r   r   r   r     s   zMessageList.listc                    s(   dd | j |||dI dH 2 I dH S )a  
        Asynchronously 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 &quot;MessageInstance.OrderType&quot; order: The sort order of the returned messages. Can be: `asc` (ascending) or `desc` (descending) with `asc` as the default.
        :param limit: Upper limit for the number of records to return. list() guarantees
                      never to return more than limit.  Default is no limit
        :param 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: list that will contain up to limit results
        c                    s   g | z3 d H W }|q6 S ro   r   )rc   recordr   r   r   
<listcomp>   s
    z*MessageList.list_async.<locals>.<listcomp>r   N)r   r   r   r   r   
list_async  s   
zMessageList.list_async
page_tokenpage_numberc                 C   sP   t ||||d}t ddi}d|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 order: The sort order of the returned messages. Can be: `asc` (ascending) or `desc` (descending) with `asc` as the default.
        :param page_token: PageToken provided by the API
        :param page_number: Page Number, this value is simply for client state
        :param page_size: Number of records to return, defaults to 50

        :returns: Page of MessageInstance
        Order	PageTokenr   PageSizer   r   r   r   r   r{   r|   paramsr}   )r   r~   rF   r   rw   r   r?   rA   r   r   r   r   r   r}   responser   r   r   r   	  s   	
zMessageList.pagec                    sX   t ||||d}t ddi}d|d< | jjd| j||dI dH }t| j|| jS )	a  
        Asynchronously retrieve a single page of MessageInstance records from the API.
        Request is executed immediately

        :param order: The sort order of the returned messages. Can be: `asc` (ascending) or `desc` (descending) with `asc` as the default.
        :param page_token: PageToken provided by the API
        :param page_number: Page Number, this value is simply for client state
        :param page_size: Number of records to return, defaults to 50

        :returns: Page of MessageInstance
        r   r   r   r   r   r   r   N)r   r~   rF   r   rw   r   r?   r   r   r   r   r   -  s   	
zMessageList.page_async
target_urlc                 C   s"   | j jjd|}t| j || jS )z
        Retrieve a specific page of MessageInstance records from the API.
        Request is executed immediately

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

        :returns: Page of MessageInstance
        r   )rF   domaintwiliorequestr   r?   rA   r   r   r   r   r   get_pageQ  s   	zMessageList.get_pagec                    s*   | j jjd|I dH }t| j || jS )a  
        Asynchronously retrieve a specific page of MessageInstance records from the API.
        Request is executed immediately

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

        :returns: Page of MessageInstance
        r   N)rF   r   r   request_asyncr   r?   r   r   r   r   get_page_async]  s   	zMessageList.get_page_asyncr*   c                 C      t | j| jd | jd |dS zm
        Constructs a MessageContext

        :param sid: The SID of the Message resource to update.
        r(   r)   r8   rE   rF   r?   rA   r*   r   r   r   r;   i     zMessageList.getc                 C   r   r   r   r   r   r   r   __call__v  r   zMessageList.__call__c                 C   r   )r\   z<Twilio.Chat.V2.MessageList>r   rG   r   r   r   rm     r   zMessageList.__repr__)!r   r   r   r   rq   r:   r   rs   r   rp   r   r   r   r   r   intr   r   r	   r   r   r   r   r   r   r   r   r   rE   r;   r   rm   ru   r   r   rB   r   r     s   




	



A




	



?







 




&




$r   N)__doc__r   typingr   r   r   r   r   r   r	   twilio.baser
   r   r   twilio.base.instance_contextr   twilio.base.instance_resourcer   twilio.base.list_resourcer   twilio.base.versionr   twilio.base.pager   r   rE   r   r   r   r   r   r   <module>   s     $ Y  