summaryrefslogtreecommitdiff
path: root/app/src/main/java/net/taler/wallet/history/HistoryEvent.kt
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/net/taler/wallet/history/HistoryEvent.kt')
-rw-r--r--app/src/main/java/net/taler/wallet/history/HistoryEvent.kt176
1 files changed, 168 insertions, 8 deletions
diff --git a/app/src/main/java/net/taler/wallet/history/HistoryEvent.kt b/app/src/main/java/net/taler/wallet/history/HistoryEvent.kt
index 34f3164..31473f6 100644
--- a/app/src/main/java/net/taler/wallet/history/HistoryEvent.kt
+++ b/app/src/main/java/net/taler/wallet/history/HistoryEvent.kt
@@ -1,10 +1,30 @@
+/*
+ This file is part of GNU Taler
+ (C) 2019 Taler Systems S.A.
+
+ GNU Taler is free software; you can redistribute it and/or modify it under the
+ terms of the GNU General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along with
+ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
package net.taler.wallet.history
+import androidx.annotation.DrawableRes
+import androidx.annotation.LayoutRes
+import androidx.annotation.StringRes
import com.fasterxml.jackson.annotation.*
import com.fasterxml.jackson.annotation.JsonInclude.Include.NON_EMPTY
import com.fasterxml.jackson.annotation.JsonSubTypes.Type
import com.fasterxml.jackson.annotation.JsonTypeInfo.As.PROPERTY
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id.NAME
+import net.taler.wallet.R
enum class ReserveType {
/**
@@ -20,7 +40,22 @@ enum class ReserveType {
}
@JsonInclude(NON_EMPTY)
-class ReserveCreationDetail(val type: ReserveType)
+class ReserveCreationDetail(val type: ReserveType, val bankUrl: String?)
+
+enum class RefreshReason {
+ @JsonProperty("manual")
+ MANUAL,
+ @JsonProperty("pay")
+ PAY,
+ @JsonProperty("refund")
+ REFUND,
+ @JsonProperty("abort-pay")
+ ABORT_PAY,
+ @JsonProperty("recoup")
+ RECOUP,
+ @JsonProperty("backup-restored")
+ BACKUP_RESTORED
+}
@JsonInclude(NON_EMPTY)
@@ -45,7 +80,7 @@ class ReserveShortInfo(
val reserveCreationDetail: ReserveCreationDetail
)
-class History: ArrayList<HistoryEvent>()
+class History : ArrayList<HistoryEvent>()
@JsonTypeInfo(
use = NAME,
@@ -56,7 +91,11 @@ class History: ArrayList<HistoryEvent>()
Type(value = ExchangeAddedEvent::class, name = "exchange-added"),
Type(value = ExchangeUpdatedEvent::class, name = "exchange-updated"),
Type(value = ReserveBalanceUpdatedEvent::class, name = "reserve-balance-updated"),
- Type(value = HistoryWithdrawnEvent::class, name = "withdrawn")
+ Type(value = HistoryWithdrawnEvent::class, name = "withdrawn"),
+ Type(value = HistoryOrderAcceptedEvent::class, name = "order-accepted"),
+ Type(value = HistoryOrderRefusedEvent::class, name = "order-refused"),
+ Type(value = HistoryPaymentSentEvent::class, name = "payment-sent"),
+ Type(value = HistoryRefreshedEvent::class, name = "refreshed")
)
@JsonIgnoreProperties(
value = [
@@ -64,7 +103,13 @@ class History: ArrayList<HistoryEvent>()
]
)
abstract class HistoryEvent(
- val timestamp: Timestamp
+ val timestamp: Timestamp,
+ @get:LayoutRes
+ open val layout: Int = R.layout.history_row,
+ @get:StringRes
+ open val title: Int = 0,
+ @get:DrawableRes
+ open val icon: Int = R.drawable.ic_account_balance
)
@@ -73,13 +118,17 @@ class ExchangeAddedEvent(
timestamp: Timestamp,
val exchangeBaseUrl: String,
val builtIn: Boolean
-) : HistoryEvent(timestamp)
+) : HistoryEvent(timestamp) {
+ override val title = R.string.history_event_exchange_added
+}
@JsonTypeName("exchange-updated")
class ExchangeUpdatedEvent(
timestamp: Timestamp,
val exchangeBaseUrl: String
-) : HistoryEvent(timestamp)
+) : HistoryEvent(timestamp) {
+ override val title = R.string.history_event_exchange_updated
+}
@JsonTypeName("reserve-balance-updated")
@@ -99,7 +148,9 @@ class ReserveBalanceUpdatedEvent(
* considering ongoing withdrawals from that reserve.
*/
val amountExpected: String
-) : HistoryEvent(timestamp)
+) : HistoryEvent(timestamp) {
+ override val title = R.string.history_event_reserve_balance_updated
+}
@JsonTypeName("withdrawn")
class HistoryWithdrawnEvent(
@@ -123,8 +174,94 @@ class HistoryWithdrawnEvent(
* Amount that actually was added to the wallet's balance.
*/
val amountWithdrawnEffective: String
-) : HistoryEvent(timestamp)
+) : HistoryEvent(timestamp) {
+ override val layout = R.layout.history_withdrawn
+ override val title = R.string.history_event_withdrawn
+ override val icon = R.drawable.history_withdrawn
+}
+@JsonTypeName("order-accepted")
+class HistoryOrderAcceptedEvent(
+ timestamp: Timestamp,
+ /**
+ * Condensed info about the order.
+ */
+ val orderShortInfo: OrderShortInfo
+) : HistoryEvent(timestamp) {
+ override val icon = R.drawable.ic_add_circle
+ override val title = R.string.history_event_order_accepted
+}
+
+@JsonTypeName("order-refused")
+class HistoryOrderRefusedEvent(
+ timestamp: Timestamp,
+ /**
+ * Condensed info about the order.
+ */
+ val orderShortInfo: OrderShortInfo
+) : HistoryEvent(timestamp) {
+ override val icon = R.drawable.ic_cancel
+ override val title = R.string.history_event_order_refused
+}
+
+@JsonTypeName("payment-sent")
+class HistoryPaymentSentEvent(
+ timestamp: Timestamp,
+ /**
+ * Condensed info about the order that we already paid for.
+ */
+ val orderShortInfo: OrderShortInfo,
+ /**
+ * Set to true if the payment has been previously sent
+ * to the merchant successfully, possibly with a different session ID.
+ */
+ val replay: Boolean,
+ /**
+ * Number of coins that were involved in the payment.
+ */
+ val numCoins: Int,
+ /**
+ * Amount that was paid, including deposit and wire fees.
+ */
+ val amountPaidWithFees: String,
+ /**
+ * Session ID that the payment was (re-)submitted under.
+ */
+ val sessionId: String?
+) : HistoryEvent(timestamp) {
+ override val layout = R.layout.history_payment_sent
+ override val title = R.string.history_event_payment_sent
+ override val icon = R.drawable.ic_cash_usd_outline
+}
+
+@JsonTypeName("refreshed")
+class HistoryRefreshedEvent(
+ timestamp: Timestamp,
+ /**
+ * Amount that is now available again because it has
+ * been refreshed.
+ */
+ val amountRefreshedEffective: String,
+ /**
+ * Amount that we spent for refreshing.
+ */
+ val amountRefreshedRaw: String,
+ /**
+ * Why was the refreshing done?
+ */
+ val refreshReason: RefreshReason,
+ val numInputCoins: Int,
+ val numRefreshedInputCoins: Int,
+ val numOutputCoins: Int,
+ /**
+ * Identifier for a refresh group, contains one or
+ * more refresh session IDs.
+ */
+ val refreshGroupId: String
+) : HistoryEvent(timestamp) {
+ override val icon = R.drawable.ic_history_black_24dp
+ override val title = R.string.history_event_refreshed
+}
@JsonTypeInfo(
use = NAME,
@@ -145,3 +282,26 @@ class WithdrawalSourceTip(
class WithdrawalSourceReserve(
val reservePub: String
) : WithdrawalSource()
+
+data class OrderShortInfo(
+ /**
+ * Wallet-internal identifier of the proposal.
+ */
+ val proposalId: String,
+ /**
+ * Order ID, uniquely identifies the order within a merchant instance.
+ */
+ val orderId: String,
+ /**
+ * Base URL of the merchant.
+ */
+ val merchantBaseUrl: String,
+ /**
+ * Amount that must be paid for the contract.
+ */
+ val amount: String,
+ /**
+ * Summary of the proposal, given by the merchant.
+ */
+ val summary: String
+)