o
    Vhfw                     @   s   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 dZdS )    N)
SSLContext)DictUnionListOptional)	BasicAuthClientSession)SlackApiError   )_debug_log_response_build_request_headers_build_body)WebhookResponse   )
Attachment)Blockc                   @   s2  e Zd Ze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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dZddeeef deeeef  defddZdeeef deeef defddZdS )AsyncWebhookClient   NFurltimeoutsslproxysessiontrust_env_in_sessionauthdefault_headersc	           	      C   sB   || _ || _|| _|| _|| _|| _|| _|r|| _d S i | _d S N)r   r   r   r   r   r   r   r   )	selfr   r   r   r   r   r   r   r    r   _/var/www/html/status_management/venv/lib/python3.10/site-packages/slack/webhook/async_client.py__init__   s   zAsyncWebhookClient.__init__)textattachmentsblocksresponse_typeheadersr!   r"   r#   r$   r%   returnc                   s    | j ||||d|dI dH 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%   r   r   r   send'   s   zAsyncWebhookClient.sendr(   c                    s"   | j t|t| j|dI d H S )Nr'   )_perform_http_requestr   r   r   )r   r(   r%   r   r   r   r)   E   s
   
zAsyncWebhookClient.send_dictc                   s  t |}d|d< | jjtjkr!| jd| j d| d|  d }| jo*| jj	 }|r1| j}nt
jt
j| jd| j| jd}z||| j| jd}|jd	| jfi |4 I d H c}i }z	| I d H }W n. t
jyz   | jd
| j d Y n t jjy } zdt| }	t|	|d }~ww t| j|j||jd}
t| j|
 |
W  d   I d H  W |s| I d H  S S 1 I d H sw   Y  W |s| I d H  d S d S |s| I d H  w 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respr   r   r   r+   K   sb   
  
z(AsyncWebhookClient._perform_http_request)r   NNNFNNr   )__name__
__module____qualname__r6   	getLoggerr4   rA   intr   r   r   boolr   r   r    r   r   anyr   r   r   r*   r)   r+   r   r   r   r   r      s\    
	

,*r   )r2   r6   r   r   typingr   r   r   r   r:   r   r   slack.errorsr	   internal_utilsr   r   r   webhook_responser   web.classes.attachmentsr   web.classes.blocksr   r   r   r   r   r   <module>   s    