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
|
import net.codinux.banking.client.model.config.NoArgConstructor
|
||||||
|
|
||||||
@NoArgConstructor
|
@NoArgConstructor
|
||||||
open class Response<T> (
|
open class Response<T> protected constructor(
|
||||||
val type: ResponseType,
|
val type: ResponseType,
|
||||||
val data: T? = null,
|
val data: T? = null,
|
||||||
val error: Error? = null,
|
val error: Error? = null,
|
||||||
|
|
|
@ -21,7 +21,7 @@ open class FinTs4kMapper {
|
||||||
|
|
||||||
fun map(response: net.dankito.banking.client.model.response.GetAccountDataResponse): Response<GetAccountDataResponse> {
|
fun map(response: net.dankito.banking.client.model.response.GetAccountDataResponse): Response<GetAccountDataResponse> {
|
||||||
return if (response.successful && response.customerAccount != null) {
|
return if (response.successful && response.customerAccount != null) {
|
||||||
Response(ResponseType.Success, mapCustomer(response.customerAccount!!))
|
Response.success(mapCustomer(response.customerAccount!!))
|
||||||
} else {
|
} else {
|
||||||
mapError(response)
|
mapError(response)
|
||||||
}
|
}
|
||||||
|
@ -93,14 +93,12 @@ open class FinTs4kMapper {
|
||||||
|
|
||||||
|
|
||||||
private fun <T> mapError(response: net.dankito.banking.client.model.response.GetAccountDataResponse): Response<T> {
|
private fun <T> mapError(response: net.dankito.banking.client.model.response.GetAccountDataResponse): Response<T> {
|
||||||
val error = if (response.error != null) {
|
return if (response.error != null) {
|
||||||
Error(ErrorType.valueOf(response.error!!.name), if (response.error == ErrorCode.BankReturnedError) null else response.errorMessage,
|
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())
|
if (response.error == ErrorCode.BankReturnedError && response.errorMessage !== null) listOf(response.errorMessage!!) else emptyList())
|
||||||
} else {
|
} else {
|
||||||
Error(ErrorType.UnknownError, response.errorMessage)
|
Response.error(ErrorType.UnknownError, response.errorMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response(ResponseType.Error, null, error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue