class APIResponse(): msg = 'ok' error = 0 data = {} def __init__(self, data, msg=None, error=None, header=None): if msg: self.msg = msg self.data = data def body(self): body = self.__dict__ body["data"] = self.data body["msg"] = self.msg body["code"] = self.error return body