o
    eL                     @   s   d 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 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 )za
This code was generated by
\ / _    _  _|   _  _
 | (_)\/(_)(_|\/| |(/_  v1.0.0
      /       /
    )deserialize)	serialize)values)InstanceContext)InstanceResource)ListResource)Pagec                       s   e Zd Z fddZdddZdddZejejejfdd	Zd
d Z	ejejejejejejfddZ
dd Zdd Zdd Z  ZS )WebhookListc                    s4   t t| | ||d| _djdi | j| _dS )a  
        Initialize the WebhookList

        :param Version version: Version that contains the resource
        :param service_sid: The SID of the Service that the Channel Webhook resource is associated with
        :param channel_sid: The SID of the Channel the Channel Webhook resource belongs to

        :returns: twilio.rest.chat.v2.service.channel.webhook.WebhookList
        :rtype: twilio.rest.chat.v2.service.channel.webhook.WebhookList
        service_sidchannel_sidz7/Services/{service_sid}/Channels/{channel_sid}/WebhooksN )superr	   __init__	_solutionformat_uri)selfversionr   r   	__class__r   ^/var/www/html/venv/lib/python3.10/site-packages/twilio/rest/chat/v2/service/channel/webhook.pyr      s   zWebhookList.__init__Nc                 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 int limit: Upper limit for the number of records to return. stream()
                          guarantees to never return more than limit.  Default is no limit
        :param int 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
        :rtype: list[twilio.rest.chat.v2.service.channel.webhook.WebhookInstance]
        	page_size)r   limit)_versionread_limitspagestream)r   r   r   limitsr   r   r   r   r   %   s   zWebhookList.streamc                 C   s   t | j||dS )ag  
        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 int limit: Upper limit for the number of records to return. list() guarantees
                          never to return more than limit.  Default is no limit
        :param int 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: Generator that will yield up to limit results
        :rtype: list[twilio.rest.chat.v2.service.channel.webhook.WebhookInstance]
        )r   r   )listr   )r   r   r   r   r   r   r   <   s   zWebhookList.listc                 C   s6   t |||d}| jjd| j|d}t| j|| jS )a  
        Retrieve a single page of WebhookInstance records from the API.
        Request is executed immediately

        :param str page_token: PageToken provided by the API
        :param int page_number: Page Number, this value is simply for client state
        :param int page_size: Number of records to return, defaults to 50

        :returns: Page of WebhookInstance
        :rtype: twilio.rest.chat.v2.service.channel.webhook.WebhookPage
        )	PageTokenr   PageSizeGET)methoduriparams)r   ofr   r   r   WebhookPager   )r   
page_tokenpage_numberr   dataresponser   r   r   r   N   s   zWebhookList.pagec                 C   s"   | j jjd|}t| j || jS )a?  
        Retrieve a specific page of WebhookInstance records from the API.
        Request is executed immediately

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

        :returns: Page of WebhookInstance
        :rtype: twilio.rest.chat.v2.service.channel.webhook.WebhookPage
        r"   )r   domaintwiliorequestr'   r   )r   
target_urlr+   r   r   r   get_pagea   s
   

zWebhookList.get_pagec           
      C   sd   t |||t|dd t|dd ||d}| jjd| j|d}	t| j|	| jd | jd d	S )
aj  
        Create the WebhookInstance

        :param WebhookInstance.Type type: The type of webhook
        :param unicode configuration_url: The URL of the webhook to call
        :param WebhookInstance.Method configuration_method: The HTTP method used to call `configuration.url`
        :param list[unicode] configuration_filters: The events that cause us to call the Channel Webhook
        :param list[unicode] configuration_triggers: A string that will cause us to call the webhook when it is found in a message body
        :param unicode configuration_flow_sid: The SID of the Studio Flow to call when an event occurs
        :param unicode configuration_retry_count: The number of times to retry the webhook if the first attempt fails

        :returns: The created WebhookInstance
        :rtype: twilio.rest.chat.v2.service.channel.webhook.WebhookInstance
        c                 S      | S Nr   er   r   r   <lambda>       z$WebhookList.create.<locals>.<lambda>c                 S   r1   r2   r   r3   r   r   r   r5      r6   )TypeConfiguration.UrlConfiguration.MethodConfiguration.FiltersConfiguration.TriggersConfiguration.FlowSidConfiguration.RetryCountPOSTr#   r$   r*   r   r   r
   )	r   r&   r   mapr   creater   WebhookInstancer   )
r   typeconfiguration_urlconfiguration_methodconfiguration_filtersconfiguration_triggersconfiguration_flow_sidconfiguration_retry_countr*   payloadr   r   r   rA   r   s    
zWebhookList.createc                 C      t | j| jd | jd |dS a  
        Constructs a WebhookContext

        :param sid: The SID of the Channel Webhook resource to fetch

        :returns: twilio.rest.chat.v2.service.channel.webhook.WebhookContext
        :rtype: twilio.rest.chat.v2.service.channel.webhook.WebhookContext
        r   r   r   r   sidWebhookContextr   r   r   rN   r   r   r   get      	zWebhookList.getc                 C   rK   rL   rO   rQ   r   r   r   __call__   rS   zWebhookList.__call__c                 C      dS )z
        Provide a friendly representation

        :returns: Machine friendly representation
        :rtype: str
        z<Twilio.Chat.V2.WebhookList>r   r   r   r   r   __repr__      zWebhookList.__repr__)NN)__name__
