def call(
self,
method: str,
data: Dict[str, str]=None
) -> Dict[str, Any]:
"""Call API methods."""
async with aiohttp.ClientSession() as session:
form = aiohttp.FormData(data or {})
form.add_field('token', self.config.TOKEN)
async with session.post(
'https://slack.com/api/{}'.format(method),
data=form
) as response:
if response.status == 200:
return await response.json(loads=ujson.loads)
else:
raise APICallError('fail to call {} with {}'.format(
method, data
))
评论列表
文章目录