Using now only creator methods
This commit is contained in:
parent
8613bdb06c
commit
1a13d5620f
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue