[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] 05/09: Circuit API.
From: |
gnunet |
Subject: |
[libeufin] 05/09: Circuit API. |
Date: |
Fri, 20 Jan 2023 16:49:39 +0100 |
This is an automated email from the git hooks/post-receive script.
ms pushed a commit to branch master
in repository libeufin.
commit 57f578ddcd03cc8efd9c51d470b875e2ee0a6b52
Author: MS <ms@taler.net>
AuthorDate: Fri Jan 20 15:18:09 2023 +0100
Circuit API.
Including the confirmation time along
the cash-out operation details.
---
.../kotlin/tech/libeufin/sandbox/CircuitApi.kt | 51 ++++++++++++++--------
.../src/main/kotlin/tech/libeufin/sandbox/DB.kt | 6 ++-
2 files changed, 37 insertions(+), 20 deletions(-)
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/CircuitApi.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/CircuitApi.kt
index a6e97778..721b3c16 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/CircuitApi.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/CircuitApi.kt
@@ -13,7 +13,6 @@ import java.io.File
import java.io.InputStreamReader
import java.math.BigDecimal
import java.math.MathContext
-import java.util.*
import java.util.concurrent.TimeUnit
import kotlin.text.toByteArray
@@ -86,6 +85,17 @@ data class CircuitAccountInfo(
val cashout_address: String
)
+data class CashoutOperationInfo(
+ val state: CashoutOperationState,
+ val amount_credit: String,
+ val amount_debit: String,
+ val subject: String,
+ val creation_time: Long, // milliseconds
+ val confirmation_time: Long?, // milliseconds
+ val tan_channel: SupportedTanChannels,
+ val account: String
+)
+
data class CashoutConfirmation(val tan: String)
// Validate phone number
@@ -241,13 +251,16 @@ fun circuitApi(circuitRoute: Route) {
* NOTE: the funds availability got already checked when this operation
* was created. On top of that, the 'wireTransfer()' helper does also
* check for funds availability. */
- wireTransfer(
- debitAccount = op.account,
- creditAccount = "admin",
- subject = op.subject,
- amount = op.amountDebit
- )
- transaction { op.state = CashoutOperationState.CONFIRMED }
+ transaction {
+ wireTransfer(
+ debitAccount = op.account,
+ creditAccount = "admin",
+ subject = op.subject,
+ amount = op.amountDebit
+ )
+ op.state = CashoutOperationState.CONFIRMED
+ op.confirmationTime = getUTCnow().toInstant().toEpochMilli()
+ }
call.respond(HttpStatusCode.NoContent)
return@post
}
@@ -263,15 +276,17 @@ fun circuitApi(circuitRoute: Route) {
}
if (maybeOperation == null)
throw notFound("Cash-out operation $operationUuid not found.")
- call.respond(object {
- val status = maybeOperation.state
- val amount_credit = maybeOperation.amountCredit
- val amount_debit = maybeOperation.amountDebit
- val subject = maybeOperation.subject
- val creation_time = maybeOperation.creationTime.toString()
- val cashout_address = maybeOperation.tanChannel
- val account = maybeOperation.account
- })
+ val ret = CashoutOperationInfo(
+ amount_credit = maybeOperation.amountCredit,
+ amount_debit = maybeOperation.amountDebit,
+ subject = maybeOperation.subject,
+ state = maybeOperation.state,
+ creation_time = maybeOperation.creationTime,
+ confirmation_time = maybeOperation.confirmationTime,
+ tan_channel = maybeOperation.tanChannel,
+ account = maybeOperation.account
+ )
+ call.respond(ret)
return@get
}
// Gets the list of all the cash-out operations.
@@ -354,7 +369,7 @@ fun circuitApi(circuitRoute: Route) {
this.amountCredit = req.amount_credit
this.subject = cashoutSubject
this.creationTime = getUTCnow().toInstant().toEpochMilli()
- this.tanChannel = tanChannel
+ this.tanChannel = SupportedTanChannels.valueOf(tanChannel)
this.account = user
this.tan = getRandomString(5)
}
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
index 3adb1a27..92171281 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/DB.kt
@@ -442,8 +442,9 @@ object CashoutOperationsTable : LongIdTable() {
val amountDebit = text("amountDebit")
val amountCredit = text("amountCredit")
val subject = text("subject")
- val creationTime = long("creationTime") // in seconds.
- val tanChannel = text("tanChannel")
+ val creationTime = long("creationTime") // in milliseconds.
+ val confirmationTime = long("confirmationTime").nullable() // in
milliseconds.
+ val tanChannel = enumeration("tanChannel", SupportedTanChannels::class)
val account = text("account")
val tan = text("tan")
val state = enumeration("state",
CashoutOperationState::class).default(CashoutOperationState.PENDING)
@@ -456,6 +457,7 @@ class CashoutOperationEntity(id: EntityID<Long>) :
LongEntity(id) {
var amountCredit by CashoutOperationsTable.amountCredit
var subject by CashoutOperationsTable.subject
var creationTime by CashoutOperationsTable.creationTime
+ var confirmationTime by CashoutOperationsTable.confirmationTime
var tanChannel by CashoutOperationsTable.tanChannel
var account by CashoutOperationsTable.account
var tan by CashoutOperationsTable.tan
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libeufin] branch master updated (048e0ada -> 45147878), gnunet, 2023/01/20
- [libeufin] 03/09: Circuit API., gnunet, 2023/01/20
- [libeufin] 02/09: 204 responses with less code., gnunet, 2023/01/20
- [libeufin] 04/09: testing the previous change, gnunet, 2023/01/20
- [libeufin] 08/09: Error management., gnunet, 2023/01/20
- [libeufin] 06/09: CLI, gnunet, 2023/01/20
- [libeufin] 07/09: adapt test, gnunet, 2023/01/20
- [libeufin] 01/09: CLI., gnunet, 2023/01/20
- [libeufin] 09/09: revert name change to match the docs, gnunet, 2023/01/20
- [libeufin] 05/09: Circuit API.,
gnunet <=