22
33import blocks .account .adapter .InMemoryAccountStorePort ;
44import blocks .account .adapter .InMemoryIdempotencyPort ;
5- import blocks .account .impl .AccountNotFoundException ;
6- import blocks .account .impl .InsufficientFundsException ;
7- import blocks .transaction .log .adapter .InMemoryTransactionStorePort ;
8-
5+ import blocks .alert .log .adapter .InMemoryAlertStorePort ;
6+ import com .bear .generated .account .Account_AlertLogBlockClient ;
97import com .bear .generated .account .Account_CreateAccount ;
108import com .bear .generated .account .Account_CreateAccountRequest ;
119import com .bear .generated .account .Account_Deposit ;
1513import com .bear .generated .account .Account_TransactionLogBlockClient ;
1614import com .bear .generated .account .Account_Withdraw ;
1715import com .bear .generated .account .Account_WithdrawRequest ;
16+ import com .bear .generated .account .AlertLogPort ;
1817import com .bear .generated .account .TransactionLogPort ;
18+ import com .bear .generated .alert .log .AlertLog_AppendAlert ;
19+ import com .bear .generated .alert .log .AlertLog_GetAlerts ;
20+ import com .bear .generated .alert .log .AlertLog_GetAlertsRequest ;
1921import com .bear .generated .transaction .log .TransactionLog_AppendTransaction ;
2022import com .bear .generated .transaction .log .TransactionLog_GetTransactions ;
2123import com .bear .generated .transaction .log .TransactionLog_GetTransactionsRequest ;
24+ import blocks .transaction .log .adapter .InMemoryTransactionStorePort ;
2225
2326public final class AccountApplication {
2427 private final Account_CreateAccount createAccount ;
2528 private final Account_Deposit deposit ;
2629 private final Account_Withdraw withdraw ;
2730 private final Account_GetBalance getBalance ;
2831 private final TransactionLog_GetTransactions getTransactions ;
32+ private final AlertLog_GetAlerts getAlerts ;
2933
3034 public AccountApplication () {
3135 InMemoryAccountStorePort accountStorePort = new InMemoryAccountStorePort ();
3236 InMemoryIdempotencyPort idempotencyPort = new InMemoryIdempotencyPort ();
3337 InMemoryTransactionStorePort transactionStorePort = new InMemoryTransactionStorePort ();
38+ InMemoryAlertStorePort alertStorePort = new InMemoryAlertStorePort ();
3439 TransactionLog_AppendTransaction appendTransaction = TransactionLog_AppendTransaction .of (transactionStorePort );
40+ AlertLog_AppendAlert appendAlert = AlertLog_AppendAlert .of (alertStorePort );
3541 TransactionLogPort transactionLogPort = new Account_TransactionLogBlockClient (appendTransaction );
42+ AlertLogPort alertLogPort = new Account_AlertLogBlockClient (appendAlert );
3643
37- this .createAccount = Account_CreateAccount .of (accountStorePort , idempotencyPort , transactionLogPort );
38- this .deposit = Account_Deposit .of (accountStorePort , idempotencyPort , transactionLogPort );
39- this .withdraw = Account_Withdraw .of (accountStorePort , idempotencyPort , transactionLogPort );
40- this .getBalance = Account_GetBalance .of (accountStorePort , idempotencyPort , transactionLogPort );
44+ this .createAccount = Account_CreateAccount .of (accountStorePort , alertLogPort , idempotencyPort , transactionLogPort );
45+ this .deposit = Account_Deposit .of (accountStorePort , alertLogPort , idempotencyPort , transactionLogPort );
46+ this .withdraw = Account_Withdraw .of (accountStorePort , alertLogPort , idempotencyPort , transactionLogPort );
47+ this .getBalance = Account_GetBalance .of (accountStorePort , alertLogPort , idempotencyPort , transactionLogPort );
4148 this .getTransactions = TransactionLog_GetTransactions .of (transactionStorePort );
49+ this .getAlerts = AlertLog_GetAlerts .of (alertStorePort );
4250 }
4351
4452 public String createAccount (String ownerId ) {
@@ -62,6 +70,11 @@ public String getTransactionsJson(String accountId, Integer sinceSeq) {
6270 return getTransactions .execute (new TransactionLog_GetTransactionsRequest (accountId , sinceSeq )).getTransactionsJson ();
6371 }
6472
73+ public String getAlertsJson (String accountId ) {
74+ getBalance (accountId );
75+ return getAlerts .execute (new AlertLog_GetAlertsRequest (accountId )).getAlertsJson ();
76+ }
77+
6578 private static OperationResult toOperationResult (com .bear .generated .account .Account_DepositResult result ) {
6679 return new OperationResult (result .getBalanceCents (), result .getTxSeq ());
6780 }
@@ -72,4 +85,4 @@ private static OperationResult toOperationResult(com.bear.generated.account.Acco
7285
7386 public record OperationResult (int balanceCents , int txSeq ) {
7487 }
75- }
88+ }
0 commit comments