
    'jJ&                         d dl Z d dlmZ d dlmZmZmZmZmZ d dl	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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)OptionalUnionDictAnyList)FormData	BasicAuth   )_files_to_data_request_with_session)AsyncSlackResponse)show_deprecation_warning_if_any)FileUploadV2Result)convert_bool_to_0_or_1_build_req_args_get_urlget_user_agent   )load_http_proxy_from_env)async_default_handlers)AsyncRetryHandlerc                   8   e Zd ZdZdedddddddddddfdee         dededee         d	ee         d
eej	                 de
dee         dee         dee         dee         deej                 deee                  fdZedej        fd            Zdddddddddededee         deeeef                  dee         dee         dee         dee         defdZdeded edefd!Zdeeef         fd"Zd#ededej        ded	ee         dee         defd$ZdS )%AsyncBaseClientzhttps://slack.com/api/N   Ftokenbase_urltimeoutsslproxysessiontrust_env_in_sessionheadersuser_agent_prefixuser_agent_suffixteam_idloggerretry_handlersc                 V   |d n|                                 | _        	 |                    d          s|dz  }|| _        	 || _        	 || _        	 || _        	 || _        	 || _        	 |pi | _	        	 t          |	|
          | j	        d<   i | _        |
|| j        d<   ||nt          j        t                    | _        ||nt!                      | _        | j        *t%          | j                                                   dk    r!t'          | j                  }|	|| _        d S d S d S )N/z
User-Agentr&   r   )stripr   endswithr   r   r   r    r!   r"   r#   r   default_paramslogging	getLogger__name___loggerr   r(   lenr   )selfr   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   env_variables                  `/usr/local/lib/hermes-agent/venv/lib/python3.11/site-packages/slack_sdk/web/async_base_client.py__init__zAsyncBaseClient.__init__   s\   " #]TT
@  %% 	OH 	2	" 	 
	8
 	/ %9!	/ }"W%34EGX%Y%Y\" -4D	*!'!3vv9J89T9T0>0JnnPfPhPh:TZ%5%5%7%7!8!8A!=!=3DLAAL')


 (' ">!=    returnc                     | j         S )zThe logger this client uses.)r1   )r3   s    r5   r'   zAsyncBaseClient.logger^   s     |r7   POST)	http_verbfilesdataparamsjsonr#   auth
api_methodr;   r<   r=   r>   r?   r@   c                  K   t          | j        |          }	|ct          |t                    rt	          |d         |d                   }t          |t                    r|i }|                                |d<   d}|pi }|                    | j                   t          | j	        |||| j
        ||||| j        | j                  }
t          |           |                     ||	|
           d{V S )a  Create a request and execute the API call to Slack.

        Args:
            api_method (str): The target Slack API method.
                e.g. 'chat.postMessage'
            http_verb (str): HTTP Verb. e.g. 'POST'
            files (dict): Files to multipart upload.
                e.g. {image OR file: file_object OR file_path}
            data: The body to attach to the request. If a dictionary is
                provided, form-encoding will take place.
                e.g. {'key1': 'value1', 'key2': 'value2'}
            params (dict): The URL parameters to append to the URL.
                e.g. {'key1': 'value1', 'key2': 'value2'}
            json (dict): JSON for the body to attach to the request
                (if files or data is not specified).
                e.g. {'key1': 'value1', 'key2': 'value2'}
            headers (dict): Additional request headers
            auth (dict): A dictionary that consists of client_id and client_secret

        Returns:
            (AsyncSlackResponse)
                The server's response to an HTTP request. Data
                from the response can be accessed like a dict.
                If the response included 'next_cursor' it can
                be iterated on to execute subsequent requests.

        Raises:
            SlackApiError: The following Slack API call failed:
                'chat.postMessage'.
            SlackRequestError: Json data can only be submitted as
                POST requests.
        N	client_idclient_secretAuthorization)r   r;   r<   r=   r-   r>   r?   r#   r@   r   r    r;   api_urlreq_args)r   r   
