def request(self, request_path, data=None, do_authentication=True, is_json=True):
uri = self.api_uri % request_path<EOL>request = urllib.request.Request(uri)<EOL>if is_json:<EOL><INDENT>request.add_header("<STR_LIT:Content-Type>", "<STR_LIT:application/json>")<EOL>if data is not None:<EOL><INDENT>request.add_data(json.dumps(data))<EOL><DEDENT><DEDENT>elif data is not None:<EOL><INDENT>request.add_data(data)<EOL><DEDENT>if do_authentication:<EOL><INDENT>if self.client_id is None or self.client_secret is None:<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>basic_auth = base64.b64encode("<STR_LIT>" % (self.client_id, self.client_secret))<EOL>request.add_header("<STR_LIT>", "<STR_LIT>" % basic_auth)<EOL><DEDENT>try:<EOL><INDENT>response = self._make_request(request)<EOL><DEDENT>except Exception as inst:<EOL><INDENT>raise <EOL><DEDENT>if '<STR_LIT:status>' in response:<EOL><INDENT>self._last_status_code = response['<STR_LIT:status>']['<STR_LIT:code>']<EOL>if '<STR_LIT:message>' in response['<STR_LIT:status>']:<EOL><INDENT>self._last_status_message = response['<STR_LIT:status>']['<STR_LIT:message>']<EOL><DEDENT>if '<STR_LIT:data>' in response:<EOL><INDENT>return response['<STR_LIT:data>']<EOL><DEDENT><DEDENT>return response<EOL>
Core "worker" for making requests and parsing JSON responses.

If `is_json` is ``True``, `data` should be a dictionary which
will be JSON-encoded.