MCPcopy Index your code
hub / github.com/slackapi/python-slack-sdk / _send

Method _send

slack/web/base_client.py:154–189  ·  view source on GitHub ↗

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.

(self, http_verb: str, api_url: str, req_args: dict)

Source from the content-addressed store, hash-verified

152 # =================================================================
153
154 async def _send(self, http_verb: str, api_url: str, req_args: dict) -> SlackResponse:
155 """Sends the request out for transmission.
156
157 Args:
158 http_verb (str): The HTTP verb. e.g. 'GET' or 'POST'.
159 api_url (str): The Slack API url. e.g. 'https://slack.com/api/chat.postMessage'
160 req_args (dict): The request arguments to be attached to the request.
161 e.g.
162 {
163 json: {
164 'attachments': [{"pretext": "pre-hello", "text": "text-world"}],
165 'channel': '#random'
166 }
167 }
168 Returns:
169 The response parsed into a SlackResponse object.
170 """
171 open_files = _files_to_data(req_args)
172 try:
173 if "params" in req_args:
174 # True/False -> "1"/"0"
175 req_args["params"] = convert_bool_to_0_or_1(req_args["params"])
176
177 res = await self._request(http_verb=http_verb, api_url=api_url, req_args=req_args)
178 finally:
179 for f in open_files:
180 f.close()
181
182 data = {
183 "client": self,
184 "http_verb": http_verb,
185 "api_url": api_url,
186 "req_args": req_args,
187 "use_sync_aiohttp": self.use_sync_aiohttp,
188 }
189 return SlackResponse(**{**data, **res}).validate()
190
191 async def _request(self, *, http_verb, api_url, req_args) -> Dict[str, any]:
192 """Submit the HTTP request with the running session or a new session.

Callers 1

api_callMethod · 0.95

Calls 6

_requestMethod · 0.95
_files_to_dataFunction · 0.90
convert_bool_to_0_or_1Function · 0.90
SlackResponseClass · 0.90
closeMethod · 0.45
validateMethod · 0.45

Tested by

no test coverage detected