auth endpoints added
This commit is contained in:
@@ -67,7 +67,7 @@ class RedisResponse:
|
||||
# Process single RedisRow
|
||||
if isinstance(data, RedisRow):
|
||||
result = {**main_dict}
|
||||
if hasattr(data, 'keys') and hasattr(data, 'row'):
|
||||
if hasattr(data, "keys") and hasattr(data, "row"):
|
||||
if not isinstance(data.keys, str):
|
||||
raise ValueError("RedisRow keys must be string type")
|
||||
result[data.keys] = data.row
|
||||
@@ -80,7 +80,11 @@ class RedisResponse:
|
||||
# Handle list of RedisRow objects
|
||||
rows_dict = {}
|
||||
for row in data:
|
||||
if isinstance(row, RedisRow) and hasattr(row, 'keys') and hasattr(row, 'row'):
|
||||
if (
|
||||
isinstance(row, RedisRow)
|
||||
and hasattr(row, "keys")
|
||||
and hasattr(row, "row")
|
||||
):
|
||||
if not isinstance(row.keys, str):
|
||||
raise ValueError("RedisRow keys must be string type")
|
||||
rows_dict[row.keys] = row.row
|
||||
@@ -137,10 +141,10 @@ class RedisResponse:
|
||||
|
||||
if isinstance(self.data, list) and self.data:
|
||||
item = self.data[0]
|
||||
if isinstance(item, RedisRow) and hasattr(item, 'row'):
|
||||
if isinstance(item, RedisRow) and hasattr(item, "row"):
|
||||
return item.row
|
||||
return item
|
||||
elif isinstance(self.data, RedisRow) and hasattr(self.data, 'row'):
|
||||
elif isinstance(self.data, RedisRow) and hasattr(self.data, "row"):
|
||||
return self.data.row
|
||||
elif isinstance(self.data, dict):
|
||||
return self.data
|
||||
@@ -168,16 +172,16 @@ class RedisResponse:
|
||||
"success": self.status,
|
||||
"message": self.message,
|
||||
}
|
||||
|
||||
|
||||
if self.error:
|
||||
response["error"] = self.error
|
||||
|
||||
if self.data is not None:
|
||||
if self.data_type == "row" and hasattr(self.data, 'to_dict'):
|
||||
if self.data_type == "row" and hasattr(self.data, "to_dict"):
|
||||
response["data"] = self.data.to_dict()
|
||||
elif self.data_type == "list":
|
||||
try:
|
||||
if all(hasattr(item, 'to_dict') for item in self.data):
|
||||
if all(hasattr(item, "to_dict") for item in self.data):
|
||||
response["data"] = [item.to_dict() for item in self.data]
|
||||
else:
|
||||
response["data"] = self.data
|
||||
@@ -192,5 +196,5 @@ class RedisResponse:
|
||||
return {
|
||||
"success": False,
|
||||
"message": "Error formatting response",
|
||||
"error": str(e)
|
||||
}
|
||||
"error": str(e),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user