U
    ^g%ik                     @   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eeeef eee	e d fddZ
eddd	d
ZedddZedddZd dddZd dddZejejfeeef eeef d dddZejejfeeef eeef d dddZedddZ  ZS )MessageInstancec                   @   s   e Zd ZdZdZdS )MessageInstance.OrderTypeascdescN)__name__
__module____qualname__ZASCZDESC r   r   j/var/www/html/api-medvista/venv/lib/python3.8/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| _|||p| 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
   Ziso8601_datetimer#   r$   r%   Z_fromr'   integerr(   r)   	_solution_context)selfr   r   r   r   r   	__class__r   r   r,   /   s.    zMessageInstance.__init__MessageContextreturnc                 C   s6   | j dkr0t| 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*   )r0   r4   _versionr/   r1   r   r   r   _proxyR   s    
zMessageInstance._proxyc                 C   s
   | j  S )j
        Deletes the MessageInstance


        :returns: True if delete succeeds, False otherwise
        )r9   deleter8   r   r   r   r;   c   s    zMessageInstance.deletec                    s   | j  I dH S )
        Asynchronous coroutine that deletes the MessageInstance


        :returns: True if delete succeeds, False otherwise
        N)r9   delete_asyncr8   r   r   r   r=   l   s    zMessageInstance.delete_asyncc                 C   s
   | j  S )[
        Fetch the MessageInstance


        :returns: The fetched MessageInstance
        )r9   fetchr8   r   r   r   r?   u   s    zMessageInstance.fetchc                    s   | j  I dH S )u
        Asynchronous coroutine to fetch the MessageInstance


        :returns: The fetched MessageInstance
        N)r9   fetch_asyncr8   r   r   r   rA   ~   s    zMessageInstance.fetch_asyncr'   r!   r6   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!   )r9   updater1   r'   r!   r   r   r   rE      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
        rD   N)r9   update_asyncrF   r   r   r   rH      s    zMessageInstance.update_asyncc                 C   s$   d dd | j D }d|S )f
        Provide a friendly representation

        :returns: Machine friendly representation
         c                 s   s   | ]\}}d  ||V  qdS z{}={}Nformat.0kvr   r   r   	<genexpr>   s     z+MessageInstance.__repr__.<locals>.<genexpr>z#<Twilio.Chat.V1.MessageInstance {}>joinr/   itemsrM   r1   contextr   r   r   __repr__   s    zMessageInstance.__repr__)N)r   r   r   objectr   r   r   strr   r   r,   propertyr9   boolr;   r=   r?   rA   r   unsetr   rE   rH   rX   __classcell__r   r   r2   r   r      s<    
#			



r   c                       s   e Zd Zeeeed fddZedddZedddZe	dd	d
Z
e	dddZejejfeeef eeef e	dddZejejfeeef eeef e	dddZedddZ  ZS )r4   )r   r   r   r   c                    s.   t  | |||d| _djf | 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}Nr+   r,   r/   rM   _uri)r1   r   r   r   r   r2   r   r   r,      s    	zMessageContext.__init__r5   c                 C   s   t i }| jjd| j|dS )r:   DELETEmethoduriheaders)r   ofr7   r;   r`   r1   re   r   r   r   r;      s    
zMessageContext.deletec                    s$   t i }| jjd| j|dI dH S )r<   ra   rb   N)r   rf   r7   r=   r`   rg   r   r   r   r=      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 )	r>   application/jsonAcceptGETrb   r   r   r   r*   )r   rf   r7   r?   r`   r   r/   r1   re   r   r   r   r   r?      s    
zMessageContext.fetchc                    sR   t i }d|d< | jjd| j|dI dH }t| j|| jd | jd | jd d	S )
r@   rh   ri   rj   rb   Nr   r   r   r*   )r   rf   r7   rA   r`   r   r/   rk   r   r   r   rA      s    
  zMessageContext.fetch_asyncrB   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 )rC   Body
