o
    lWiK                     @   s   d dl Z d dlmZ ddlmZ ddlmZmZ ddlm	Z	m
Z
 ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ 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  e !e j"dZ#G dd dZ$G dd dZ%dS )    N)JSONDecodeError   )ApiError)AsyncClientWrapperSyncClientWrapper)AsyncHttpResponseHttpResponse)jsonable_encoder)RequestOptions)'convert_and_respect_annotation_metadata)construct_type)UnprocessableEntityError)#DeleteWorkspaceWebhookResponseModel)HttpValidationError)"PatchWorkspaceWebhookResponseModel)WebhookHmacSettings)#WorkspaceCreateWebhookResponseModel)!WorkspaceWebhookListResponseModel.c                   @      e Zd ZdefddZddddeje deje de	e
 fd	d
Zdddedeje de	e fddZdddedeje de	e fddZdddedededeje de	e f
ddZdS )RawWebhooksClientclient_wrapperc                C   
   || _ d S N_client_wrapperselfr    r   b/var/www/html/asistente-voz-ia/venv/lib/python3.10/site-packages/elevenlabs/webhooks/raw_client.py__init__      
zRawWebhooksClient.__init__Ninclude_usagesrequest_optionsr"   r#   returnc             	   C   s   | j jjddd|i|d}z>d|j  krdk r.n ntttt| d}t	||dW S |jd	krFt
t|jtttt| dd
| }W n ty^   t|jt|j|jdw t|jt|j|d)a  
        List all webhooks for a workspace

        Parameters
        ----------
        include_usages : typing.Optional[bool]
            Whether to include active usages of the webhook, only usable by admins

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[WorkspaceWebhookListResponseModel]
            Successful Response
        v1/workspace/webhooksGETr"   methodparamsr#      ,  type_object_responsedata  headersbodystatus_coder4   r5   )r   httpx_clientrequestr7   typingcastr   r   jsonr   r   dictr4   r   r   r   textr   r"   r#   	_response_data_response_jsonr   r   r   list   sB   

zRawWebhooksClient.listr#   settingsc             	   C   s   | j jjdddt|tddiddi|td}z>d	|j  kr"d
k r7n ntt	t
t	| d}t||dW S |jdkrOtt|jttt
t| dd| }W n tyg   t|jt|j|jdw t|jt|j|d)a  
        Create a new webhook for the workspace with the specified authentication type.

        Parameters
        ----------
        settings : WebhookHmacSettings
            Webhook settings object containing auth_type and corresponding configuration

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[WorkspaceCreateWebhookResponseModel]
            Successful Response
        r%   POSTrE   writer.   
