def api_call_helper(self, name, http_method, params, data):
# helper formats the url and reads error codes nicely
url = self.config['host'] + self.config['routes'][name]
if params is not None:
url = url.format(**params)
response = self.api_call(url, http_method, data)
if response.status_code != 200:
raise requests.HTTPError(response.text)
body = json.loads(response.text)
if is_status_2xx(body['code']):
# success
return body['data']
else:
raise requests.HTTPError(response.text)
return
评论列表
文章目录