From 1a13d5620f2edc01f536b53659e3f0d2876d4647 Mon Sep 17 00:00:00 2001 From: dankito Date: Sun, 18 Aug 2024 03:45:44 +0200 Subject: [PATCH] Using now only creator methods --- .../codinux/banking/client/model/response/Response.kt | 2 +- .../codinux/banking/client/fints4k/FinTs4kMapper.kt | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/response/Response.kt b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/response/Response.kt index 7f079c15..5fb815b0 100644 --- a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/response/Response.kt +++ b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/response/Response.kt @@ -3,7 +3,7 @@ package net.codinux.banking.client.model.response import net.codinux.banking.client.model.config.NoArgConstructor @NoArgConstructor -open class Response ( +open class Response protected constructor( val type: ResponseType, val data: T? = null, val error: Error? = null, diff --git a/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kMapper.kt b/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kMapper.kt index a6f75352..bc9172b1 100644 --- a/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kMapper.kt +++ b/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kMapper.kt @@ -21,7 +21,7 @@ open class FinTs4kMapper { fun map(response: net.dankito.banking.client.model.response.GetAccountDataResponse): Response { return if (response.successful && response.customerAccount != null) { - Response(ResponseType.Success, mapCustomer(response.customerAccount!!)) + Response.success(mapCustomer(response.customerAccount!!)) } else { mapError(response) } @@ -93,14 +93,12 @@ open class FinTs4kMapper { private fun mapError(response: net.dankito.banking.client.model.response.GetAccountDataResponse): Response { - val error = if (response.error != null) { - Error(ErrorType.valueOf(response.error!!.name), if (response.error == ErrorCode.BankReturnedError) null else response.errorMessage, + return if (response.error != null) { + Response.error(ErrorType.valueOf(response.error!!.name), if (response.error == ErrorCode.BankReturnedError) null else response.errorMessage, if (response.error == ErrorCode.BankReturnedError && response.errorMessage !== null) listOf(response.errorMessage!!) else emptyList()) } else { - Error(ErrorType.UnknownError, response.errorMessage) + Response.error(ErrorType.UnknownError, response.errorMessage) } - - return Response(ResponseType.Error, null, error) } } \ No newline at end of file