def __extract_data(self, encrypted_data): try: json_data = json.loads(fernet.decrypt(encrypted_data.encode()).decode('utf8')) self.binary_id = json_data["binary_id"] balance = self.__get_balance(json_data) result = get_json_template(response=True, results=balance, message="Balance collected", total=-1) except: result = get_json_template(message="Unable to collect balance info", total=-1) return result
def register(self, json_data): run_transaction(sessionmaker(bind=engine), lambda var: self.trx_register(var, json_data)) return get_json_template(response=self.resp_status, results=self.resp_data, total=-1, message=self.msg)
def get_data_by_userid(self, userid): run_transaction(sessionmaker(bind=engine), lambda var: self.trx_get_data_by_userid(var, userid)) return get_json_template(response=self.resp_status, results=self.resp_data, total=-1, message=self.msg)
def validate_user(self, json_data): run_transaction(sessionmaker(bind=engine), lambda var: self.__validate_login_data(var, json_data)) return get_json_template(response=self.resp_status, results=self.resp_data, total=-1, message=self.msg)
def delete_all_user_data(self, get_args=None): get_args = self.__extract_get_args(get_args) run_transaction(sessionmaker(bind=engine), lambda var: self.trx_del_all_data(var, get_args)) return get_json_template(response=self.resp_status, results=self.resp_data, total=-1, message=self.msg)
def get_data_by_hobby(self, hobby, register_after): run_transaction( sessionmaker(bind=engine), lambda var: self.trx_get_data_by_hobby(var, hobby, register_after)) return get_json_template(response=self.resp_status, results=self.resp_data, total=-1, message=self.msg)
def get_users(self, get_args=None): get_args = self.__extract_get_args(get_args) run_transaction(sessionmaker(bind=engine), lambda var: self.trx_get_users(var, get_args=get_args)) return get_json_template(response=self.resp_status, results=self.resp_data, message=self.msg, total=self.total_records)
def get_data_by_hobby_between(self, hobby, start_date, end_date): run_transaction( sessionmaker(bind=engine), lambda var: self.trx_get_data_by_hobby_between( var, hobby, start_date, end_date)) return get_json_template(response=self.resp_status, results=self.resp_data, total=-1, message=self.msg)
def post(self): '''Login using Binary Token to get Server Token''' try: json_data = api.payload resp = User().validate_user(json_data=json_data) return masked_json_template(resp, 200) except: resp = get_json_template(response=False, message="No Json Input Found.", results=-1, total=-1) return resp, 404
def do_logout(self, encoded_token=None): self.revokesExistedToken(encoded_token) return get_json_template(response=True, results=-1, total=-1, message="Logout Success.")