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