-
Notifications
You must be signed in to change notification settings - Fork 0
/
AccountsRepository.kt
33 lines (26 loc) · 1.06 KB
/
AccountsRepository.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.colvir.shared.repositories
import repositories.AbstractNetworkListRepository
import com.colvir.shared.APIs.MainApi
import com.colvir.shared.DTOs.products.account.AccountDTO
import com.colvir.shared.DTOs.products.account.AccountListDTO
import infrastructure.network.NetworkResponse
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
class AccountsRepository(
private val mainApi: MainApi
) : AbstractNetworkListRepository<AccountDTO, AccountListDTO>(tresholdIsSec = 600) {
fun accountsWithAllowedTransactionHistory(): List<AccountDTO> {
return items.filter { it.walLock?.code == "0" }
}
override suspend fun updateInternal(forcedUpdate: Boolean): NetworkResponse<AccountListDTO> {
val response = mainApi.accountList()
if (!response.isSuccessful) {
return response
}
items = (response.body?.dataSet ?: emptyList()).toMutableList()
withContext(Dispatchers.Main) {
structureChangesWatcher.fireOnStructureChanged()
}
return response
}
}