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)
| 190 | # ================================================================= |
| 191 | |
| 192 | async def _send(self, http_verb: str, api_url: str, req_args: dict) -> SlackResponse: |
| 193 | """Sends the request out for transmission. |
| 194 | Args: |
| 195 | http_verb (str): The HTTP verb. e.g. 'GET' or 'POST'. |
| 196 | api_url (str): The Slack API url. e.g. 'https://slack.com/api/chat.postMessage' |
| 197 | req_args (dict): The request arguments to be attached to the request. |
| 198 | e.g. |
| 199 | { |
| 200 | json: { |
| 201 | 'attachments': [{"pretext": "pre-hello", "text": "text-world"}], |
| 202 | 'channel': '#random' |
| 203 | } |
| 204 | } |
| 205 | Returns: |
| 206 | The response parsed into a SlackResponse object. |
| 207 | """ |
| 208 | open_files = _files_to_data(req_args) |
| 209 | try: |
| 210 | if "params" in req_args: |
| 211 | # True/False -> "1"/"0" |
| 212 | req_args["params"] = convert_bool_to_0_or_1(req_args["params"]) |
| 213 | |
| 214 | res = await self._request(http_verb=http_verb, api_url=api_url, req_args=req_args) |
| 215 | finally: |
| 216 | for f in open_files: |
| 217 | f.close() |
| 218 | |
| 219 | data = { |
| 220 | "client": self, |
| 221 | "http_verb": http_verb, |
| 222 | "api_url": api_url, |
| 223 | "req_args": req_args, |
| 224 | "use_sync_aiohttp": self.use_sync_aiohttp, |
| 225 | } |
| 226 | return SlackResponse(**{**data, **res}).validate() |
| 227 | |
| 228 | async def _request(self, *, http_verb, api_url, req_args) -> Dict[str, Any]: |
| 229 | """Submit the HTTP request with the running session or a new session. |
no test coverage detected