libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit 4b42c655325ab5c69e776d7aec7cb6b2e42c79c9
parent ce6538949e057eb9b6ba7ebff403f1f6becf21d0
Author: Marcello Stanisci <ms@taler.net>
Date:   Sat,  9 May 2020 12:26:59 +0200

Organize JSON types.

Diffstat:
Mnexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt | 142++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
Mnexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 6+++++-
Mnexus/src/main/kotlin/tech/libeufin/nexus/taler.kt | 10++++++----
3 files changed, 90 insertions(+), 68 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/JSON.kt @@ -72,46 +72,6 @@ data class EbicsErrorJson( val error: EbicsErrorDetailJson ) -data class BankAccount( - var holder: String, - var iban: String, - var bic: String, - var account: String -) - -data class BankAccounts( - var accounts: MutableList<BankAccount> = mutableListOf() -) - -/** THE NEXUS USER */ - -/** SHOWS details about one user */ -data class NexusUser( - val userID: String, - val transports: MutableList<Any> = mutableListOf() -) - -/** is "UserResponse" in the API spec */ -data class UserResponse( - val username: String, - val superuser: Boolean -) - -/** Instructs the nexus to CREATE a new user */ -data class User( - val username: String, - val password: String -) - -/** Collection of all the nexus users existing in the system */ -data class Users( - val users: MutableList<NexusUser> = mutableListOf() -) - -/************************************/ - -/** TRANSPORT TYPES */ - /** Instructs the nexus to CREATE a new Ebics subscriber. * Note that the nexus user to which the subscriber must be * associated is extracted from other HTTP details. @@ -127,16 +87,39 @@ data class EbicsSubscriber( val systemID: String? = null ) -/** Type representing the "test" transport. Test transport - * does not cooperate with the bank/sandbox in order to obtain - * data about one user. All the data is just mocked internally - * at the NEXUS. - */ -class TestSubscriber() +data class RawPayments( + var payments: MutableList<RawPayment> = mutableListOf() +) + +/************************************************* + * API types (used as requests/responses types) * + *************************************************/ + +/** Response type of "GET /collected-transactions" */ +data class Transaction( + val account: String, + val counterpartIban: String, + val counterpartBic: String, + val counterpartName: String, + val amount: String, + val subject: String, + val date: String +) +/** Request type of "POST /prepared-payments/submit" */ +data class SubmitPayment( + val uuid: String, + val transport: String? +) -/** PAYMENT INSTRUCTIONS TYPES */ +/** Request type of "POST /collected-transactions" */ +data class CollectedTransaction( + val transport: String?, + val start: String?, + val end: String? +) +/** Request type of "POST /prepared-payments" */ data class PreparedPaymentRequest( val iban: String, val bic: String, @@ -145,34 +128,68 @@ data class PreparedPaymentRequest( val subject: String ) +/** Response type of "POST /prepared-payments" */ data class PreparedPaymentResponse( val uuid: String ) -/** This structure is used to INSTRUCT the nexus to prepare such payment. */ +/** Response type of "GET /user" */ +data class UserResponse( + val username: String, + val superuser: Boolean +) + +/** Request type of "POST /users" */ +data class User( + val username: String, + val password: String +) + +/** Response (list's element) type of "GET /bank-accounts" */ +data class BankAccount( + var holder: String, + var iban: String, + var bic: String, + var account: String +) + +/** Response type of "GET /bank-accounts" */ +data class BankAccounts( + var accounts: MutableList<BankAccount> = mutableListOf() +) + + +/********************************************************************** + * Convenience types (ONLY used to gather data together in one place) * + **********************************************************************/ + data class Pain001Data( val creditorIban: String, val creditorBic: String, val creditorName: String, val debitorIban: String, val debitorBic: String, - val debitorName: String?, + val debitorName: String, val sum: Amount, - val currency: String = "EUR", + val currency: String, val subject: String ) -data class RawPayments( - var payments: MutableList<RawPayment> = mutableListOf() -) -data class SubmitPayment( - val uuid: String, - val transport: String? -) -data class CollectedTransaction( - val transport: String?, - val start: String?, - val end: String? -) -\ No newline at end of file + + + + + + + + + + + + + + + + diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt @@ -339,9 +339,13 @@ fun main() { return@post } /** - * Queries list of transactions ALREADY downloaded from the bank. + * Asks list of transactions ALREADY downloaded from the bank. */ get("/bank-accounts/{accountid}/collected-transactions") { + val userId = authenticateRequest(call.request.headers["Authorization"]) + val start = call.request.queryParameters["start"] + val end = call.request.queryParameters["end"] + return@get } /** diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/taler.kt @@ -249,7 +249,8 @@ class Taler(app: Route) { creditorBic = creditorData.bic, creditorName = creditorData.name, subject = transferRequest.wtid, - sum = parseAmount(transferRequest.amount).amount, + sum = amountObj.amount, + currency = amountObj.currency, debitorName = exchangeBankAccount.accountHolder, debitorBic = exchangeBankAccount.bankCode, debitorIban = exchangeBankAccount.iban @@ -262,7 +263,7 @@ class Taler(app: Route) { unstructuredRemittanceInformation = transferRequest.wtid transactionType = "DBIT" currency = amountObj.currency - amount = amountObj.amount.toPlainString() + this.amount = amountObj.amount.toPlainString() debitorName = "Exchange Company" debitorIban = exchangeBankAccount.iban creditorName = creditorObj.name @@ -319,7 +320,7 @@ class Taler(app: Route) { currency = amount.currency this.amount = amount.amount.toPlainString() creditorIban = exchangeBankAccount.iban - creditorName = exchangeBankAccount.accountHolder ?: "Exchange default name for tests" + creditorName = exchangeBankAccount.accountHolder debitorIban = debtor.iban debitorName = debtor.name counterpartBic = debtor.bic @@ -376,7 +377,8 @@ class Taler(app: Route) { subject = "Taler refund", debitorIban = requesterBankAccount.iban, debitorBic = requesterBankAccount.bankCode, - debitorName = requesterBankAccount.accountHolder + debitorName = requesterBankAccount.accountHolder, + currency = it.payment.currency ), nexusUser )