Using now only creator methods

This commit is contained in:
dankito 2024-08-18 03:45:44 +02:00
parent 8613bdb06c
commit 1a13d5620f
2 changed files with 5 additions and 7 deletions

View File

@ -3,7 +3,7 @@ package net.codinux.banking.client.model.response
import net.codinux.banking.client.model.config.NoArgConstructor
@NoArgConstructor
open class Response<T> (
open class Response<T> protected constructor(
val type: ResponseType,
val data: T? = null,
val error: Error? = null,

View File

@ -21,7 +21,7 @@ open class FinTs4kMapper {
fun map(response: net.dankito.banking.client.model.response.GetAccountDataResponse): Response<GetAccountDataResponse> {
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 <T> mapError(response: net.dankito.banking.client.model.response.GetAccountDataResponse): Response<T> {
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)
}
}