
    iw                         d dl Z d dlZd dlmZ d dlmZmZmZmZ d dl	Z	d dl	m
Z
mZ d dl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  G d d          ZdS )    N)
SSLContext)DictUnionListOptional)	BasicAuthClientSession)SlackApiError   )_debug_log_response_build_request_headers_build_body)WebhookResponse   )
Attachment)Blockc                      e Zd Z ej        e           Z	 	 	 	 	 	 	 ddededee	         dee         dee
         d	ed
ee         deeeef                  fdZdddddddee         deeeeeef         ef                           deeeeeef         ef                           dee         deeeef                  defdZddeeef         deeeef                  defdZdeeef         deeef         defdZdS )AsyncWebhookClient   NFurltimeoutsslproxysessiontrust_env_in_sessionauthdefault_headersc	                 ~    || _         || _        || _        || _        || _        || _        || _        |r|ni | _        d S N)r   r   r   r   r   r   r   r   )	selfr   r   r   r   r   r   r   r   s	            U/root/projects/butler/venv/lib/python3.11/site-packages/slack/webhook/async_client.py__init__zAsyncWebhookClient.__init__   sM     
$8!	2AIr    )textattachmentsblocksresponse_typeheadersr$   r%   r&   r'   r(   returnc                J   K   |                      ||||d|           d{V S )a  Performs a Slack API request and returns the result.

        Args:
            text: The text message (even when having blocks, setting this as well is recommended as it works as fallback)
            attachments: A collection of attachments
            blocks: A collection of Block Kit UI components
            response_type: The type of message (either 'in_channel' or 'ephemeral')
            headers: Request headers to append only for this request
        Returns:
            Webhook response
        )r$   r%   r&   r'   bodyr(   N)	send_dict)r    r$   r%   r&   r'   r(   s         r!   sendzAsyncWebhookClient.send'   s\      ( ^^* !.	   $ 
 
 
 
 
 
 
 
 	
r#   r,   c                    K   |                      t          |          t          | j        |                     d {V S )Nr+   )_perform_http_requestr   r   r   )r    r,   r(   s      r!   r-   zAsyncWebhookClient.send_dictE   s\      //T""*4+?II 0 
 
 
 
 
 
 
 
 	
r#   c                ^  K   t          j        |          }d|d<   | j        j        t          j        k    r(| j                            d| j         d| d|            d }| j        o| j        j	         }|r| j        }n9t          j        t          j        | j                  | j        | j                  }	 ||| j        | j        d} |j        d	| j        fi |4 d {V }i }	 |                                 d {V }nq# t          j        $ r& | j                            d
| j         d           Y n=t           j        j        $ r'}dt1          |           }	t3          |	|          d }~ww xY wt5          | j        |j        ||j                  }
t;          | j        |
           |
cd d d           d {V  |s|                                 d {V  S S # 1 d {V swxY w Y   	 |s|                                 d {V  d S d S # |s|                                 d {V  w w xY w)Nzapplication/json;charset=utf-8zContent-TypezSending a request - url: z, body: z, headers: )total)r   r   	trust_env)r(   datar   r   POSTz7No response data returned from the following API call: .z#Failed to parse the response body: )r   status_coder,   r(   )jsondumpsloggerlevelloggingDEBUGdebugr   r   closedaiohttpr	   ClientTimeoutr   r   r   r   r   requestr$   ContentTypeError_loggerdecoderJSONDecodeErrorstrr
   r   statusr(   r   close)r    r,   r(   r   use_running_sessionrequest_kwargsresresponse_bodyemessageresps              r!   r0   z(AsyncWebhookClient._perform_http_requestK   sJ     z$"B;--Kf$(ffDff]dffggg+/"lF4<3F/F 	lGG+-DLAAAY3  G	&"x	 N 'wvtxJJ>JJ       c "6*-((**$4$4$4$4$4$4MM/ n n nL&&'laeai'l'l'lmmmmm|3 6 6 6LCFFLLG'5556 ' #
&K	   $DK666#            & ' &mmoo%%%%%%%%&'              & ' &mmoo%%%%%%%%%& && &mmoo%%%%%%%%&s`   8+H #G'DG2E04G6E0	"E++E00;G+H 
G%%H (G%)H H,)r   NNNFNNr   )__name__
__module____qualname__r<   	getLoggerr:   rG   intr   r   r	   boolr   r   r"   r   r   anyr   r   r   r.   r-   r0    r#   r!   r   r      s       Wx((F
 $(#+/%*$(48J JJ J j!	J
 }J -(J #J y!J "$sCx.1J J J J. #IM?C'+,0
 
 
 sm
 d5c3h)C#DEF	

 eDcNE$9:;<
  }
 $sCx.)
 

 
 
 
<
 
DcN 
Xd3PS8n=U 
ap 
 
 
 
,&4S> ,&DQTVYQYN ,&_n ,& ,& ,& ,& ,& ,&r#   r   )r8   r<   r   r   typingr   r   r   r   r@   r   r	   slack.errorsr
   internal_utilsr   r   r   webhook_responser   web.classes.attachmentsr   web.classes.blocksr   r   rX   r#   r!   <module>r_      s           . . . . . . . . . . . .  , , , , , , , , & & & & & & T T T T T T T T T T - - - - - - 0 0 0 0 0 0 & & & & & &g& g& g& g& g& g& g& g& g& g&r#   