MCPcopy
hub / github.com/slackapi/python-slack-sdk / api_call

Method api_call

slack/web/async_base_client.py:47–115  ·  view source on GitHub ↗

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 O

(  # skipcq: PYL-R1710
        self,
        api_method: str,
        *,
        http_verb: str = "POST",
        files: dict = None,
        data: Union[dict, FormData] = None,
        params: dict = None,
        json: dict = None,  # skipcq: PYL-W0621
        headers: dict = None,
        auth: dict = None,
    )

Source from the content-addressed store, hash-verified

45 self._logger = logging.getLogger(__name__)
46
47 async def api_call( # skipcq: PYL-R1710
48 self,
49 api_method: str,
50 *,
51 http_verb: str = "POST",
52 files: dict = None,
53 data: Union[dict, FormData] = None,
54 params: dict = None,
55 json: dict = None, # skipcq: PYL-W0621
56 headers: dict = None,
57 auth: dict = None,
58 ) -> AsyncSlackResponse:
59 """Create a request and execute the API call to Slack.
60
61 Args:
62 api_method (str): The target Slack API method.
63 e.g. 'chat.postMessage'
64 http_verb (str): HTTP Verb. e.g. 'POST'
65 files (dict): Files to multipart upload.
66 e.g. {image OR file: file_object OR file_path}
67 data: The body to attach to the request. If a dictionary is
68 provided, form-encoding will take place.
69 e.g. {'key1': 'value1', 'key2': 'value2'}
70 params (dict): The URL parameters to append to the URL.
71 e.g. {'key1': 'value1', 'key2': 'value2'}
72 json (dict): JSON for the body to attach to the request
73 (if files or data is not specified).
74 e.g. {'key1': 'value1', 'key2': 'value2'}
75 headers (dict): Additional request headers
76 auth (dict): A dictionary that consists of client_id and client_secret
77
78 Returns:
79 (AsyncSlackResponse)
80 The server's response to an HTTP request. Data
81 from the response can be accessed like a dict.
82 If the response included 'next_cursor' it can
83 be iterated on to execute subsequent requests.
84
85 Raises:
86 SlackApiError: The following Slack API call failed:
87 'chat.postMessage'.
88 SlackRequestError: Json data can only be submitted as
89 POST requests.
90 """
91
92 api_url = _get_url(self.base_url, api_method)
93 headers = headers or {}
94 headers.update(self.headers)
95
96 req_args = _build_req_args(
97 token=self.token,
98 http_verb=http_verb,
99 files=files,
100 data=data,
101 params=params,
102 json=json, # skipcq: PYL-W0621
103 headers=headers,
104 auth=auth,

Callers

nothing calls this directly

Calls 4

_sendMethod · 0.95
_get_urlFunction · 0.90
_build_req_argsFunction · 0.90
show_2020_01_deprecationFunction · 0.90

Tested by

no test coverage detected