def api(self, name, url, **kwargs):
if name not in self._apis:<EOL><INDENT>raise ValueError('<STR_LIT>'.format(<EOL>tuple(self._apis), name))<EOL><DEDENT>fields = kwargs.get('<STR_LIT>')<EOL>timeout = kwargs.get('<STR_LIT>')<EOL>text = kwargs.get('<STR_LIT:text>')<EOL>html = kwargs.get('<STR_LIT:html>')<EOL>if text and html:<EOL><INDENT>raise ValueError(u'<STR_LIT>')<EOL><DEDENT>params = {'<STR_LIT:url>': url, '<STR_LIT>': self._token}<EOL>if timeout:<EOL><INDENT>params['<STR_LIT>'] = timeout<EOL><DEDENT>if fields:<EOL><INDENT>if not isinstance(fields, str):<EOL><INDENT>fields = '<STR_LIT:U+002C>'.join(sorted(fields))<EOL><DEDENT>params['<STR_LIT>'] = fields<EOL><DEDENT>url = self.endpoint(name)<EOL>if text or html:<EOL><INDENT>content_type = html and '<STR_LIT>' or '<STR_LIT>'<EOL>return self._post(url, text or html, content_type, params=params)<EOL><DEDENT>return self._get(url, params=params)<EOL>
Generic API method.