def prepare_request(<EOL>url: Union[str, methods],<EOL>data: Optional[MutableMapping],<EOL>headers: Optional[MutableMapping],<EOL>global_headers: MutableMapping,<EOL>token: str,<EOL>as_json: Optional[bool] = None,<EOL>) -> Tuple[str, Union[str, MutableMapping], MutableMapping]:
if isinstance(url, methods):<EOL><INDENT>as_json = as_json or url.value[<NUM_LIT:3>]<EOL>real_url = url.value[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>real_url = url<EOL>as_json = False<EOL><DEDENT>if not headers:<EOL><INDENT>headers = {**global_headers}<EOL><DEDENT>else:<EOL><INDENT>headers = {**global_headers, **headers}<EOL><DEDENT>payload: Optional[Union[str, MutableMapping]] = None<EOL>if real_url.startswith(HOOK_URL) or (real_url.startswith(ROOT_URL) and as_json):<EOL><INDENT>payload, headers = _prepare_json_request(data, token, headers)<EOL><DEDENT>elif real_url.startswith(ROOT_URL) and not as_json:<EOL><INDENT>payload = _prepare_form_encoded_request(data, token)<EOL><DEDENT>else:<EOL><INDENT>real_url = ROOT_URL + real_url<EOL>payload = _prepare_form_encoded_request(data, token)<EOL><DEDENT>return real_url, payload, headers<EOL>
Prepare outgoing request

Create url, headers, add token to the body and if needed json encode it

Args:
    url: :class:`slack.methods` item or string of url
    data: Outgoing data
    headers: Custom headers
    global_headers: Global headers
    token: Slack API token
    as_json: Post JSON to the slack API
Returns:
    :py:class:`tuple` (url, body, headers)