def __init__(self, callResult):
self.success = False
try:
# decode from json if possible
result = callResult.json()
# if there is a status then the response came from the API server
if result['status']:
# so store a copy of the json
self.response = result
# copy the json result code
code = result['status']['code']
# assemble a description of the result
self.text = str(code) + ': ' + result['status']['info']
# if we got a 200 OK then the the json object has the answer data
if code == 200:
self.success = True
else:
# otherwise, assemble a description from the HTTP results
self.text = 'Error ' + str(callResult.status_code) + ': ' + callResult.reason
except JSONDecodeError:
self.text = 'Error ' + str(callResult.status_code) + ': ' + callResult.reason
# chat API call
评论列表
文章目录