o
    f>hk                     @   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 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values)InstanceContext)InstanceResource)ListResource)Version)Pagec                       s   e Zd 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defddZdefddZd!ddZd!ddZejejfdeeef deeef dd fddZejej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                   @   s   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/v1/service/channel/message.py	OrderType   s    r   Nversionpayloadservice_sidchannel_sidsidc                    s   t  | |d| _|d| _|d| _|d| _|d| _|d| _t	
|d| _t	
|d| _|d	| _|d
| _|d| _t	|d| _|d| _|||pc| jd| _d | _d S )Nr!   account_sid
attributesr   tor    date_createddate_updated
was_editedfrombodyindexurlr   r    r!   )super__init__getr!   r"   r#   r   r$   r    r
   iso8601_datetimer%   r&   r'   _fromr)   integerr*   r+   	_solution_context)selfr   r   r   r    r!   	__class__r   r   r.   /   s.   
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!   r,   )r4   r9   _versionr3   r5   r   r   r   _proxyR   s   
zMessageInstance._proxyc                 C   
   | j  S )j
        Deletes the MessageInstance


        :returns: True if delete succeeds, False otherwise
        )r<   deleter;   r   r   r   r?   c      
zMessageInstance.deletec                       | j  I dH S )
        Asynchronous coroutine that deletes the MessageInstance


        :returns: True if delete succeeds, False otherwise
        N)r<   delete_asyncr;   r   r   r   rC   l      zMessageInstance.delete_asyncc                 C   r=   )[
        Fetch the MessageInstance


        :returns: The fetched MessageInstance
        )r<   fetchr;   r   r   r   rF   u   r@   zMessageInstance.fetchc                    rA   )u
        Asynchronous coroutine to fetch the MessageInstance


        :returns: The fetched MessageInstance
        N)r<   fetch_asyncr;   r   r   r   rH   ~   rD   zMessageInstance.fetch_asyncr)   r#   c                 C   s   | j j||dS )  
        Update the MessageInstance

        :param body: The message to send to the channel. Can also 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.

        :returns: The updated MessageInstance
        r)   r#   )r<   updater5   r)   r#   r   r   r   rK      s   zMessageInstance.updatec                    s   | j j||dI dH S )  
        Asynchronous coroutine to update the MessageInstance

        :param body: The message to send to the channel. Can also 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.

        :returns: The updated MessageInstance
        rJ   N)r<   update_asyncrL   r   r   r   rN      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.V1.MessageInstance {}>joinr3   itemsrU   r5   contextr   r   r   __repr__      
zMessageInstance.__repr__N)r8   r9   )r8   r   )r   r   r   objectr   r   r   strr   r   r.   propertyr<   boolr?   rC   rF   rH   r   unsetr   rK   rN   ra   __classcell__r   r   r6   r   r      sP    
#	
	
	





r   c                       s   e Zd Zdedededef fddZdefdd	Zdefd
dZde	fddZ
de	fddZejejfdeeef deeef de	fddZejej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 )r9   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/api/chat/rest/services) to update the resource from.
        :param channel_sid: The unique ID of the [Channel](https://www.twilio.com/docs/api/chat/rest/channels) the message belongs to. Can be the Channel's `sid` or `unique_name`.
        :param sid: The Twilio-provided string that uniquely identifies the Message resource to update.
        r,   z=/Services/{service_sid}/Channels/{channel_sid}/Messages/{sid}Nr   r-   r.   r3   rU   _uri)r5   r   r   r    r!   r6   r   r   r.      s   	zMessageContext.__init__r8   c                 C   s   t i }| jjd| j|dS )r>   DELETEmethoduriheaders)r   ofr:   r?   rk   r5   rp   r   r   r   r?      s   
zMessageContext.deletec                    s&   t i }| jjd| j|dI dH S )rB   rl   rm   N)r   rq   r:   rC   rk   rr   r   r   r   rC      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 )	rE   application/jsonAcceptGETrm   r   r    r!   r,   )r   rq   r:   rF   rk   r   r3   r5   rp   r   r   r   r   rF      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 )
rG   rs   rt   ru   rm   Nr   r    r!   r,   )r   rq   r:   rH   rk   r   r3   rv   r   r   r   rH      s   
zMessageContext.fetch_asyncr)   r#   c                 C   sf   t ||d}t i }d|d< d|d< | jjd| j||d}t| j|| jd | jd	 | jd
 dS )rI   Body
Attributes!application/x-www-form-urlencodedContent-Typers   rt   POSTrn   ro   datarp   r   r    r!   r,   )r   rq   r:   rK   rk   r   r3   r5   r)   r#   r~   rp   r   r   r   r   rK     s$   