annotation	directioncontent-typeapplication/jsonr(   r<   r4   r#   omitr*   r+   r,   r/   r2   r3   r6   )r   r8   r9   r   r   OMITr7   r:   r;   r   r   r<   r   r   r=   r4   r   r   r   r>   r   rE   r#   r@   rA   rB   r   r   r   createR   sL   

zRawWebhooksClient.create
webhook_idc             	   C   s   | j jjdt| d|d}z>d|j  krdk r0n ntttt|	 d}t
||dW S |jdkrHtt|jtttt|	 dd	|	 }W n ty`   t|jt|j|jd
w t|jt|j|d
)a  
        Delete the specified workspace webhook

        Parameters
        ----------
        webhook_id : str
            The unique ID for the webhook

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[DeleteWorkspaceWebhookResponseModel]
            Successful Response
        v1/workspace/webhooks/DELETEr(   r#   r*   r+   r,   r/   r2   r3   r6   )r   r8   r9   r	   r7   r:   r;   r   r   r<   r   r   r=   r4   r   r   r   r>   r   rR   r#   r@   rA   rB   r   r   r   delete   s>   

zRawWebhooksClient.deleteis_disablednamec             	   C   s   | j jjdt| d||dddi|td}z>d|j  kr#dk r8n nttt	t|
 d	}t||d
W S |jdkrPtt|jttt	t|
 d	d|
 }W n tyh   t|jt|j|jdw t|jt|j|d)a6  
        Update the specified workspace webhook

        Parameters
        ----------
        webhook_id : str
            The unique ID for the webhook

        is_disabled : bool
            Whether to disable or enable the webhook

        name : str
            The display name of the webhook (used for display purposes only).

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        HttpResponse[PatchWorkspaceWebhookResponseModel]
            Successful Response
        rS   PATCHrX   rY   rK   rL   rM   r*   r+   r,   r/   r2   r3   r6   )r   r8   r9   r	   rO   r7   r:   r;   r   r   r<   r   r   r=   r4   r   r   r   r>   r   rR   rX   rY   r#   r@   rA   rB   r   r   r   update   sJ   

zRawWebhooksClient.update)__name__
__module____qualname__r   r   r:   Optionalboolr
   r   r   rC   r   r   rQ   strr   rW   r   r]   r   r   r   r   r      L    
6
<
3r   c                   @   r   )AsyncRawWebhooksClientr   c                C   r   r   r   r   r   r   r   r     r    zAsyncRawWebhooksClient.__init__Nr!   r"   r#   r$   c             	      s   | j jjddd|i|dI dH }z>d|j  krdk r2n ntttt| d}t	||d	W S |jd
krJt
t|jtttt| dd| }W n tyb   t|jt|j|jdw t|jt|j|d)a  
        List all webhooks for a workspace

        Parameters
        ----------
        include_usages : typing.Optional[bool]
            Whether to include active usages of the webhook, only usable by admins

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[WorkspaceWebhookListResponseModel]
            Successful Response
        r%   r&   r"   r'   Nr*   r+   r,   r/   r2   r3   r6   )r   r8   r9   r7   r:   r;   r   r   r<   r   r   r=   r4   r   r   r   r>   r?   r   r   r   rC     sD   

zAsyncRawWebhooksClient.listrD   rE   c             	      s   | j jjdddt|tddiddi|tdI d	H }z>d
|j  kr&dk r;n ntt	t
t	| d}t||dW S |jdkrStt|jttt
t| dd| }W n tyk   t|jt|j|jdw t|jt|j|d)a  
        Create a new webhook for the workspace with the specified authentication type.

        Parameters
        ----------
        settings : WebhookHmacSettings
            Webhook settings object containing auth_type and corresponding configuration

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[WorkspaceCreateWebhookResponseModel]
            Successful Response
        r%   rF   rE   rG   rH   rK   rL   rM   Nr*   r+   r,   r/   r2   r3   r6   )r   r8   r9   r   r   rO   r7   r:   r;   r   r   r<   r   r   r=   r4   r   r   r   r>   rP   r   r   r   rQ   9  sN   

zAsyncRawWebhooksClient.createrR   c             	      s   | j jjdt| d|dI dH }z>d|j  krdk r4n ntttt|	 d}t
||dW S |jd	krLtt|jtttt|	 dd
|	 }W n tyd   t|jt|j|jdw t|jt|j|d)a  
        Delete the specified workspace webhook

        Parameters
        ----------
        webhook_id : str
            The unique ID for the webhook

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[DeleteWorkspaceWebhookResponseModel]
            Successful Response
        rS   rT   rU   Nr*   r+   r,   r/   r2   r3   r6   )r   r8   r9   r	   r7   r:   r;   r   r   r<   r   r   r=   r4   r   r   r   r>   rV   r   r   r   rW   t  s@   

zAsyncRawWebhooksClient.deleterX   rY   c             	      s   | j jjdt| d||dddi|tdI dH }z>d|j  kr'd	k r<n nttt	t|
 d
}t||dW S |jdkrTtt|jttt	t|
 d
d|
 }W n tyl   t|jt|j|jdw t|jt|j|d)a;  
        Update the specified workspace webhook

        Parameters
        ----------
        webhook_id : str
            The unique ID for the webhook

        is_disabled : bool
            Whether to disable or enable the webhook

        name : str
            The display name of the webhook (used for display purposes only).

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        AsyncHttpResponse[PatchWorkspaceWebhookResponseModel]
            Successful Response
        rS   rZ   r[   rK   rL   rM   Nr*   r+   r,   r/   r2   r3   r6   )r   r8   r9   r	   rO   r7   r:   r;   r   r   r<   r   r   r=   r4   r   r   r   r>   r\   r   r   r   r]     sL   

zAsyncRawWebhooksClient.update)r^   r_   r`   r   r   r:   ra   rb   r
   r   r   rC   r   r   rQ   rc   r   rW   r   r]   r   r   r   r   re      rd   re   )&r:   json.decoderr   core.api_errorr   core.client_wrapperr   r   core.http_responser   r   core.jsonable_encoderr	   core.request_optionsr
   core.serializationr   core.unchecked_base_modelr   !errors.unprocessable_entity_errorr   -types.delete_workspace_webhook_response_modelr   types.http_validation_errorr   ,types.patch_workspace_webhook_response_modelr   types.webhook_hmac_settingsr   -types.workspace_create_webhook_response_modelr   +types.workspace_webhook_list_response_modelr   r;   AnyrO   r   re   r   r   r   r   <module>   s(    h