o
    f>h                     @   s   d Z ddlmZ ddlmZmZmZmZmZmZm	Z	 ddl
mZmZmZ ddlmZ ddlmZ ddlmZ ddlmZ dd	lmZ G d
d deZG dd deZG dd deZG dd deZdS )a  
    This code was generated by
   ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
    |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
    |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \

    Twilio - Chat
    This is the public Twilio REST API.

    NOTE: This class is auto generated by OpenAPI Generator.
    https://openapi-generator.tech
    Do not edit the class manually.
    )datetime)AnyDictListOptionalUnionIteratorAsyncIterator)deserialize	serializevalues)InstanceContext)InstanceResource)ListResource)Version)Pagec                       s  e Zd ZG dd deZG dd deZ	 	d&dedeee	f ded	ed
e
e f
 fddZed'ddZdefddZdefddZd(ddZd(ddZejejejejejejfdeeef dedef deee ef deee ef deeef deeef dd fd d!Zejejejejejejfdeeef dedef deee ef deee ef deeef deeef dd fd"d#Zdefd$d%Z  ZS ))WebhookInstancec                   @   s   e Zd ZdZdZdS )WebhookInstance.MethodGETPOSTN)__name__
__module____qualname__r   r    r   r   ^/var/www/html/venv/lib/python3.10/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.TypewebhooktriggerstudioN)r   r   r   WEBHOOKTRIGGER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	| _|||pH| 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
   iso8601_datetimer-   r.   	_solution_context)selfr$   r%   r&   r'   r(   	__class__r   r   r1   0   s&   
zWebhookInstance.__init__returnWebhookContextc                 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: WebhookContext for this WebhookInstance
        Nr&   r'   r(   r/   )r5   r:   _versionr4   r6   r   r   r   _proxyO   s   
