def request(self, url, method="<STR_LIT:GET>", data=None, params=None, retry=True):
headers = config.REQUEST_HEADERS<EOL>if params and self._session_id:<EOL><INDENT>params['<STR_LIT>'] = self._session_id<EOL><DEDENT>if method == "<STR_LIT:GET>":<EOL><INDENT>response = requests.get(url, headers=headers, params=params)<EOL><DEDENT>elif method == "<STR_LIT:POST>":<EOL><INDENT>response = requests.post(url, headers=headers, params=params, data=data)<EOL><DEDENT>if response.status_code == <NUM_LIT> and retry:<EOL><INDENT>_LOGGER.warn("<STR_LIT>")<EOL>self._session_id = None<EOL>self.authenticate()<EOL>return self.request(url, method=method, data=data, params=params, retry=False)<EOL><DEDENT>response.raise_for_status()<EOL>try:<EOL><INDENT>return response.json()<EOL><DEDENT>except ValueError:<EOL><INDENT>return response<EOL><DEDENT>
Make a request to the NuHeat API

:param url: The URL to request
:param method: The type of request to make (GET, POST)
:param data: Data to be sent along with POST requests
:param params: Querystring parameters
:param retry: Attempt to re-authenticate and retry request if necessary