Attributes!application/x-www-form-urlencodedContent-Typerh   ri   POSTrc   rd   datare   r   r   r   r*   )r   rf   r7   rE   r`   r   r/   r1   r'   r!   rs   re   r   r   r   r   rE     s*    
   zMessageContext.updatec                    sl   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 )rG   rl   ro   rp   rh   ri   rq   rr   Nr   r   r   r*   )r   rf   r7   rH   r`   r   r/   rt   r   r   r   rH   <  s*    
   zMessageContext.update_asyncc                 C   s$   d dd | j D }d|S )rI   rJ   c                 s   s   | ]\}}d  ||V  qdS rK   rL   rN   r   r   r   rR   h  s     z*MessageContext.__repr__.<locals>.<genexpr>z"<Twilio.Chat.V1.MessageContext {}>rS   rV   r   r   r   rX   b  s    zMessageContext.__repr__)r   r   r   r   rZ   r,   r\   r;   r=   r   r?   rA   r   r]   r   rY   rE   rH   rX   r^   r   r   r2   r   r4      s(   

(

&r4   c                   @   s2   e Zd Zeeef edddZedddZdS )MessagePage)r   r6   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   r7   r/   )r1   r   r   r   r   get_instancen  s    zMessagePage.get_instancer5   c                 C   s   dS )rI   z<Twilio.Chat.V1.MessagePage>r   r8   r   r   r   rX   {  s    zMessagePage.__repr__N)	r   r   r   r   rZ   r   r   rw   rX   r   r   r   r   ru   l  s   ru   c                       s(  e Zd Zeeed fddZejejfeeee	f eee	f e
dddZejejfeeee	f eee	f e
dddZejd	d	fed
e	f ee ee ee
 dddZejd	d	fed
e	f ee ee ee
 dddZejd	d	fed
e	f ee ee ee
 dddZejd	d	fed
e	f ee ee ee
 dddZejejejejfed
e	f eee	f eee	f eee	f edddZejejejejfed
e	f eee	f eee	f eee	f edddZeedddZeedddZeeddd Zeedd!d"Zed#d$d%Z  ZS )&MessageList)r   r   r   c                    s,   t  | ||d| _djf | 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`.

        rv   z7/Services/{service_sid}/Channels/{channel_sid}/MessagesNr_   )r1   r   r   r   r2   r   r   r,     s    	zMessageList.__init__)r'   from_r!   r6   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
        rm   Fromrn   rp   ro   rh   ri   rq   rr   r   r   rv   )r   rf   r7   creater`   r   r/   r1   r'   ry   r!   rs   re   r   r   r   r   r|     s*       zMessageList.createc                    sj   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
        rz   rp   ro   rh   ri   rq   rr   Nr   r   rv   )r   rf   r7   create_asyncr`   r   r/   r}   r   r   r   r~     s*       zMessageList.create_asyncNr   )orderlimit	page_sizer6   c                 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   )r7   read_limitspagestreamr1   r   r   r   Zlimitsr   r   r   r   r     s    zMessageList.streamc                    s8   | 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   )r7   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   r1   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 )Nr   )rO   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)r   
page_tokenpage_numberr   r6   c                 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
        ZOrderZ	PageTokenr   ZPageSizerp   ro   rh   ri   rj   rc   rd   paramsre   )r   rf   r7   r   r`   ru   r/   r1   r   r   r   r   rs   re   responser   r   r   r   [  s     	   zMessageList.pagec                    sV   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   rp   ro   rh   ri   rj   r   N)r   rf   r7   r   r`   ru   r/   r   r   r   r   r     s     	   zMessageList.page_async)
target_urlr6   c                 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
        rj   )r7   domaintwiliorequestru   r/   r1   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
        rj   N)r7   r   r   Zrequest_asyncru   r/   r   r   r   r   get_page_async  s    	zMessageList.get_page_async)r   r6   c                 C   s   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*   r4   r7   r/   r1   r   r   r   r   r-     s    zMessageList.getc                 C   s   t | j| jd | jd |dS r   r   r   r   r   r   __call__  s    zMessageList.__call__r5   c                 C   s   dS )rI   z<Twilio.Chat.V1.MessageList>r   r8   r   r   r   rX     s    zMessageList.__repr__) r   r   r   r   rZ   r,   r   r]   r   rY   r   r|   r~   r   intr   r   r	   r   r   r   r   ru   r   r   r   r   r4   r-   r   rX   r^   r   r   r2   r   rx     s   

+

*



 



&



$rx   N)__doc__r   typingr   r   r   r   r   r   r	   Ztwilio.baser
   r   Ztwilio.base.instance_contextr   Ztwilio.base.instance_resourcer   Ztwilio.base.list_resourcer   Ztwilio.base.versionr   Ztwilio.base.pager   r   r4   ru   rx   r   r   r   r   <module>   s   $  8