zWebhookInstance._proxyc                 C   
   | j  S )j
        Deletes the WebhookInstance


        :returns: True if delete succeeds, False otherwise
        )r=   deleter<   r   r   r   r@   `      
zWebhookInstance.deletec                       | j  I dH S )
        Asynchronous coroutine that deletes the WebhookInstance


        :returns: True if delete succeeds, False otherwise
        N)r=   delete_asyncr<   r   r   r   rD   i      zWebhookInstance.delete_asyncc                 C   r>   )[
        Fetch the WebhookInstance


        :returns: The fetched WebhookInstance
        )r=   fetchr<   r   r   r   rG   r   rA   zWebhookInstance.fetchc                    rB   )u
        Asynchronous coroutine to fetch the WebhookInstance


        :returns: The fetched WebhookInstance
        N)r=   fetch_asyncr<   r   r   r   rI   {   rE   zWebhookInstance.fetch_asyncconfiguration_urlconfiguration_methodr   configuration_filtersconfiguration_triggersconfiguration_flow_sidconfiguration_retry_countc                 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
        rJ   rK   rL   rM   rN   rO   )r=   updater6   rJ   rK   rL   rM   rN   rO   r   r   r   rR      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
        rQ   N)r=   update_asyncrS   r   r   r   rU      s   zWebhookInstance.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+WebhookInstance.__repr__.<locals>.<genexpr>z#<Twilio.Chat.V2.WebhookInstance {}>joinr4   itemsr\   r6   contextr   r   r   __repr__      
zWebhookInstance.__repr__N)r9   r:   )r9   r   )r   r   r   objectr   r#   r   r   strr   r   r1   propertyr=   boolr@   rD   rG   rI   r   unsetr   r   intrR   rU   rh   __classcell__r   r   r7   r   r      s    
	
	
	




 




r   c                       sd  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ejejejejfdeeef dedef deee ef deee ef deeef deeef de	fddZejejejejejejfdeeef dedef deee ef deee ef deeef deeef de	fddZdefddZ  ZS )r:   r$   r&   r'   r(   c                    s2   t  | |||d| _djdi | 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}Nr   r0   r1   r4   r\   _uri)r6   r$   r&   r'   r(   r7   r   r   r1      s   	zWebhookContext.__init__r9   c                 C   s   t i }| jjd| j|dS )r?   DELETEmethoduriheaders)r   ofr;   r@   rs   r6   rx   r   r   r   r@      s   
zWebhookContext.deletec                    s&   t i }| jjd| j|dI dH S )rC   rt   ru   N)r   ry   r;   rD   rs   rz   r   r   r   rD      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 )	rF   application/jsonAcceptr   ru   r&   r'   r(   r/   )r   ry   r;   rG   rs   r   r4   r6   rx   r%   r   r   r   rG      s   
zWebhookContext.fetchc                    sT   t i }d|d< | jjd| j|dI dH }t| j|| jd | jd | jd d	S )
rH   r{   r|   r   ru   Nr&   r'   r(   r/   )r   ry   r;   rI   rs   r   r4   r}   r   r   r   rI     s   
zWebhookContext.fetch_asyncrJ   rK   r   rL   rM   rN   rO   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 )rP   c                 S      | S rj   r   er   r   r   <lambda>F      z'WebhookContext.update.<locals>.<lambda>c                 S   r~   rj   r   r   r   r   r   r   I  r   Configuration.UrlConfiguration.MethodConfiguration.FiltersConfiguration.TriggersConfiguration.FlowSidConfiguration.RetryCount!application/x-www-form-urlencodedContent-Typer{   r|   r   rv   rw   datarx   r&   r'   r(   r/   )	r   ry   r   mapr;   rR   rs   r   r4   
r6   rJ   rK   rL   rM   rN   rO   r   rx   r%   r   r   r   rR   +  s4   

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 )rT   c                 S   r~   rj   r   r   r   r   r   r   |  r   z-WebhookContext.update_async.<locals>.<lambda>c                 S   r~   rj   r   r   r   r   r   r     r   r   r   r   r{   r|   r   r   Nr&   r'   r(   r/   )	r   ry   r   r   r;   rU   rs   r   r4   r   r   r   r   rU   a  s6   

zWebhookContext.update_asyncc                 C   rV   )rW   rX   c                 s   rY   rZ   r[   r]   r   r   r   ra     rb   z*WebhookContext.__repr__.<locals>.<genexpr>z"<Twilio.Chat.V2.WebhookContext {}>rc   rf   r   r   r   rh     ri   zWebhookContext.__repr__)r   r   r   r   rl   r1   rn   r@   rD   r   rG   rI   r   ro   r   rk   r   rp   rR   rU   rh   rq   r   r   r7   r   r:      sb    




8




6r:   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 )WebhookPager%   r9   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   r;   r4   )r6   r%   r   r   r   get_instance  s   zWebhookPage.get_instancec                 C      dS )rW   z<Twilio.Chat.V2.WebhookPage>r   r<   r   r   r   rh        zWebhookPage.__repr__N)	r   r   r   r   rl   r   r   r   rh   r   r   r   r   r     s    r   c                       s  e Zd Zdededef fddZejejejejejejfdddeee	f d	ed
e	f dee
e e	f dee
e e	f deee	f deee	f defddZejejejejejejfdddeee	f d	ed
e	f dee
e e	f dee
e e	f deee	f deee	f defddZ		d1dee dee dee fddZ		d1dee dee dee fddZ		d1dee dee de
e fddZ		d1dee dee de
e fddZejejej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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/d0Z  ZS )2WebhookListr$   r&   r'   c                    s0   t  | ||d| _djdi | 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}/WebhooksNr   rr   )r6   r$   r&   r'   r7   r   r   r1     s   	zWebhookList.__init__r*   r   rJ   rK   r   rL   rM   rN   rO   r9   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   r~   rj   r   r   r   r   r   r     r   z$WebhookList.create.<locals>.<lambda>c                 S   r~   rj   r   r   r   r   r   r     r   r#   r   r   r   r   r   r   r   r   r{   r|   r   r   r&   r'   r   )	r   ry   r   r   r;   creaters   r   r4   r6   r*   rJ   rK   rL   rM   rN   rO   r   rx   r%   r   r   r   r     s4   
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   r~   rj   r   r   r   r   r   r   %  r   z*WebhookList.create_async.<locals>.<lambda>c                 S   r~   rj   r   r   r   r   r   r   (  r   r   r   r   r{   r|   r   r   Nr&   r'   r   )	r   ry   r   r   r;   create_asyncrs   r   r4   r   r   r   r   r     s6   
zWebhookList.create_asyncNlimit	page_sizec                 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   )r;   read_limitspagestreamr6   r   r   limitsr   r   r   r   r   ?  s   zWebhookList.streamc                    s8   | 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   )r;   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   r6   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 rj   r   )r^   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_numberc                 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
        	PageTokenr   PageSizer   r   r{   r|   r   rv   rw   paramsrx   )r   ry   r;   r   rs   r   r4   r6   r   r   r   r   rx   responser   r   r   r     s   
zWebhookList.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 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   r{   r|   r   r   N)r   ry   r;   r   rs   r   r4   r   r   r   r   r     s   
zWebhookList.page_async
target_urlc                 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   )r;   domaintwiliorequestr   r4   r6   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)r;   r   r   request_asyncr   r4   r   r   r   r   get_page_async  s   	zWebhookList.get_page_asyncr(   c                 C      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/   r:   r;   r4   r6   r(   r   r   r   r2         zWebhookList.getc                 C   r   r   r   r   r   r   r   __call__  r   zWebhookList.__call__c                 C   r   )rW   z<Twilio.Chat.V2.WebhookList>r   r<   r   r   r   rh     r   zWebhookList.__repr__)NN) r   r   r   r   rl   r1   r   ro   r   rk   r   rp   r   r   r   r   r   r   r	   r   r   r   r   r   r   r   r   r:   r2   r   rh   rq   r   r   r7   r   r     s    



	
;



	
:







#



!r   N)__doc__r   typingr   r   r   r   r   r   r	   twilio.baser
   r   r   twilio.base.instance_contextr   twilio.base.instance_resourcer   twilio.base.list_resourcer   twilio.base.versionr   twilio.base.pager   r   r:   r   r   r   r   r   r   <module>   s    $ 2 X