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)
| 115 | ) |
| 116 | |
| 117 | async def _send(self, http_verb: str, api_url: str, req_args: dict) -> AsyncSlackResponse: |
| 118 | """Sends the request out for transmission. |
| 119 | |
| 120 | Args: |
| 121 | http_verb (str): The HTTP verb. e.g. 'GET' or 'POST'. |
| 122 | api_url (str): The Slack API url. e.g. 'https://slack.com/api/chat.postMessage' |
| 123 | req_args (dict): The request arguments to be attached to the request. |
| 124 | e.g. |
| 125 | { |
| 126 | json: { |
| 127 | 'attachments': [{"pretext": "pre-hello", "text": "text-world"}], |
| 128 | 'channel': '#random' |
| 129 | } |
| 130 | } |
| 131 | Returns: |
| 132 | The response parsed into a AsyncSlackResponse object. |
| 133 | """ |
| 134 | open_files = _files_to_data(req_args) |
| 135 | try: |
| 136 | if "params" in req_args: |
| 137 | # True/False -> "1"/"0" |
| 138 | req_args["params"] = convert_bool_to_0_or_1(req_args["params"]) |
| 139 | |
| 140 | res = await self._request(http_verb=http_verb, api_url=api_url, req_args=req_args) |
| 141 | finally: |
| 142 | for f in open_files: |
| 143 | f.close() |
| 144 | |
| 145 | data = { |
| 146 | "client": self, |
| 147 | "http_verb": http_verb, |
| 148 | "api_url": api_url, |
| 149 | "req_args": req_args, |
| 150 | } |
| 151 | return AsyncSlackResponse(**{**data, **res}).validate() |
| 152 | |
| 153 | async def _request(self, *, http_verb, api_url, req_args) -> Dict[str, any]: |
| 154 | """Submit the HTTP request with the running session or a new session. |
no test coverage detected