[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] 01/05: Inline helper function
From: |
gnunet |
Subject: |
[libeufin] 01/05: Inline helper function |
Date: |
Thu, 18 Jun 2020 15:27:03 +0200 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository libeufin.
commit 12c1a45ce0bb96b874d27629a7ac0ead227ac773
Author: Florian Dold <florian.dold@gmail.com>
AuthorDate: Thu Jun 18 12:30:50 2020 +0530
Inline helper function
---
nexus/build.gradle | 1 -
nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt | 16 ----------------
.../main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt | 13 ++++++++-----
3 files changed, 8 insertions(+), 22 deletions(-)
diff --git a/nexus/build.gradle b/nexus/build.gradle
index 4a20556..069a437 100644
--- a/nexus/build.gradle
+++ b/nexus/build.gradle
@@ -120,4 +120,3 @@ jar {
run {
standardInput = System.in
}
-
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
index a3567c5..b9851bb 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt
@@ -50,22 +50,6 @@ fun extractFirstIban(bankAccounts:
List<EbicsTypes.AbstractAccountNumber>?): Str
return null
}
-/**
- * Skip national only-numeric codes, and returns the first BIC in list
- */
-fun extractFirstBic(bankCodes: List<EbicsTypes.AbstractBankCode>?): String? {
- if (bankCodes == null)
- return null
-
- for (item in bankCodes) {
- if (item is EbicsTypes.GeneralBankCode) {
- if (item.international)
- return item.value
- }
- }
- return null
-}
-
fun getEbicsSubscriberDetailsInternal(subscriber: EbicsSubscriberEntity):
EbicsClientSubscriberDetails {
var bankAuthPubValue: RSAPublicKey? = null
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt
index abbcaf1..2c9741d 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt
@@ -45,6 +45,7 @@ import org.jetbrains.exposed.sql.transactions.transaction
import tech.libeufin.nexus.*
import tech.libeufin.nexus.logger
import tech.libeufin.util.*
+import tech.libeufin.util.ebics_h004.EbicsTypes
import tech.libeufin.util.ebics_h004.HTDResponseOrderData
import java.io.ByteArrayOutputStream
import java.security.interfaces.RSAPrivateCrtKey
@@ -332,14 +333,16 @@ fun Route.ebicsBankConnectionRoutes(client: HttpClient) {
transaction {
val conn = requireBankConnection(call, "connid")
payload.value.partnerInfo.accountInfoList?.forEach {
- val bankAccount = NexusBankAccountEntity.new(id =
it.id) {
+ NexusBankAccountEntity.new(id = it.id) {
accountHolder = it.accountHolder ?: "NOT-GIVEN"
iban = extractFirstIban(it.accountNumberList)
?: throw NexusError(HttpStatusCode.NotFound,
reason = "bank gave no IBAN")
- bankCode = extractFirstBic(it.bankCodeList) ?:
throw NexusError(
- HttpStatusCode.NotFound,
- reason = "bank gave no BIC"
- )
+ bankCode =
it.bankCodeList?.filterIsInstance<EbicsTypes.GeneralBankCode>()
+ ?.find { it.international }?.value
+ ?: throw NexusError(
+ HttpStatusCode.NotFound,
+ reason = "bank gave no BIC"
+ )
defaultBankConnection = conn
highestSeenBankMessageId = 0
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.