isinstancer   r
   encodeupdater#   r   r   r-   r   r    r   _send)r3   rA   r;   r<   r=   r>   r?   r#   r@   rG   rH   s              r5   api_callzAsyncBaseClient.api_callf   s,     Z 4=*55$%% K k!2D4IJJ$	** ? G+/;;==(-Rt|$$$"*.*
 
 
 	(
333ZZ   
 
 
 
 
 
 
 
 	
r7   rG   rH   c                 \  K   t          |          }	 d|v rt          |d                   |d<   |                     |||           d{V }|D ]}|                                 n# |D ]}|                                 w xY w| |||d}t	          di i ||                                S )aW  Sends the request out for transmission.

        Args:
            http_verb (str): The HTTP verb. e.g. 'GET' or 'POST'.
            api_url (str): The Slack API url. e.g. 'https://slack.com/api/chat.postMessage'
            req_args (dict): The request arguments to be attached to the request.
            e.g.
            {
                json: {
                    'attachments': [{"pretext": "pre-hello", "text": "text-world"}],
                    'channel': '#random'
                }
            }
        Returns:
            The response parsed into a AsyncSlackResponse object.
        r>   rF   N)clientr;   rG   rH    )r   r   _requestcloser   validate)r3   r;   rG   rH   
open_filesresfr=   s           r5   rL   zAsyncBaseClient._send   s      " $H--
	8##%;HX<N%O%O"	7U]^^^^^^^^C  				Z  				 " 	
 
 "44OtOsO44==???s   :A' 'Bc          	      f   K   t          | j        | j        | j        |||| j                   d{V S )zSubmit the HTTP request with the running session or a new session.
        Returns:
            A dictionary of the response data.
        current_sessionr   r'   r;   rG   rH   r(   N)r   r!   r   r1   r(   )r3   r;   rG   rH   s       r5   rQ   zAsyncBaseClient._request   s[      
 + LL<.
 
 
 
 
 
 
 
 
 	
r7   urlc                   K   t          | j        ||d||||d| j                   d{V }t          |                    d          |                    d                    S )z)Upload a file using the issued upload URLr:   )r=   r    r   rX   Nstatus_codebody)statusr]   )r   r!   r(   r   get)r3   rZ   r=   r'   r   r    r   results           r5   _upload_filezAsyncBaseClient._upload_file   s       - L"U3??.
 
 
 
 
 
 
 
 
 "::m,,F##
 
 
 	
r7   )r0   
__module____qualname__BASE_URLr   strintr   aiohttpClientSessionbooldictr.   Loggerr   r   r6   propertyr'   r   r	   r   rM   rL   r   r   rQ   bytesr   ra   rP   r7   r5   r   r      s       'H  $ $(#37%*"&+/+/!%+/<@;* ;*};* ;* 	;*
 j!;* };* '/0;* #;* $;* $C=;* $C=;* #;* (;* !&7!89;* ;* ;* ;*@     X   $04!%#"&#M
 M
 M
M
 	M

 ~M
 uT8^,-M
 M
 tnM
 $M
 tnM
 
M
 M
 M
 M
^"@S "@3 "@$ "@K] "@ "@ "@ "@H
c3h 
 
 
 

 
 	

 
 
 }
 j!
 

 
 
 
 
 
r7   r   )!r.   r   r   typingr   r   r   r   r   rg   r	   r
   async_internal_utilsr   r   async_slack_responser   deprecationr   file_upload_v2_resultr   internal_utilsr   r   r   r   proxy_env_variable_loaderr   +slack_sdk.http_retry.builtin_async_handlersr   "slack_sdk.http_retry.async_handlerr   r   rP   r7   r5   <module>rw      s|          3 3 3 3 3 3 3 3 3 3 3 3 3 3  ' ' ' ' ' ' ' '        5 4 4 4 4 4 8 8 8 8 8 8 5 5 5 5 5 5            A @ @ @ @ @ N N N N N N @ @ @ @ @ @d
 d
 d
 d
 d
 d
 d
 d
 d
 d
r7   