def _api_call(self, method, **kwargs):
# type: (str, **Any) -> Dict[str, Any]
'''
Performs a _validated_ Slack API call. After performing a normal API
call using SlackClient, validate that the call returned 'ok'. If not,
log and error.
Args:
method (str): The API endpoint to call.
**kwargs: Any arguments to pass on to the request.
Returns:
(dict): Parsed JSON from the response.
'''
response = self._slack.api_call(method, **kwargs)
if not ('ok' in response and response['ok']):
if kwargs:
logging.error('Bad Slack API request on {} with {}'.format(method, kwargs))
else:
logging.error('Bad Slack API request on {}'.format(method))
return response
评论列表
文章目录