Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions api/app/utils/ApiResponse.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class ApiResponse():
A class that formats correctly the expected
response from the web applicaiton.

@author : github.com/flavienbwk | berwic_f
@author : github.com/flavienbwk
"""

def __init__(self) -> None:
Expand Down Expand Up @@ -38,13 +38,13 @@ def setDetails(self, details: dict) -> None:
def setHTTPCode(self, http_code: int) -> None:
self.http_code = http_code

def getResponse(self) -> {"http_code": int, "error": bool, "message": str, "data": {}}:
def getResponse(self) -> {"http_code": int, "error": bool, "message": str, "details": {}}:
return {
"flask_api": True,
"http_code": self.http_code,
"error": self.error,
"message": self.message,
"data": self.details
"details": self.details
}

@staticmethod
Expand All @@ -56,7 +56,7 @@ def formatFlaskResponse(response):
Switching from the Flask "errors" key to
response format with "error" & "message".

Adding an empty "data" object if no details
Adding an empty "details" object if no details
are returned, to remain consistent.
"""
try:
Expand All @@ -76,8 +76,8 @@ def formatFlaskResponse(response):
response_data["message"] = ApiResponse.stringifyFlaskErrors(response_data["errors"])
response_data["error"] = True
del(response_data["errors"])
if "data" not in response_data:
response_data["data"] = {}
if "details" not in response_data:
response_data["details"] = {}
if "error" not in response_data:
response_data["error"] = True
if "http_code" in response_data:
Expand Down