def submit_transaction_v1( transaction: Dict[str, Any], callback_url: Optional[str], api_key: "api_key_model.APIKeyModel") -> Dict[str, str]: """Formats and enqueues individual transaction (from user input) to the webserver queue Returns: String of the submitted transaction id """ _log.info("[TRANSACTION] Parsing and loading user input") txn_model = _generate_transaction_model(transaction) # Check if allowed to create transaction of this type if not api_key.is_key_allowed( "transactions", "create", "create_transaction", False, extra_data={"requested_types": {txn_model.txn_type}}): raise exceptions.ActionForbidden( f"API Key is not allowed to create transaction of type {txn_model.txn_type}" ) _log.info("[TRANSACTION] Txn valid. Queueing txn object") queue.enqueue_item(txn_model.export_as_queue_task()) if callback_url: _log.info("[TRANSACTION] Registering callback for queued txn") callback.register_callback(txn_model.txn_id, callback_url) return {"transaction_id": txn_model.txn_id}
def submit_transaction_v1(transaction: Dict[str, Any], callback_url: Optional[str] = None) -> Dict[str, str]: """Formats and enqueues individual transaction (from user input) to the webserver queue Returns: String of the submitted transaction id """ _log.info("[TRANSACTION] Parsing and loading user input") txn_model = _generate_transaction_model(transaction) _log.info("[TRANSACTION] Txn valid. Queueing txn object") queue.enqueue_item(txn_model.export_as_queue_task()) _log.info("[TRANSACTION] insert transaction stub for pending transaction") _add_transaction_stub(txn_model) if callback_url: _log.info("[TRANSACTION] Registering callback for queued txn") callback.register_callback(txn_model.txn_id, callback_url) return {"transaction_id": txn_model.txn_id}
def test_register_if_callback_url_is_not_none(self, mock_hset): register_callback("banana", "NotNone") mock_hset.assert_called_once_with("dc:tx:callback", "banana", "NotNone")