__module____qualname__r   r   r   r   unsetr   r0   rA   rR   rT   rX   __classcell__r   r   r   r   r	      s$    



'r	   c                       s,   e Zd Z fddZdd Zdd Z  ZS )r'   c                    s   t t| || || _dS )a  
        Initialize the WebhookPage

        :param Version version: Version that contains the resource
        :param Response response: Response from the API
        :param service_sid: The SID of the Service that the Channel Webhook resource is associated with
        :param channel_sid: The SID of the Channel the Channel Webhook resource belongs to

        :returns: twilio.rest.chat.v2.service.channel.webhook.WebhookPage
        :rtype: twilio.rest.chat.v2.service.channel.webhook.WebhookPage
        N)r   r'   r   r   )r   r   r+   solutionr   r   r   r      s   
zWebhookPage.__init__c                 C   s   t | j|| jd | jd dS )a  
        Build an instance of WebhookInstance

        :param dict payload: Payload response from the API

        :returns: twilio.rest.chat.v2.service.channel.webhook.WebhookInstance
        :rtype: twilio.rest.chat.v2.service.channel.webhook.WebhookInstance
        r   r   r
   )rB   r   r   r   rJ   r   r   r   get_instance   s   	zWebhookPage.get_instancec                 C   rU   )rV   z<Twilio.Chat.V2.WebhookPage>r   rW   r   r   r   rX      rY   zWebhookPage.__repr__)rZ   r[   r\   r   ra   rX   r^   r   r   r   r   r'      s    r'   c                       sV   e Zd Z fddZdd ZejejejejejejfddZdd Zd	d
 Z	  Z
S )rP   c                    s6   t t| | |||d| _djdi | j| _dS )a  
        Initialize the WebhookContext

        :param Version version: Version that contains the resource
        :param service_sid: The SID of the Service with the Channel to fetch the Webhook resource from
        :param channel_sid: The SID of the Channel the resource to fetch belongs to
        :param sid: The SID of the Channel Webhook resource to fetch

        :returns: twilio.rest.chat.v2.service.channel.webhook.WebhookContext
        :rtype: twilio.rest.chat.v2.service.channel.webhook.WebhookContext
        rM   z=/Services/{service_sid}/Channels/{channel_sid}/Webhooks/{sid}Nr   )r   rP   r   r   r   r   )r   r   r   r   rN   r   r   r   r      s   zWebhookContext.__init__c                 C   s8   | j jd| jd}t| j || jd | jd | jd dS )
        Fetch the WebhookInstance

        :returns: The fetched WebhookInstance
        :rtype: twilio.rest.chat.v2.service.channel.webhook.WebhookInstance
        r"   r#   r$   r   r   rN   rM   )r   fetchr   rB   r   r`   r   r   r   rd     s   zWebhookContext.fetchc           	   
   C   sj   t ||t|dd t|dd ||d}| jjd| j|d}t| j|| jd | jd | jd	 d
S ),  
        Update the WebhookInstance

        :param unicode configuration_url: The URL of the webhook to call
        :param WebhookInstance.Method configuration_method: The HTTP method used to call `configuration.url`
        :param list[unicode] configuration_filters: The events that cause us to call the Channel Webhook
        :param list[unicode] configuration_triggers: A string that will cause us to call the webhook when it is found in a message body
        :param unicode configuration_flow_sid: The SID of the Studio Flow to call when an event occurs
        :param unicode configuration_retry_count: The number of times to retry the webhook if the first attempt fails

        :returns: The updated WebhookInstance
        :rtype: twilio.rest.chat.v2.service.channel.webhook.WebhookInstance
        c                 S   r1   r2   r   r3   r   r   r   r5   +  r6   z'WebhookContext.update.<locals>.<lambda>c                 S   r1   r2   r   r3   r   r   r   r5   ,  r6   )r8   r9   r:   r;   r<   r=   r>   r?   r   r   rN   rM   )	r   r&   r   r@   r   updater   rB   r   )	r   rD   rE   rF   rG   rH   rI   r*   rJ   r   r   r   rf     s    	zWebhookContext.updatec                 C   s   | j jd| jdS )~
        Deletes the WebhookInstance

        :returns: True if delete succeeds, False otherwise
        :rtype: bool
        DELETErc   )r   deleter   rW   r   r   r   ri   ;  s   zWebhookContext.deletec                 C   $   d dd | j D }d|S )rV    c                 s        | ]\}}d  ||V  qdS z{}={}Nr   .0kvr   r   r   	<genexpr>K      z*WebhookContext.__repr__.<locals>.<genexpr>z"<Twilio.Chat.V2.WebhookContext {}>joinr   itemsr   r   contextr   r   r   rX   D     
