summaryrefslogtreecommitdiff
path: root/wallet/src/main/java/net/taler/wallet/transactions/TransactionManager.kt
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2023-05-15 15:34:24 -0600
committerIván Ávalos <avalos@disroot.org>2023-06-28 19:59:12 -0600
commitf72b427cc7df48f42b99eda5aa6f4f3b66e533a9 (patch)
tree6a106816bce90a2248d39676ec4318f05f027980 /wallet/src/main/java/net/taler/wallet/transactions/TransactionManager.kt
parentd99fd893dbe66e64954114bfd2bd6a37f388cc2b (diff)
downloadtaler-android-f72b427cc7df48f42b99eda5aa6f4f3b66e533a9.tar.gz
taler-android-f72b427cc7df48f42b99eda5aa6f4f3b66e533a9.tar.bz2
taler-android-f72b427cc7df48f42b99eda5aa6f4f3b66e533a9.zip
[wallet] Implemented DD37 with the new txActions field
Diffstat (limited to 'wallet/src/main/java/net/taler/wallet/transactions/TransactionManager.kt')
-rw-r--r--wallet/src/main/java/net/taler/wallet/transactions/TransactionManager.kt45
1 files changed, 43 insertions, 2 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/transactions/TransactionManager.kt b/wallet/src/main/java/net/taler/wallet/transactions/TransactionManager.kt
index ed4c4da..dfe25ad 100644
--- a/wallet/src/main/java/net/taler/wallet/transactions/TransactionManager.kt
+++ b/wallet/src/main/java/net/taler/wallet/transactions/TransactionManager.kt
@@ -26,7 +26,7 @@ import kotlinx.coroutines.launch
import net.taler.wallet.TAG
import net.taler.wallet.backend.TalerErrorInfo
import net.taler.wallet.backend.WalletBackendApi
-import net.taler.wallet.transactions.ExtendedStatus.Pending
+import net.taler.wallet.transactions.TransactionMajorState.Pending
import java.util.LinkedList
sealed class TransactionsResult {
@@ -79,7 +79,7 @@ class TransactionManager(
val transactions = LinkedList(result.transactions)
// TODO remove when fixed in wallet-core
val comparator = compareBy<Transaction>(
- { it.extendedStatus == Pending },
+ { it.txState.major == Pending },
{ it.timestamp.ms },
{ it.transactionId }
)
@@ -138,7 +138,48 @@ class TransactionManager(
}
}
+ fun retryTransaction(transactionId: String) = scope.launch {
+ api.request<Unit>("retryTransaction") {
+ put("transactionId", transactionId)
+ }.onError {
+ Log.e(TAG, "Error retryTransaction $it")
+ }.onSuccess {
+ loadTransactions()
+ }
+ }
+
+ fun abortTransaction(transactionId: String) = scope.launch {
+ api.request<Unit>("abortTransaction") {
+ put("transactionId", transactionId)
+ }.onError {
+ Log.e(TAG, "Error abortTransaction $it")
+ }.onSuccess {
+ loadTransactions()
+ }
+ }
+
+ fun suspendTransaction(transactionId: String) = scope.launch {
+ api.request<Unit>("suspendTransaction") {
+ put("transactionId", transactionId)
+ }.onError {
+ Log.e(TAG, "Error suspendTransaction $it")
+ }.onSuccess {
+ loadTransactions()
+ }
+ }
+
+ fun resumeTransaction(transactionId: String) = scope.launch {
+ api.request<Unit>("resumeTransaction") {
+ put("transactionId", transactionId)
+ }.onError {
+ Log.e(TAG, "Error resumeTransaction $it")
+ }.onSuccess {
+ loadTransactions()
+ }
+ }
+
fun deleteTransactions(transactionIds: List<String>) {
+ // TODO: do NOT delete non-deletable transactions
transactionIds.forEach { id ->
deleteTransaction(id)
}