I have one call that return different objects name, in this case, each name is the hash of your wallet address, but I would like to treat them indifferently because all that matters is the data that is inside them, using a standard converter like Gson I am not able to do this, is there any way to do it manually?
{
"0x1234": {
"success": true,
"cache_last_updated": 1642815869695,
"total": 500
},
"0x1244445": {
"success": true,
"cache_last_updated": 1642815869695,
"total": 324
},
"0x47851":{
"success": true,
"cache_last_updated": 1642815869695,
"total": 324
}
}
My Repository:
class WalletsResumeRepository(
private val service: apiService
) {
suspend fun getAddressData(listAddress: List<String>): Flow<Result<List<DetailModel>>> =
flow {
emit(Result.success(service.getWalletResume(listAddress))
}.catch { e ->
emit(Result.failure(RuntimeException("Something went wrong ${e.cause}")))
}
}
my repository always falls into the catch scenario with an NPE, remembering that the response can have countless addresses so infinite object names, how can I treat them as generics and map only the responses as lists? or something like that?
Service.kt
suspend fun getWalletResume(@Path("address") wallet: String): WalletDetailDTO
WalletDTO
data class WalletDetailDTO(
val success: Boolean,
@SerializedName("cache_last_updated")
val cacheLastUpdated: Long?,
val totalSlp: Int?
)