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d
ddZ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feeef edef eee ef e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feeef edef eee ef eee ef eeef eeef d dddZed
ddZ  ZS )WebhookInstancec                   @   s   e Zd ZdZdZdS )WebhookInstance.MethodGETPOSTN)__name__
__module____qualname__r   r    r   r   j/var/www/html/api-medvista/venv/lib/python3.8/site-packages/twilio/rest/chat/v2/service/channel/webhook.pyMethod   s   r   c                   @   s   e Zd ZdZdZdZdS )WebhookInstance.TypeZwebhooktriggerZstudioN)r   r   r   ZWEBHOOKZTRIGGERZSTUDIOr   r   r   r   Type   s   r   N)versionpayloadservice_sidchannel_sidsidc                    s   t  | |d| _|d| _|d| _|d| _|d| _|d| _|d| _	t
|d| _t
|d	| _|||p| jd
| _d | _d S )Nr#   account_sidr!   r"   typeurlconfigurationdate_createddate_updatedr!   r"   r#   )super__init__getr#   r$   r!   r"   r%   r&   r'   r
   Ziso8601_datetimer(   r)   	_solution_context)selfr   r    r!   r"   r#   	__class__r   r   r,   0   s&    zWebhookInstance.__init__WebhookContext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: WebhookContext for this WebhookInstance
        Nr!   r"   r#   r*   )r/   r3   _versionr.   r0   r   r   r   _proxyO   s    
