def _request(self, endpoint, method, data=None, **kwargs):
final_url = self.url + endpoint<EOL>if not self._is_authenticated:<EOL><INDENT>raise LoginRequired<EOL><DEDENT>rq = self.session<EOL>if method == '<STR_LIT>':<EOL><INDENT>request = rq.get(final_url, **kwargs)<EOL><DEDENT>else:<EOL><INDENT>request = rq.post(final_url, data, **kwargs)<EOL><DEDENT>request.raise_for_status()<EOL>request.encoding = '<STR_LIT>'<EOL>if len(request.text) == <NUM_LIT:0>:<EOL><INDENT>data = json.loads('<STR_LIT:{}>')<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>data = json.loads(request.text)<EOL><DEDENT>except ValueError:<EOL><INDENT>data = request.text<EOL><DEDENT><DEDENT>return data<EOL>
Method to hanle both GET and POST requests.

:param endpoint: Endpoint of the API.
:param method: Method of HTTP request.
:param data: POST DATA for the request.
:param kwargs: Other keyword arguments.

:return: Response for the request.