zMessageContext.updatec                    sn   t ||d}t i }d|d< d|d< | jjd| j||dI dH }t| j|| jd	 | jd
 | jd dS )rM   rw   rz   r{   rs   rt   r|   r}   Nr   r    r!   r,   )r   rq   r:   rN   rk   r   r3   r   r   r   r   rN   <  s&   

zMessageContext.update_asyncc                 C   rO   )rP   rQ   c                 s   rR   rS   rT   rV   r   r   r   rZ   h  r[   z*MessageContext.__repr__.<locals>.<genexpr>z"<Twilio.Chat.V1.MessageContext {}>r\   r_   r   r   r   ra   b  rb   zMessageContext.__repr__)r   r   r   r   re   r.   rg   r?   rC   r   rF   rH   r   rh   r   rd   rK   rN   ra   ri   r   r   r6   r   r9      s2    


(


&r9   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   r8   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   r:   r3   )r5   r   r   r   r   get_instancen  s   zMessagePage.get_instancec                 C      dS )rP   z<Twilio.Chat.V1.MessagePage>r   r;   r   r   r   ra   {     zMessagePage.__repr__N)	r   r   r   r   re   r   r   r   ra   r   r   r   r   r   l  s    r   c                       sh  e Zd Zdededef fddZejejfdedeee	f deee	f d	e
fd
dZejejfde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)d*Zd	efd+d,Z  ZS )-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/api/chat/rest/services) to read the resources from.
        :param channel_sid: The unique ID of the [Channel](https://www.twilio.com/docs/api/chat/rest/channels) the message to read belongs to. Can be the Channel's `sid` or `unique_name`.

        r   z7/Services/{service_sid}/Channels/{channel_sid}/MessagesNr   rj   )r5   r   r   r    r6   r   r   r.     s   	zMessageList.__init__r)   from_r#   r8   c                 C   sd   t |||d}t ddi}d|d< d|d< | jjd| j||d}t| j|| jd | jd	 d
S )a  
        Create the MessageInstance

        :param body: The message to send to the channel. Can also 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 from_: The [identity](https://www.twilio.com/docs/api/chat/guides/identity) of the new message's author. The default value is `system`.
        :param attributes: A valid JSON string that contains application-specific data.

        :returns: The created MessageInstance
        rx   Fromry   r{   rz   rs   rt   r|   r}   r   r    r   )r   rq   r:   createrk   r   r3   r5   r)   r   r#   r~   rp   r   r   r   r   r     s$   
zMessageList.createc                    sl   t |||d}t ddi}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 body: The message to send to the channel. Can also 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 from_: The [identity](https://www.twilio.com/docs/api/chat/guides/identity) of the new message's author. The default value is `system`.
        :param attributes: A valid JSON string that contains application-specific data.

        :returns: The created MessageInstance
        r   r{   rz   rs   rt   r|   r}   Nr   r    r   )r   rq   r:   create_asyncrk   r   r3   r   r   r   r   r     s&   
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   )r:   read_limitspagestreamr5   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   )r:   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   r5   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 rc   r   )rW   recordr   r   r   
<listcomp>R  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{   rz   rs   rt   ru   rn   ro   paramsrp   )r   rq   r:   r   rk   r   r3   r5   r   r   r   r   r~   rp   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{   rz   rs   rt   ru   r   N)r   rq   r:   r   rk   r   r3   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
        ru   )r:   domaintwiliorequestr   r3   r5   r   r   r   r   r   get_page  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
        ru   N)r:   r   r   request_asyncr   r3   r   r   r   r   get_page_async  s   	zMessageList.get_page_asyncr!   c                 C      t | j| jd | jd |dS z
        Constructs a MessageContext

        :param sid: The Twilio-provided string that uniquely identifies the Message resource to update.
        r   r    r,   r9   r:   r3   r5   r!   r   r   r   r/        zMessageList.getc                 C   r   r   r   r   r   r   r   __call__  r   zMessageList.__call__c                 C   r   )rP   z<Twilio.Chat.V1.MessageList>r   r;   r   r   r   ra     r   zMessageList.__repr__) r   r   r   r   re   r.   r   rh   r   rd   r   r   r   r   intr   r   r	   r   r   r   r   r   r   r   r   r   r9   r/   r   ra   ri   r   r   r6   r   r     s    


+


*







 




&




$r   N)__doc__r   typingr   r   r   r   r   r   r	   twilio.baser
   r   twilio.base.instance_contextr   twilio.base.instance_resourcer   twilio.base.list_resourcer   twilio.base.versionr   twilio.base.pager   r   r9   r   r   r   r   r   r   <module>   s    $  8