commit af043ff81663ae2e1029a3fde56e031f13a8adb4
parent 3cb47562212364162a82c83fd73074573d9f883e
Author: MS <ms@taler.net>
Date: Fri, 19 Jun 2020 16:57:33 +0200
listing raw bank accounts
Diffstat:
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt
@@ -423,7 +423,31 @@ fun Route.ebicsBankConnectionRoutes(client: HttpClient) {
}
get("/accounts") {
val ret = BankAccounts()
- call.respond(object {})
+ transaction {
+ val conn = requireBankConnection(call, "connid")
+ val hasXml = RawHTDResponseEntity.findById(conn.id.value) ?: throw NexusError(
+ HttpStatusCode.NotFound, "Bank connection ${conn.id.value} never called HTD"
+ )
+ val payload = XMLUtil.convertStringToJaxb<HTDResponseOrderData>(hasXml.htdResponse)
+ payload.value.partnerInfo.accountInfoList?.forEach {
+ ret.accounts.add(
+ BankAccount(
+ holder = it.accountHolder ?: "NOT-GIVEN",
+ iban = it.accountNumberList?.filterIsInstance<EbicsTypes.GeneralAccountNumber>()
+ ?.find { it.international }?.value
+ ?: throw NexusError(HttpStatusCode.NotFound, reason = "bank gave no IBAN"),
+ bic = it.bankCodeList?.filterIsInstance<EbicsTypes.GeneralBankCode>()
+ ?.find { it.international }?.value
+ ?: throw NexusError(
+ HttpStatusCode.NotFound,
+ reason = "bank gave no BIC"
+ ),
+ account = it.id
+ )
+ )
+ }
+ }
+ call.respond(ret)
}
post("/account/import") {
call.respond(object {})