def request(self, method, url_parts, headers=None, data=None):
if method in self.ALLOWED_REQUESTS:<EOL><INDENT>headers = headers or {}<EOL>if self.token_type == '<STR_LIT>':<EOL><INDENT>headers.update(<EOL>{'<STR_LIT>': self.api_key,<EOL>'<STR_LIT>': '<STR_LIT>'})<EOL><DEDENT>elif self.token_type == '<STR_LIT>':<EOL><INDENT>headers.update(<EOL>{'<STR_LIT>': '<STR_LIT>' + self.api_key,<EOL>'<STR_LIT>': '<STR_LIT>'})<EOL><DEDENT>else:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>'.format(self.token_type))<EOL><DEDENT>url = urlparse.urljoin(<EOL>self.api_base,<EOL>'<STR_LIT:/>'.join([str(url_part) for url_part in url_parts])<EOL>)<EOL>return self.parse_response(<EOL>getattr(requests, method)(url, headers=headers, data=data)<EOL>)<EOL><DEDENT>else:<EOL><INDENT>raise error.BadRequestError(<EOL>'<STR_LIT>' % method)<EOL><DEDENT>
Method for making requests to the Optimizely API