33 lines
805 B
Python
33 lines
805 B
Python
from typing import Union, Dict, List
|
|
from ApiServiceRedis.Redis.Actions.actions import RedisRow
|
|
|
|
|
|
class RedisResponse:
|
|
|
|
def __init__(
|
|
self,
|
|
status: bool,
|
|
message: str,
|
|
data: RedisRow = None,
|
|
error: str = None,
|
|
):
|
|
self.status = status
|
|
self.message = message
|
|
self.data = data
|
|
if isinstance(data, dict):
|
|
self.data_type = "dict"
|
|
elif isinstance(data, list):
|
|
self.data_type = "list"
|
|
elif data is None:
|
|
self.data_type = None
|
|
self.error = error
|
|
|
|
def as_dict(self):
|
|
return {
|
|
"status": self.status,
|
|
"message": self.message,
|
|
"data": self.data,
|
|
"dataType": self.data_type,
|
|
"error": self.error,
|
|
}
|