Started rudimentary version of FinTsClient

This commit is contained in:
dankl 2019-10-03 23:39:53 +02:00 committed by dankito
parent f1e6ed1350
commit 41e8dfae41
4 changed files with 66 additions and 0 deletions

View File

@ -0,0 +1,42 @@
package net.dankito.fints
import net.dankito.fints.messages.nachrichten.implementierte.DialoginitialisierungAnonym
import net.dankito.fints.model.BankInfo
import net.dankito.fints.model.ProductInfo
import net.dankito.fints.util.IBase64Service
import net.dankito.utils.web.client.IWebClient
import net.dankito.utils.web.client.OkHttpWebClient
import net.dankito.utils.web.client.RequestParameters
open class FinTsClient(
protected val base64Service: IBase64Service,
protected val webClient: IWebClient = OkHttpWebClient()
) {
fun getBankInfo(bankInfo: BankInfo, productInfo: ProductInfo) {
val dialogInit = DialoginitialisierungAnonym(bankInfo.countryCode, bankInfo.bankCode,
productInfo.productName, productInfo.productVersion)
val requestBody = dialogInit.format()
val encodedRequestBody = base64Service.encode(requestBody)
val response = webClient.post(RequestParameters(bankInfo.finTsServerAddress, encodedRequestBody, "application/octet-stream"))
val responseBody = response.body
if (response.isSuccessful && responseBody != null) {
val decodedResponse = decodeBase64Response(responseBody)
if (decodedResponse != null) {
}
}
}
protected open fun decodeBase64Response(responseBody: String): String {
return base64Service.decode(responseBody.replace("\r", "").replace("\n", ""))
}
}

View File

@ -0,0 +1,9 @@
package net.dankito.fints.model
open class AccountCredentials @JvmOverloads constructor(
val bankCode: String,
val customerId: String,
val pin: String,
val userId: String = customerId
)

View File

@ -0,0 +1,8 @@
package net.dankito.fints.model
open class BankInfo(
val bankCode: String,
val countryCode: Int,
val finTsServerAddress: String
)

View File

@ -0,0 +1,7 @@
package net.dankito.fints.model
open class ProductInfo(
val productName: String,
val productVersion: String
)