Changing json request return type, now it only returns dictionaries;
Changing the do method return interface. Now, instead of returning only the response body, it returns the entire response.master
parent
985ecd7e12
commit
94337e2949
|
@ -55,10 +55,8 @@ class API_Proxy:
|
|||
if res.status_code >= 400:
|
||||
raise Exception(f"HTTP ERROR: {str(res.status_code)} - {res.text}")
|
||||
|
||||
if res.headers.get("Content-Type") != None and res.headers.get("Content-Type").find("json") != -1:
|
||||
|
||||
return json.loads(res.text)
|
||||
else:
|
||||
return res.text
|
||||
|
||||
|
||||
def do (self, request: dict):
|
||||
|
@ -97,5 +95,12 @@ class API_Proxy:
|
|||
-> Estrutura APIProxyResponse já definida nesta classe.
|
||||
"""
|
||||
|
||||
return self.__request_json_post__ ("/ipc/apiproxy/do", request)
|
||||
do_response = self.__request_json_post__ ("/ipc/apiproxy/do", request)
|
||||
|
||||
do_response["body"] = base64.b64decode(do_response["body"])
|
||||
do_response["body"] = str(do_response["body"], "utf-8")
|
||||
|
||||
if do_response["header"]["Content-Type"].find("json") != -1:
|
||||
do_response["body"] = json.loads(do_response["body"])
|
||||
|
||||
return do_response
|
||||
|
|
Loading…
Reference in New Issue