o
    aqe                     @   s   d dl Z d dlmZ d dlmZmZmZ d dlZd dlmZ d dl	m
Z
mZ d dlmZmZmZmZ d dlmZ d dlmZ G d	d
 d
ZdS )    N)
SSLContext)OptionalUnionDict)FormData)convert_bool_to_0_or_1get_user_agent)_build_req_args_get_url_files_to_data_request_with_session)AsyncSlackResponse)show_2020_01_deprecationc                   @   s   e Zd ZdZde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 fddZdddddddddedededeeef dededededefddZdedededefdd Zdeeef fd!d"ZdS )#AsyncBaseClientzhttps://www.slack.com/api/N   Ftokenbase_urltimeoutsslproxysessiontrust_env_in_sessionheadersuser_agent_prefixuser_agent_suffixc                 C   sd   |d u rd n|  | _|| _|| _|| _|| _|| _|| _|p i | _t	|	|
| jd< t
t| _d S )Nz
User-Agent)stripr   r   r   r   r   r   r   r   r   logging	getLogger__name___logger)selfr   r   r   r   r   r   r   r   r   r    r!   \/var/www/html/humari/django-venv/lib/python3.10/site-packages/slack/web/async_base_client.py__init__   s   

zAsyncBaseClient.__init__POST)	http_verbfilesdataparamsjsonr   auth
api_methodr%   r&   r'   r(   r)   r*   returnc                   sb   t | j|}	|p
i }|| j t| j|||||||| j| jd
}
t| | j	||	|
dI dH 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.
        )
r   r%   r&   r'   r(   r)   r   r*   r   r   r%   api_urlreq_argsN)
r
   r   updater   r	   r   r   r   r   _send)r    r+   r%   r&   r'   r(   r)   r   r*   r.   r/   r!   r!   r"   api_call1   s,   -zAsyncBaseClient.api_callr.   r/   c              	      s   t |}z"d|v rt|d |d< | j|||dI dH }W |D ]}|  q n
|D ]}|  q*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(   r-   N)clientr%   r.   r/   r!   )r   r   _requestcloser   validate)r    r%   r.   r/   
open_filesresfr'   r!   r!   r"   r1   w   s&   


zAsyncBaseClient._sendc                   s"   t | j| j| j|||dI dH S )zSubmit the HTTP request with the running session or a new session.
        Returns:
            A dictionary of the response data.
        )current_sessionr   loggerr%   r.   r/   N)r   r   r   r   )r    r%   r.   r/   r!   r!   r"   r4      s   zAsyncBaseClient._request)r   
__module____qualname__BASE_URLr   strintr   aiohttpClientSessionbooldictr#   r   r   r   r2   r1   r   anyr4   r!   r!   r!   r"   r      s    	


	

F
(r   )r   r   r   typingr   r   r   rA   r   	slack.webr   r   slack.web.async_internal_utilsr	   r
   r   r   slack.web.async_slack_responser   slack.web.deprecationr   r   r!   r!   r!   r"   <module>   s    