MCPcopy
hub / github.com/slackapi/python-slack-sdk / _build_req_args

Function _build_req_args

slack/web/async_internal_utils.py:89–139  ·  view source on GitHub ↗
(
    *,
    token: Optional[str],
    http_verb: str,
    files: dict,
    data: Union[dict, FormData],
    params: dict,
    json: dict,  # skipcq: PYL-W0621
    headers: dict,
    auth: dict,
    ssl: Optional[SSLContext],
    proxy: Optional[str],
)

Source from the content-addressed store, hash-verified

87
88
89def _build_req_args(
90 *,
91 token: Optional[str],
92 http_verb: str,
93 files: dict,
94 data: Union[dict, FormData],
95 params: dict,
96 json: dict, # skipcq: PYL-W0621
97 headers: dict,
98 auth: dict,
99 ssl: Optional[SSLContext],
100 proxy: Optional[str],
101) -> dict:
102 has_json = json is not None
103 has_files = files is not None
104 if has_json and http_verb != "POST":
105 msg = "Json data can only be submitted as POST requests. GET requests should use the 'params' argument."
106 raise SlackRequestError(msg)
107
108 if auth:
109 auth = BasicAuth(auth["client_id"], auth["client_secret"])
110
111 if data is not None and isinstance(data, dict):
112 data = {k: v for k, v in data.items() if v is not None}
113 if files is not None and isinstance(files, dict):
114 files = {k: v for k, v in files.items() if v is not None}
115 if params is not None and isinstance(params, dict):
116 params = {k: v for k, v in params.items() if v is not None}
117
118 token: Optional[str] = token
119 if params is not None and "token" in params:
120 token = params.pop("token")
121 if json is not None and "token" in json:
122 token = json.pop("token")
123 req_args = {
124 "headers": _get_headers(
125 headers=headers,
126 token=token,
127 has_json=has_json,
128 has_files=has_files,
129 request_specific_headers=headers,
130 ),
131 "data": data,
132 "files": files,
133 "params": params,
134 "json": json,
135 "ssl": ssl,
136 "proxy": proxy,
137 "auth": auth,
138 }
139 return req_args
140
141
142def _files_to_data(req_args: dict) -> List[BinaryIO]:

Callers 2

api_callMethod · 0.90
api_callMethod · 0.90

Calls 2

SlackRequestErrorClass · 0.90
_get_headersFunction · 0.70

Tested by

no test coverage detected