Skip to content

Commit

Permalink
Modified response serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdria committed Nov 12, 2024
1 parent e598548 commit bf413c4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion esignanywhere_python_client/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ def __init__(
self.service_url = service_url
self.method_name = method_name
self.request_data = json.dumps(request_data)
self.response_headers = dict(response.headers)
try:
self.response_data = response.json()
except Exception:
try:
self.response_data = response.content
self.response_data = (
response.content.decode()
if isinstance(response.content, bytes)
else response.content
)
except Exception:
try:
self.response_data = response.text
Expand Down Expand Up @@ -66,6 +71,7 @@ def __str__(self):
f"method_name : {self.method_name}\n"
f"request_data : {str(self.request_data)}\n"
f"response_data : {str(self.response_data)}\n"
f"response_headers : {str(self.response_headers)}\n"
)


Expand All @@ -77,4 +83,5 @@ def __str__(self):
f"method_name: {self.method_name}\n"
f"request_data : {str(self.request_data)}\n"
f"response_data : {str(self.response_data)}\n"
f"response_headers : {str(self.response_headers)}\n"
)

0 comments on commit bf413c4

Please sign in to comment.