Esempio n. 1
0
    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
Esempio n. 2
0
 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)
Esempio n. 3
0
 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)
Esempio n. 4
0
 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)
Esempio n. 5
0
 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)
Esempio n. 6
0
 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)
Esempio n. 7
0
 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)
Esempio n. 8
0
 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)
Esempio n. 9
0
 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
Esempio n. 10
0
 def do_logout(self, encoded_token=None):
     self.revokesExistedToken(encoded_token)
     return get_json_template(response=True,
                              results=-1,
                              total=-1,
                              message="Logout Success.")