def _request(self, url, method='<STR_LIT:GET>', params=None, api_call=None, json_encoded=False):
method = method.lower()<EOL>params = params or {}<EOL>func = getattr(self.client, method)<EOL>if isinstance(params, dict) and json_encoded is False:<EOL><INDENT>params, files = _transparent_params(params)<EOL><DEDENT>else:<EOL><INDENT>params = params<EOL>files = list()<EOL><DEDENT>requests_args = {}<EOL>for k, v in self.client_args.items():<EOL><INDENT>if k in ('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>requests_args[k] = v<EOL><DEDENT><DEDENT>if method == '<STR_LIT>' or method == '<STR_LIT>':<EOL><INDENT>requests_args['<STR_LIT>'] = params<EOL><DEDENT>else:<EOL><INDENT>if json_encoded:<EOL><INDENT>data_key = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>data_key = '<STR_LIT:data>'<EOL><DEDENT>requests_args.update({<EOL>data_key: params,<EOL>'<STR_LIT>': files,<EOL>})<EOL><DEDENT>try:<EOL><INDENT>response = func(url, **requests_args)<EOL><DEDENT>except requests.RequestException as e:<EOL><INDENT>raise TwythonError(str(e))<EOL><DEDENT>self._last_call = {<EOL>'<STR_LIT>': api_call,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': response.cookies,<EOL>'<STR_LIT>': response.headers,<EOL>'<STR_LIT>': response.status_code,<EOL>'<STR_LIT:url>': response.url,<EOL>'<STR_LIT:content>': response.text,<EOL>}<EOL>if response.status_code > <NUM_LIT>:<EOL><INDENT>error_message = self._get_error_message(response)<EOL>self._last_call['<STR_LIT>'] = error_message<EOL>ExceptionType = TwythonError<EOL>if response.status_code == <NUM_LIT>:<EOL><INDENT>ExceptionType = TwythonRateLimitError<EOL><DEDENT>elif response.status_code == <NUM_LIT> or '<STR_LIT>'in error_message:<EOL><INDENT>ExceptionType = TwythonAuthError<EOL><DEDENT>raise ExceptionType(<EOL>error_message,<EOL>error_code=response.status_code,<EOL>retry_after=response.headers.get('<STR_LIT>'))<EOL><DEDENT>content = '<STR_LIT>'<EOL>try:<EOL><INDENT>if response.status_code == <NUM_LIT>:<EOL><INDENT>content = response.content<EOL><DEDENT>else:<EOL><INDENT>content = response.json()<EOL><DEDENT><DEDENT>except ValueError:<EOL><INDENT>if response.content != '<STR_LIT>':<EOL><INDENT>raise TwythonError('<STR_LIT>')<EOL><DEDENT><DEDENT>return content<EOL>
Internal request method