diff --git a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/FlickerCode.kt b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/FlickerCode.kt index 8fb77557..a39f0620 100644 --- a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/FlickerCode.kt +++ b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/FlickerCode.kt @@ -7,13 +7,13 @@ import net.codinux.banking.client.model.config.NoArgConstructor @NoArgConstructor open class FlickerCode( val challengeHHD_UC: String, - val parsedDataSet: String, + val parsedDataSet: String? = null, val decodingError: String? = null ) { @get:JsonIgnore val decodingSuccessful: Boolean - get() = decodingError == null + get() = parsedDataSet != null override fun toString(): String { diff --git a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/TanImage.kt b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/TanImage.kt index da739a76..b58f9c4a 100644 --- a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/TanImage.kt +++ b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/TanImage.kt @@ -6,22 +6,22 @@ import net.codinux.banking.client.model.config.NoArgConstructor @Suppress("RUNTIME_ANNOTATION_NOT_SUPPORTED") @NoArgConstructor open class TanImage( - val mimeType: String, - val imageBytesBase64: String, + val mimeType: String? = null, + val imageBytesBase64: String? = null, val decodingError: String? = null ) { @get:JsonIgnore val decodingSuccessful: Boolean - get() = decodingError == null + get() = mimeType != null && imageBytesBase64 != null override fun toString(): String { - if (decodingSuccessful == false) { - return "Decoding error: $decodingError" + mimeType?.let { + return mimeType } - return mimeType + return "Decoding error: $decodingError" } } \ No newline at end of file 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 75f3832c..51d1eec7 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 @@ -338,7 +338,11 @@ open class FinTs4kMapper { TanImage(image.mimeType, mapToBase64(image.imageBytes), mapException(image.decodingError)) @OptIn(ExperimentalEncodingApi::class) - protected open fun mapToBase64(bytes: ByteArray): String { + protected open fun mapToBase64(bytes: ByteArray?): String? { + if (bytes == null || bytes.isEmpty()) { + return null + } + return Base64.Default.encode(bytes) }