zWebhookInstance._proxyc                 C   s
   | j  S )j
        Deletes the WebhookInstance


        :returns: True if delete succeeds, False otherwise
        )r8   deleter7   r   r   r   r:   `   s    zWebhookInstance.deletec                    s   | j  I dH S )
        Asynchronous coroutine that deletes the WebhookInstance


        :returns: True if delete succeeds, False otherwise
        N)r8   delete_asyncr7   r   r   r   r<   i   s    zWebhookInstance.delete_asyncc                 C   s
   | j  S )[
        Fetch the WebhookInstance


        :returns: The fetched WebhookInstance
        )r8   fetchr7   r   r   r   r>   r   s    zWebhookInstance.fetchc                    s   | j  I dH S )u
        Asynchronous coroutine to fetch the WebhookInstance


        :returns: The fetched WebhookInstance
        N)r8   fetch_asyncr7   r   r   r   r@   {   s    zWebhookInstance.fetch_asyncr   configuration_urlconfiguration_methodconfiguration_filtersconfiguration_triggersconfiguration_flow_sidconfiguration_retry_countr5   c                 C   s   | j j||||||dS )  
        Update the WebhookInstance

        :param configuration_url: The URL of the webhook to call using the `configuration.method`.
        :param configuration_method:
        :param configuration_filters: The events that cause us to call the Channel Webhook. Used when `type` is `webhook`. This parameter takes only one event. To specify more than one event, repeat this parameter for each event. For the list of possible events, see [Webhook Event Triggers](https://www.twilio.com/docs/chat/webhook-events#webhook-event-trigger).
        :param configuration_triggers: A string that will cause us to call the webhook when it is present in a message body. This parameter takes only one trigger string. To specify more than one, repeat this parameter for each trigger string up to a total of 5 trigger strings. Used only when `type` = `trigger`.
        :param configuration_flow_sid: The SID of the Studio [Flow](https://www.twilio.com/docs/studio/rest-api/flow) to call when an event in `configuration.filters` occurs. Used only when `type` = `studio`.
        :param configuration_retry_count: The number of times to retry the webhook if the first attempt fails. Can be an integer between 0 and 3, inclusive, and the default is 0.

        :returns: The updated WebhookInstance
        rB   rC   rD   rE   rF   rG   )r8   updater0   rB   rC   rD   rE   rF   rG   r   r   r   rJ      s    zWebhookInstance.updatec                    s   | j j||||||dI dH S )(  
        Asynchronous coroutine to update the WebhookInstance

        :param configuration_url: The URL of the webhook to call using the `configuration.method`.
        :param configuration_method:
        :param configuration_filters: The events that cause us to call the Channel Webhook. Used when `type` is `webhook`. This parameter takes only one event. To specify more than one event, repeat this parameter for each event. For the list of possible events, see [Webhook Event Triggers](https://www.twilio.com/docs/chat/webhook-events#webhook-event-trigger).
        :param configuration_triggers: A string that will cause us to call the webhook when it is present in a message body. This parameter takes only one trigger string. To specify more than one, repeat this parameter for each trigger string up to a total of 5 trigger strings. Used only when `type` = `trigger`.
        :param configuration_flow_sid: The SID of the Studio [Flow](https://www.twilio.com/docs/studio/rest-api/flow) to call when an event in `configuration.filters` occurs. Used only when `type` = `studio`.
        :param configuration_retry_count: The number of times to retry the webhook if the first attempt fails. Can be an integer between 0 and 3, inclusive, and the default is 0.

        :returns: The updated WebhookInstance
        rI   N)r8   update_asyncrK   r   r   r   rM      s    zWebhookInstance.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+WebhookInstance.__repr__.<locals>.<genexpr>z#<Twilio.Chat.V2.WebhookInstance {}>joinr.   itemsrR   r0   contextr   r   r   __repr__   s    zWebhookInstance.__repr__)N)r   r   r   objectr   r   r   r   strr   r   r,   propertyr8   boolr:   r<   r>   r@   r   unsetr   r   intrJ   rM   r]   __classcell__r   r   r1   r   r      s^    
			



 



r   c                	       sF  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ejejejejfeeef edef eee ef e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feeef edef eee ef eee ef eeef eeef e	dddZedddZ  ZS )r3   )r   r!   r"   r#   c                    s.   t  | |||d| _djf | j| _dS )a-  
        Initialize the WebhookContext

        :param version: Version that contains the resource
        :param service_sid: The SID of the [Service](https://www.twilio.com/docs/chat/rest/service-resource) with the Channel that has the Webhook resource to update.
        :param channel_sid: The SID of the [Channel](https://www.twilio.com/docs/chat/channels) the Channel Webhook resource to update belongs to. This value can be the Channel resource's `sid` or `unique_name`.
        :param sid: The SID of the Channel Webhook resource to update.
        r*   z=/Services/{service_sid}/Channels/{channel_sid}/Webhooks/{sid}Nr+   r,   r.   rR   _uri)r0   r   r!   r"   r#   r1   r   r   r,      s    	zWebhookContext.__init__r4   c                 C   s   t i }| jjd| j|dS )r9   DELETEmethoduriheaders)r   ofr6   r:   rf   r0   rk   r   r   r   r:      s    
zWebhookContext.deletec                    s$   t i }| jjd| j|dI dH S )r;   rg   rh   N)r   rl   r6   r<   rf   rm   r   r   r   r<      s    
  zWebhookContext.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Acceptr   rh   r!   r"   r#   r*   )r   rl   r6   r>   rf   r   r.   r0   rk   r    r   r   r   r>      s    
zWebhookContext.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?   rn   ro   r   rh   Nr!   r"   r#   r*   )r   rl   r6   r@   rf   r   r.   rp   r   r   r   r@     s    
  zWebhookContext.fetch_asyncr   rA   c           
   
   C   s   t ||t|dd t|dd ||d}t i }d|d< d|d< | jjd	| j||d
}	t| j|	| jd | jd | jd dS )rH   c                 S   s   | S Nr   er   r   r   <lambda>F      z'WebhookContext.update.<locals>.<lambda>c                 S   s   | S rq   r   rr   r   r   r   rt   I  ru   Configuration.UrlConfiguration.MethodConfiguration.FiltersConfiguration.TriggersConfiguration.FlowSidConfiguration.RetryCount!application/x-www-form-urlencodedContent-Typern   ro   r   ri   rj   datark   r!   r"   r#   r*   )	r   rl   r   mapr6   rJ   rf   r   r.   
r0   rB   rC   rD   rE   rF   rG   r   rk   r    r   r   r   rJ   +  s>      
   zWebhookContext.updatec           
   
      s   t ||t|dd t|dd ||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 )rL   c                 S   s   | S rq   r   rr   r   r   r   rt   |  ru   z-WebhookContext.update_async.<locals>.<lambda>c                 S   s   | S rq   r   rr   r   r   r   rt     ru   rv   r}   r~   rn   ro   r   r   Nr!   r"   r#   r*   )	r   rl   r   r   r6   rM   rf   r   r.   r   r   r   r   rM   a  s>      
   zWebhookContext.update_asyncc                 C   s$   d dd | j D }d|S )rN   rO   c                 s   s   | ]\}}d  ||V  qdS rP   rQ   rS   r   r   r   rW     s     z*WebhookContext.__repr__.<locals>.<genexpr>z"<Twilio.Chat.V2.WebhookContext {}>rX   r[   r   r   r   r]     s    zWebhookContext.__repr__)r   r   r   r   r_   r,   ra   r:   r<   r   r>   r@   r   rb   r   r^   r   rc   rJ   rM   r]   rd   r   r   r1   r   r3      sH   



8



6r3   c                   @   s2   e Zd Zeeef edddZedddZdS )WebhookPage)r    r5   c                 C   s   t | j|| jd | jd dS )zm
        Build an instance of WebhookInstance

        :param payload: Payload response from the API
        r!   r"   r!   r"   )r   r6   r.   )r0   r    r   r   r   get_instance  s    zWebhookPage.get_instancer4   c                 C   s   dS )rN   z<Twilio.Chat.V2.WebhookPage>r   r7   r   r   r   r]     s    zWebhookPage.__repr__N)	r   r   r   r   r_   r   r   r   r]   r   r   r   r   r     s   r   c                
       sD  e Zd Zeeed fddZejejejejejejfdeee	f ede	f ee
e e	f e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fdeee	f ede	f ee
e e	f ee
e e	f eee	f eee	f edd	d
Zd'ee ee ee dddZd(ee ee ee dddZd)ee ee e
e dddZd*ee ee e
e dddZejejejfeee	f eee	f eee	f edddZejejej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 )+WebhookList)r   r!   r"   c                    s,   t  | ||d| _djf | j| _dS )a  
        Initialize the WebhookList

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

        r   z7/Services/{service_sid}/Channels/{channel_sid}/WebhooksNre   )r0   r   r!   r"   r1   r   r   r,     s    	zWebhookList.__init__r   r   )r%   rB   rC   rD   rE   rF   rG   r5   c                 C   s   t |||t|dd t|dd ||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 WebhookInstance

        :param type:
        :param configuration_url: The URL of the webhook to call using the `configuration.method`.
        :param configuration_method:
        :param configuration_filters: The events that cause us to call the Channel Webhook. Used when `type` is `webhook`. This parameter takes only one event. To specify more than one event, repeat this parameter for each event. For the list of possible events, see [Webhook Event Triggers](https://www.twilio.com/docs/chat/webhook-events#webhook-event-trigger).
        :param configuration_triggers: A string that will cause us to call the webhook when it is present in a message body. This parameter takes only one trigger string. To specify more than one, repeat this parameter for each trigger string up to a total of 5 trigger strings. Used only when `type` = `trigger`.
        :param configuration_flow_sid: The SID of the Studio [Flow](https://www.twilio.com/docs/studio/rest-api/flow) to call when an event in `configuration.filters` occurs. Used only when `type` is `studio`.
        :param configuration_retry_count: The number of times to retry the webhook if the first attempt fails. Can be an integer between 0 and 3, inclusive, and the default is 0.

        :returns: The created WebhookInstance
        c                 S   s   | S rq   r   rr   r   r   r   rt     ru   z$WebhookList.create.<locals>.<lambda>c                 S   s   | S rq   r   rr   r   r   r   rt     ru   r   rw   rx   ry   rz   r{   r|   r~   r}   rn   ro   r   r   r!   r"   r   )	r   rl   r   r   r6   createrf   r   r.   r0   r%   rB   rC   rD   rE   rF   rG   r   rk   r    r   r   r   r     s>         zWebhookList.createc                    s   t |||t|dd t|dd ||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 )a3  
        Asynchronously create the WebhookInstance

        :param type:
        :param configuration_url: The URL of the webhook to call using the `configuration.method`.
        :param configuration_method:
        :param configuration_filters: The events that cause us to call the Channel Webhook. Used when `type` is `webhook`. This parameter takes only one event. To specify more than one event, repeat this parameter for each event. For the list of possible events, see [Webhook Event Triggers](https://www.twilio.com/docs/chat/webhook-events#webhook-event-trigger).
        :param configuration_triggers: A string that will cause us to call the webhook when it is present in a message body. This parameter takes only one trigger string. To specify more than one, repeat this parameter for each trigger string up to a total of 5 trigger strings. Used only when `type` = `trigger`.
        :param configuration_flow_sid: The SID of the Studio [Flow](https://www.twilio.com/docs/studio/rest-api/flow) to call when an event in `configuration.filters` occurs. Used only when `type` is `studio`.
        :param configuration_retry_count: The number of times to retry the webhook if the first attempt fails. Can be an integer between 0 and 3, inclusive, and the default is 0.

        :returns: The created WebhookInstance
        c                 S   s   | S rq   r   rr   r   r   r   rt   %  ru   z*WebhookList.create_async.<locals>.<lambda>c                 S   s   | S rq   r   rr   r   r   r   rt   (  ru   r   r~   r}   rn   ro   r   r   Nr!   r"   r   )	r   rl   r   r   r6   create_asyncrf   r   r.   r   r   r   r   r     s>         zWebhookList.create_asyncN)limit	page_sizer5   c                 C   s0   | j ||}| j|d d}| j ||d S )a]  
        Streams WebhookInstance 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 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   )r6   read_limitspagestreamr0   r   r   Zlimitsr   r   r   r   r   ?  s    zWebhookList.streamc                    s6   | j ||}| j|d dI dH }| j ||d S )al  
        Asynchronously streams WebhookInstance 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 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   )r6   r   
page_asyncstream_asyncr   r   r   r   r   X  s    zWebhookList.stream_asyncc                 C   s   t | j||dS )a  
        Lists WebhookInstance records from the API as a list.
        Unlike stream(), this operation is eager and will load `limit` records into
        memory before returning.

        :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   )listr   r0   r   r   r   r   r   r   q  s    zWebhookList.listc                    s$   dd | j ||dI dH 2 I dH S )a	  
        Asynchronously lists WebhookInstance records from the API as a list.
        Unlike stream(), this operation is eager and will load `limit` records into
        memory before returning.

        :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 rq   r   )rT   recordr   r   r   
<listcomp>  s   z*WebhookList.list_async.<locals>.<listcomp>r   N)r   r   r   r   r   
list_async  s    
zWebhookList.list_async)
page_tokenpage_numberr   r5   c                 C   sN   t |||d}t ddi}d|d< | jjd| j||d}t| j|| jS )as  
        Retrieve a single page of WebhookInstance records from the API.
        Request is executed immediately

        :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 WebhookInstance
        Z	PageTokenr   ZPageSizer~   r}   rn   ro   r   ri   rj   paramsrk   )r   rl   r6   r   rf   r   r.   r0   r   r   r   r   rk   responser   r   r   r     s       zWebhookList.pagec                    sT   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 WebhookInstance records from the API.
        Request is executed immediately

        :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 WebhookInstance
        r   r~   r}   rn   ro   r   r   N)r   rl   r6   r   rf   r   r.   r   r   r   r   r     s       zWebhookList.page_async)
target_urlr5   c                 C   s"   | j jjd|}t| j || jS )z
        Retrieve a specific page of WebhookInstance records from the API.
        Request is executed immediately

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

        :returns: Page of WebhookInstance
        r   )r6   domaintwiliorequestr   r.   r0   r   r   r   r   r   get_page  s    	zWebhookList.get_pagec                    s(   | j jjd|I dH }t| j || jS )a  
        Asynchronously retrieve a specific page of WebhookInstance records from the API.
        Request is executed immediately

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

        :returns: Page of WebhookInstance
        r   N)r6   r   r   Zrequest_asyncr   r.   r   r   r   r   get_page_async  s    	zWebhookList.get_page_async)r#   r5   c                 C   s   t | j| jd | jd |dS zu
        Constructs a WebhookContext

        :param sid: The SID of the Channel Webhook resource to update.
        r!   r"   r*   r3   r6   r.   r0   r#   r   r   r   r-      s    zWebhookList.getc                 C   s   t | j| jd | jd |dS r   r   r   r   r   r   __call__  s    zWebhookList.__call__r4   c                 C   s   dS )rN   z<Twilio.Chat.V2.WebhookList>r   r7   r   r   r   r]     s    zWebhookList.__repr__)NN)NN)NN)NN) r   r   r   r   r_   r,   r   rb   r   r^   r   rc   r   r   r   r   r   r   r	   r   r   r   r   r   r   r   r   r3   r-   r   r]   rd   r   r   r1   r   r     s   



;



:        


#


!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   r3   r   r   r   r   r   r   <module>   s   $ 2 X