(
*,
token: Optional[str],
http_verb: str,
files: dict,
data: dict,
default_params: dict,
params: dict,
json: dict,
headers: dict,
auth: dict,
ssl: Optional[SSLContext],
proxy: Optional[str],
)
| 130 | |
| 131 | |
| 132 | def _build_req_args( |
| 133 | *, |
| 134 | token: Optional[str], |
| 135 | http_verb: str, |
| 136 | files: dict, |
| 137 | data: dict, |
| 138 | default_params: dict, |
| 139 | params: dict, |
| 140 | json: dict, |
| 141 | headers: dict, |
| 142 | auth: dict, |
| 143 | ssl: Optional[SSLContext], |
| 144 | proxy: Optional[str], |
| 145 | ) -> dict: |
| 146 | has_json = json is not None |
| 147 | has_files = files is not None |
| 148 | if has_json and http_verb != "POST": |
| 149 | msg = "Json data can only be submitted as POST requests. GET requests should use the 'params' argument." |
| 150 | raise SlackRequestError(msg) |
| 151 | |
| 152 | if data is not None and isinstance(data, dict): |
| 153 | data = {k: v for k, v in data.items() if v is not None} |
| 154 | _set_default_params(data, default_params) |
| 155 | if files is not None and isinstance(files, dict): |
| 156 | files = {k: v for k, v in files.items() if v is not None} |
| 157 | # NOTE: We do not need to all #_set_default_params here |
| 158 | # because other parameters in binary data requests can exist |
| 159 | # only in either data or params, not in files. |
| 160 | if params is not None and isinstance(params, dict): |
| 161 | params = {k: v for k, v in params.items() if v is not None} |
| 162 | _set_default_params(params, default_params) |
| 163 | if json is not None and isinstance(json, dict): |
| 164 | _set_default_params(json, default_params) |
| 165 | |
| 166 | token = token |
| 167 | if params is not None and "token" in params: |
| 168 | token = params.pop("token") |
| 169 | if json is not None and "token" in json: |
| 170 | token = json.pop("token") |
| 171 | req_args = { |
| 172 | "headers": _get_headers( |
| 173 | headers=headers, |
| 174 | token=token, |
| 175 | has_json=has_json, |
| 176 | has_files=has_files, |
| 177 | request_specific_headers=headers, |
| 178 | ), |
| 179 | "data": data, |
| 180 | "files": files, |
| 181 | "params": params, |
| 182 | "json": json, |
| 183 | "ssl": ssl, |
| 184 | "proxy": proxy, |
| 185 | "auth": auth, |
| 186 | } |
| 187 | return req_args |
| 188 | |
| 189 |
no test coverage detected