U
    ^g%i                     @   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eeee	f eee
e d fddZed	d
ddZejfedef edddZejfedef edddZd d
ddZd d
ddZejejej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eef eeef eeef d dddZejejej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ee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/v2/service/channel/message.py	OrderType   s   r   c                   @   s   e Zd ZdZdZdS )"MessageInstance.WebhookEnabledTypetruefalseN)r   r   r   TRUEFALSEr   r   r   r   WebhookEnabledType   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| _|d| _t	|d| _|d| _|d| _|d| _|||p| 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+   r,   r-   Z_fromr/   integerr0   r1   r2   r3   	_solution_context)selfr"   r#   r$   r%   r&   	__class__r   r   r6   6   s4    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&   r4   )r;   r?   _versionr:   r<   r   r   r   _proxy\   s    
zMessageInstance._proxyr   x_twilio_webhook_enabledrA   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
        rF   )rD   deleter<   rF   r   r   r   rI   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
        rH   N)rD   delete_asyncrJ   r   r   r   rL   ~   s    zMessageInstance.delete_asyncc                 C   s
   | j  S )[
        Fetch the MessageInstance


        :returns: The fetched MessageInstance
        )rD   fetchrC   r   r   r   rN      s    zMessageInstance.fetchc                    s   | j  I dH S )u
        Asynchronous coroutine to fetch the MessageInstance


        :returns: The fetched MessageInstance
        N)rD   fetch_asyncrC   r   r   r   rP      s    zMessageInstance.fetch_asyncrF   r/   r(   r*   r+   r,   from_rA   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
        rF   r/   r(   r*   r+   r,   rR   )rD   updater<   rF   r/   r(   r*   r+   r,   rR   r   r   r   rU      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
        rT   N)rD   update_asyncrV   r   r   r   rX      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.V2.MessageInstance {}>joinr:   itemsr]   r<   contextr   r   r   __repr__   s    zMessageInstance.__repr__)N)r   r   r   objectr   r!   r   r   strr   r   r6   propertyrD   r   unsetr   boolrI   rL   rN   rP   r   rU   rX   rh   __classcell__r   r   r=   r   r      s    
&	





'





#r   c                
       sr  e Zd Zeeeed fddZejfede	f e
dddZejfede	f e
ddd	Zed
ddZed
ddZejejej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ee	f eee	f eee	f edddZejejej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ee	f eee	f eee	f edddZed
ddZ  ZS )r?   )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/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.
        r4   z=/Services/{service_sid}/Channels/{channel_sid}/Messages/{sid}Nr5   r6   r:   r]   _uri)r<   r"   r$   r%   r&   r=   r   r   r6      s    	zMessageContext.__init__r   rE   c                 C   s,   t d|i}t i }| jjd| j|dS )rG   X-Twilio-Webhook-EnabledDELETEmethoduriheaders)r   ofrB   rI   rp   r<   rF   rv   r   r   r   rI   
  s     
zMessageContext.deletec                    s2   t d|i}t i }| jjd| j|dI dH S )rK   rq   rr   rs   N)r   rw   rB   rL   rp   rx   r   r   r   rL   !  s     
  zMessageContext.delete_asyncr@   c                 C   sL   t i }d|d< | jjd| j|d}t| j|| jd | jd | jd dS )	rM   application/jsonAcceptGETrs   r$   r%   r&   r4   )r   rw   rB   rN   rp   r   r:   r<   rv   r#   r   r   r   rN   :  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 )
rO   ry   rz   r{   rs   Nr$   r%   r&   r4   )r   rw   rB   rP   rp   r   r:   r|   r   r   r   rP   P  s    
  zMessageContext.fetch_asyncrQ   c              	   C   s   t ||t|t|||d}t i }	|t jksNt|trF|rN||	d< d|	d< d|	d< | jjd| j	||	d}
t
| j|
| jd	 | jd
 | jd dS )rS   Body
