def check_wallet_for_amount(user_id, amount) -> Response: try: amount = Decimal(amount).quantize(Decimal('1.00')) data = query_service.check_available_amount(user_id, amount) return json.dumps(data) except Exception as err: return handle_error(err)
def get_wallet_all_transactions(user_id) -> Response: try: token = request.headers.get('Authorization') security.validate_owner(token, user_id) data = query_service.get_wallet_all_transactions(user_id) return json.dumps(data) except Exception as err: return handle_error(err)
def check_transaction_status(transaction_id) -> Response: try: token = request.headers.get('Authorization') data = query_service.get_transaction(transaction_id) security.validate_party(token, data) return json.dumps(data) except Exception as err: return handle_error(err)
def create_transaction() -> Response: try: token = request.headers.get('Authorization') params = json.loads(request.data.decode()) tipo = params.get('type') if tipo and tipo == 'consolidacion': security.validate_admin_role(token) else: security.validate_party(token, params) data = command_service.create_transaction(params) return json.dumps(data) except Exception as err: return handle_error(err)
def modify_wallet_status(user_id) -> Response: try: token = request.headers.get('Authorization') params = json.loads(request.data.decode()) if params.get('estado') == 'cerrada': security.validate_admin_role(token) params['role'] = 'admin' else: security.validate_owner_or_admin_role(token, user_id) params['role'] = 'user' data = command_service.update_status(user_id, params) return json.dumps(data) except Exception as err: return handle_error(err)
def get_wallet_status(user_id) -> Response: try: data = query_service.get_wallet_status(user_id) return json.dumps(data) except Exception as err: return handle_error(err)