summaryrefslogtreecommitdiff
path: root/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
diff options
context:
space:
mode:
authorMS <ms@taler.net>2020-05-28 17:21:52 +0200
committerMS <ms@taler.net>2020-05-28 17:21:52 +0200
commit729df3c1230b382bfeb26c8befce397cf1d29940 (patch)
tree96520d6a1ceb7d96a342a1f2d624bb41bc6dd270 /nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
parentb08fa41132983296ace7eb49eb424960c1bbe596 (diff)
downloadlibeufin-729df3c1230b382bfeb26c8befce397cf1d29940.tar.gz
libeufin-729df3c1230b382bfeb26c8befce397cf1d29940.tar.bz2
libeufin-729df3c1230b382bfeb26c8befce397cf1d29940.zip
TWG: finding the handler of outgoing history.
Diffstat (limited to 'nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt')
-rw-r--r--nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt38
1 files changed, 38 insertions, 0 deletions
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
index 09dbc801..3dc91fe9 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt
@@ -408,6 +408,43 @@ fun ingestTransactions() {
}
}
+suspend fun historyOutgoing(call: ApplicationCall): Unit {
+ /* sanitize URL arguments */
+ val subscriberId = authenticateRequest(call.request)
+ val delta: Int = expectInt(call.expectUrlParameter("delta"))
+ val start: Long = handleStartArgument(call.request.queryParameters["start"], delta)
+ val startCmpOp = getComparisonOperator(delta, start, TalerRequestedPayments)
+ /* retrieve database elements */
+ val history = TalerOutgoingHistory()
+ transaction {
+ /** Retrieve all the outgoing payments from the _clean Taler outgoing table_ */
+ val subscriberBankAccount = NexusBankAccountEntity.new { /* FIXME; exchange should communicate this value */ }
+ val reqPayments = TalerRequestedPaymentEntity.find {
+ TalerRequestedPayments.rawConfirmed.isNotNull() and startCmpOp
+ }.orderTaler(delta)
+ if (reqPayments.isNotEmpty()) {
+ reqPayments.subList(0, min(abs(delta), reqPayments.size)).forEach {
+ history.outgoing_transactions.add(
+ TalerOutgoingBankTransaction(
+ row_id = it.id.value,
+ amount = it.amount,
+ wtid = it.wtid,
+ date = GnunetTimestamp(it.rawConfirmed?.bookingDate?.div(1000) ?: throw NexusError(
+ HttpStatusCode.InternalServerError, "Null value met after check, VERY strange.")),
+ credit_account = it.creditAccount,
+ debit_account = buildPaytoUri(subscriberBankAccount.iban, subscriberBankAccount.bankCode),
+ exchange_base_url = "FIXME-to-request-along-subscriber-registration"
+ )
+ )
+ }
+ }
+ }
+ call.respond(
+ HttpStatusCode.OK,
+ TextContent(customConverter(history), ContentType.Application.Json)
+ )
+}
+
// /taler/history/incoming
suspend fun historyIncoming(call: ApplicationCall): Unit {
val exchangeUser = authenticateRequest(call.request)
@@ -455,6 +492,7 @@ fun talerFacadeRoutes(route: Route) {
return@post
}
route.get("/history/outgoing") {
+ historyOutgoing(call)
return@get
}
route.get("/history/incoming") {