AttributesDateCreatedDateUpdatedLastUpdatedByFromrq   !application/x-www-form-urlencodedContent-Typery   rz   POSTrt   ru   datarv   r$   r%   r&   r4   )r   rw   r   r8   rl   
isinstancerj   rB   rU   rp   r   r:   r<   rF   r/   r(   r*   r+   r,   rR   r   rv   r#   r   r   r   rU   h  s@    

   zMessageContext.updatec              	      s   t ||t|t|||d}t i }	|t jksNt|trF|rN||	d< d|	d< d|	d< | jjd| j	||	dI d	H }
t
| j|
| jd
 | jd | jd dS )rW   r}   rq   r   r   ry   rz   r   r   Nr$   r%   r&   r4   )r   rw   r   r8   rl   r   rj   rB   rX   rp   r   r:   r   r   r   r   rX     s@    

   zMessageContext.update_asyncc                 C   s$   d dd | j D }d|S )rY   rZ   c                 s   s   | ]\}}d  ||V  qdS r[   r\   r^   r   r   r   rb     s     z*MessageContext.__repr__.<locals>.<genexpr>z"<Twilio.Chat.V2.MessageContext {}>rc   rf   r   r   r   rh     s    zMessageContext.__repr__)r   r   r   r   rj   r6   r   rl   r   ri   rm   rI   rL   r   rN   rP   r   rU   rX   rh   rn   r   r   r=   r   r?      sp   





C





?r?   c                   @   s2   e Zd Zeeef edddZedddZdS )MessagePage)r#   rA   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   rB   r:   )r<   r#   r   r   r   get_instance  s    zMessagePage.get_instancer@   c                 C   s   dS )rY   z<Twilio.Chat.V2.MessagePage>r   rC   r   r   r   rh     s    zMessagePage.__repr__N)	r   r   r   r   rj   r   r   r   rh   r   r   r   r   r     s   r   c                       s  e Zd Zeeed fddZejejejej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e
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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e
e	f eee	f 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/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}/MessagesNro   )r<   r"   r$   r%   r=   r   r   r6   
  s    	zMessageList.__init__r   )	rF   rR   r(   r*   r+   r,   r/   	media_sidrA   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~   ZMediaSidr   rq   r   r   ry   rz   r   r   r$   r%   r   )	r   rw   r   r8   rB   createrp   r   r:   r<   rF   rR   r(   r*   r+   r,   r/   r   r   rv   r#   r   r   r   r     s:       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   ry   rz   r   r   Nr$   r%   r   )	r   rw   r   r8   rB   create_asyncrp   r   r:   r   r   r   r   r   [  s:       zMessageList.create_asyncNr   )orderlimit	page_sizerA   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   )rB   read_limitspagestreamr<   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   )rB   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   r<   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   )r_   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)r   
page_tokenpage_numberr   rA   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PageSizer   r   ry   rz   r{   rt   ru   paramsrv   )r   rw   rB   r   rp   r   r:   r<   r   r   r   r   r   rv   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   r   r   ry   rz   r{   r   N)r   rw   rB   r   rp   r   r:   r   r   r   r   r   -  s     	   zMessageList.page_async)
target_urlrA   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
        r{   )rB   domaintwiliorequestr   r:   r<   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)rB   r   r   Zrequest_asyncr   r:   r   r   r   r   get_page_async]  s    	zMessageList.get_page_async)r&   rA   c                 C   s   t | j| jd | jd |dS zm
        Constructs a MessageContext

        :param sid: The SID of the Message resource to update.
        r$   r%   r4   r?   rB   r:   r<   r&   r   r   r   r7   i  s    zMessageList.getc                 C   s   t | j| jd | jd |dS r   r   r   r   r   r   __call__v  s    zMessageList.__call__r@   c                 C   s   dS )rY   z<Twilio.Chat.V2.MessageList>r   rC   r   r   r   rh     s    zMessageList.__repr__)!r   r   r   r   rj   r6   r   rl   r   ri   r   r   r   r   r   intr   r   r	   r   r   r   r   r   r   r   r   r   r?   r7   r   rh   rn   r   r   r=   r   r     s   






A






?



 



&



$r   N)__doc__r   typingr   r   r   r   r   r   r	   Ztwilio.baser
   r   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   r?   r   r   r   r   r   r   <module>   s   $ Y  