zWebhookContext.__repr__)rZ   r[   r\   r   rd   r   r]   rf   ri   rX   r^   r   r   r   r   rP      s    
&	rP   c                       s   e Zd ZG dd deZG dd deZd$ fdd	Zedd	 Zed
d Z	edd Z
edd Zedd Zedd Zedd Zedd Zedd Zedd Zdd ZejejejejejejfddZd d! Zd"d# Z  ZS )%rB   c                   @   s   e Zd ZdZdZdZdS )zWebhookInstance.TypewebhooktriggerstudioN)rZ   r[   r\   WEBHOOKTRIGGERSTUDIOr   r   r   r   r7   Q  s    r7   c                   @   s   e Zd ZdZdZdS )zWebhookInstance.Methodr"   r>   N)rZ   r[   r\   r"   r>   r   r   r   r   MethodV  s    r   Nc                    s   t t| | |d|d|d|d|d|d|dt|dt|d	d
	| _d| _|||pA| jd d| _dS )z
        Initialize the WebhookInstance

        :returns: twilio.rest.chat.v2.service.channel.webhook.WebhookInstance
        :rtype: twilio.rest.chat.v2.service.channel.webhook.WebhookInstance
        rN   account_sidr   r   rC   urlconfigurationdate_createddate_updated)	rN   r   r   r   rC   r   r   r   r   NrM   )	r   rB   r   rR   r   iso8601_datetime_properties_contextr   )r   r   rJ   r   r   rN   r   r   r   r   Z  s    zWebhookInstance.__init__c                 C   s6   | j du rt| j| jd | jd | jd d| _ | j S )a5  
        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
        :rtype: twilio.rest.chat.v2.service.channel.webhook.WebhookContext
        Nr   r   rN   rM   )r   rP   r   r   rW   r   r   r   _proxyx  s   
	zWebhookInstance._proxyc                 C   
   | j d S )zb
        :returns: The unique string that identifies the resource
        :rtype: unicode
        rN   r   rW   r   r   r   rN        
zWebhookInstance.sidc                 C   r   )zd
        :returns: The SID of the Account that created the resource
        :rtype: unicode
        r   r   rW   r   r   r   r     r   zWebhookInstance.account_sidc                 C   r   )z
        :returns: The SID of the Service that the Channel Webhook resource is associated with
        :rtype: unicode
        r   r   rW   r   r   r   r     r   zWebhookInstance.service_sidc                 C   r   )zr
        :returns: The SID of the Channel the Channel Webhook resource belongs to
        :rtype: unicode
        r   r   rW   r   r   r   r     r   zWebhookInstance.channel_sidc                 C   r   )zG
        :returns: The type of webhook
        :rtype: unicode
        rC   r   rW   r   r   r   rC     r   zWebhookInstance.typec                 C   r   )zd
        :returns: The absolute URL of the Channel Webhook resource
        :rtype: unicode
        r   r   rW   r   r   r   r     r   zWebhookInstance.urlc                 C   r   )z
        :returns: The JSON string that describes the configuration object for the channel webhook
        :rtype: dict
        r   r   rW   r   r   r   r     r   zWebhookInstance.configurationc                 C   r   )zt
        :returns: The ISO 8601 date and time in GMT when the resource was created
        :rtype: datetime
        r   r   rW   r   r   r   r     r   zWebhookInstance.date_createdc                 C   r   )zy
        :returns: The ISO 8601 date and time in GMT when the resource was last updated
        :rtype: datetime
        r   r   rW   r   r   r   r     r   zWebhookInstance.date_updatedc                 C   
   | j  S )rb   )r   rd   rW   r   r   r   rd        
zWebhookInstance.fetchc                 C   s   | j j||||||dS )re   )rD   rE   rF   rG   rH   rI   )r   rf   )r   rD   rE   rF   rG   rH   rI   r   r   r   rf     s   zWebhookInstance.updatec                 C   r   )rg   )r   ri   rW   r   r   r   ri     r   zWebhookInstance.deletec                 C   rj   )rV   rk   c                 s   rl   rm   rn   ro   r   r   r   rs     rt   z+WebhookInstance.__repr__.<locals>.<genexpr>z#<Twilio.Chat.V2.WebhookInstance {}>ru   rx   r   r   r   rX      rz   zWebhookInstance.__repr__r2   )rZ   r[   r\   objectr7   r   r   propertyr   rN   r   r   r   rC   r   r   r   r   rd   r   r]   rf   ri   rX   r^   r   r   r   r   rB   O  sD    









	
	rB   N)__doc__twilio.baser   r   r   twilio.base.instance_contextr   twilio.base.instance_resourcer   twilio.base.list_resourcer   twilio.base.pager   r	   r'   rP   rB   r   r   r   r   <module>   s    2-_