Skip to content

Commit 061067b

Browse files
Implemented fineract sdk
1 parent 01c8e45 commit 061067b

File tree

75 files changed

+704
-926
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+704
-926
lines changed

core/data/src/main/java/com/mifos/core/data/paging_source/CenterListPagingSource.kt

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -41,33 +41,10 @@ class CenterListPagingSource(private val dataManagerCenter: DataManagerCenter) :
4141
}
4242
}
4343

44-
private suspend fun getCenterList(position: Int): Pair<List<Center>, Int> =
45-
suspendCoroutine { continuation ->
46-
try {
47-
dataManagerCenter.getCenters(true, position, 10)
48-
.observeOn(AndroidSchedulers.mainThread())
49-
.subscribeOn(Schedulers.io())
50-
.subscribe(object : Subscriber<Page<Center>>() {
51-
override fun onCompleted() {
52-
}
53-
54-
override fun onError(exception: Throwable) {
55-
continuation.resumeWithException(exception)
56-
}
57-
58-
override fun onNext(center: Page<Center>) {
59-
continuation.resume(
60-
Pair(
61-
center.pageItems,
62-
center.totalFilteredRecords
63-
)
64-
)
65-
}
66-
})
67-
} catch (exception: Exception) {
68-
continuation.resumeWithException(exception)
69-
}
70-
}
44+
private suspend fun getCenterList(position: Int): Pair<List<Center>, Int> {
45+
val pagedClient = dataManagerCenter.getCenters(true, position, 10)
46+
return Pair(pagedClient.pageItems, pagedClient.totalFilteredRecords)
47+
}
7148

7249
private suspend fun getCenterDbList(): List<Center> = suspendCoroutine { continuation ->
7350
try {

core/data/src/main/java/com/mifos/core/data/paging_source/ClientListPagingSource.kt

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import androidx.paging.PagingState
55
import com.mifos.core.network.datamanager.DataManagerClient
66
import com.mifos.core.objects.client.Client
77
import com.mifos.core.objects.client.Page
8-
import kotlinx.coroutines.suspendCancellableCoroutine
98
import rx.Subscriber
109
import rx.android.schedulers.AndroidSchedulers
1110
import rx.schedulers.Schedulers
@@ -48,24 +47,8 @@ class ClientListPagingSource(
4847
}
4948

5049
private suspend fun getClientList(position: Int): Pair<List<Client>, Int> {
51-
return suspendCancellableCoroutine { continuation ->
52-
dataManagerClient.getAllClients(offset = position, 10)
53-
.observeOn(AndroidSchedulers.mainThread())
54-
.subscribeOn(Schedulers.io())
55-
.subscribe(object : Subscriber<Page<Client>>() {
56-
override fun onCompleted() {
57-
58-
}
59-
60-
override fun onError(e: Throwable) {
61-
continuation.resumeWithException(e)
62-
}
63-
64-
override fun onNext(t: Page<Client>) {
65-
continuation.resume(Pair(t.pageItems, t.totalFilteredRecords))
66-
}
67-
})
68-
}
50+
val response = dataManagerClient.getAllClients(position, 10)
51+
return Pair(response.pageItems, response.totalFilteredRecords)
6952
}
7053

7154
private suspend fun getClientDbList(): List<Client> {

core/data/src/main/java/com/mifos/core/data/repository/ActivateRepository.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package com.mifos.core.data.repository
22

33
import com.mifos.core.network.GenericResponse
44
import com.mifos.core.objects.client.ActivatePayload
5-
import org.apache.fineract.client.models.PostCentersCenterIdResponse
6-
import org.apache.fineract.client.models.PostClientsClientIdResponse
5+
import org.openapitools.client.models.PostCentersCenterIdResponse
6+
import org.openapitools.client.models.PostClientsClientIdResponse
77
import rx.Observable
88

99
/**
@@ -12,15 +12,15 @@ import rx.Observable
1212

1313
interface ActivateRepository {
1414

15-
fun activateClient(
15+
suspend fun activateClient(
1616
clientId: Int,
1717
clientActivate: ActivatePayload?
18-
): Observable<PostClientsClientIdResponse>
18+
): PostClientsClientIdResponse
1919

20-
fun activateCenter(
20+
suspend fun activateCenter(
2121
centerId: Int,
2222
activatePayload: ActivatePayload?
23-
): Observable<PostCentersCenterIdResponse>
23+
): PostCentersCenterIdResponse
2424

2525
fun activateGroup(
2626
groupId: Int,

core/data/src/main/java/com/mifos/core/data/repository/ClientDetailsRepository.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ interface ClientDetailsRepository {
1515

1616
fun deleteClientImage(clientId: Int): Observable<ResponseBody>
1717

18-
fun getClientAccounts(clientId: Int): Observable<ClientAccounts>
18+
suspend fun getClientAccounts(clientId: Int): ClientAccounts
1919

20-
fun getClient(clientId: Int): Observable<Client>
20+
suspend fun getClient(clientId: Int): Client
2121

2222
}

core/data/src/main/java/com/mifos/core/data/repository/ClientIdentifierDialogRepository.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ package com.mifos.core.data.repository
33
import com.mifos.core.objects.noncore.IdentifierCreationResponse
44
import com.mifos.core.objects.noncore.IdentifierPayload
55
import com.mifos.core.objects.noncore.IdentifierTemplate
6-
import rx.Observable
76

87
/**
98
* Created by Aditya Gupta on 16/08/23.
109
*/
1110
interface ClientIdentifierDialogRepository {
1211

13-
fun getClientIdentifierTemplate(clientId: Int): Observable<IdentifierTemplate>
12+
suspend fun getClientIdentifierTemplate(clientId: Int): IdentifierTemplate
1413

1514
suspend fun createClientIdentifier(
1615
clientId: Int, identifierPayload: IdentifierPayload
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
package com.mifos.core.data.repository
22

33
import com.mifos.core.objects.noncore.Identifier
4-
import org.apache.fineract.client.models.DeleteClientsClientIdIdentifiersIdentifierIdResponse
5-
import rx.Observable
4+
import org.openapitools.client.models.DeleteClientsClientIdIdentifiersIdentifierIdResponse
65

76
/**
87
* Created by Aditya Gupta on 08/08/23.
98
*/
109
interface ClientIdentifiersRepository {
1110

12-
fun getClientIdentifiers(clientId: Int): Observable<List<Identifier>>
11+
suspend fun getClientIdentifiers(clientId: Int): List<Identifier>
1312

14-
fun deleteClientIdentifier(
13+
suspend fun deleteClientIdentifier(
1514
clientId: Int,
1615
identifierId: Int
17-
): Observable<DeleteClientsClientIdIdentifiersIdentifierIdResponse>
16+
): DeleteClientsClientIdIdentifiersIdentifierIdResponse
1817
}

core/data/src/main/java/com/mifos/core/data/repository/CreateNewClientRepository.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ interface CreateNewClientRepository {
1616

1717
fun clientTemplate(): Observable<ClientsTemplate>
1818

19-
fun offices(): Observable<List<Office>>
19+
suspend fun offices(): List<Office>
2020

21-
fun getStaffInOffice(officeId: Int): Observable<List<Staff>>
21+
suspend fun getStaffInOffice(officeId: Int): List<Staff>
2222

2323
fun createClient(clientPayload: ClientPayload): Observable<Client>
2424

core/data/src/main/java/com/mifos/core/data/repository/CreateNewGroupRepository.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.mifos.core.data.repository
22

3-
import com.mifos.core.datastore.PrefManager
43
import com.mifos.core.objects.group.GroupPayload
54
import com.mifos.core.objects.organisation.Office
65
import com.mifos.core.objects.response.SaveResponse
@@ -11,7 +10,7 @@ import rx.Observable
1110
*/
1211
interface CreateNewGroupRepository {
1312

14-
fun offices(): Observable<List<Office>>
13+
suspend fun offices(): List<Office>
1514

1615
fun createGroup(groupPayload: GroupPayload): Observable<SaveResponse>
1716
}
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package com.mifos.core.data.repository
22

33
import com.google.gson.JsonArray
4-
import org.apache.fineract.client.models.DeleteDataTablesDatatableAppTableIdDatatableIdResponse
5-
import rx.Observable
4+
import org.openapitools.client.models.DeleteDataTablesDatatableAppTableIdDatatableIdResponse
65

76
/**
87
* Created by Aditya Gupta on 10/08/23.
@@ -11,10 +10,10 @@ interface DataTableDataRepository {
1110

1211
suspend fun getDataTableInfo(table: String, entityId: Int): JsonArray
1312

14-
fun deleteDataTableEntry(
15-
table: String?,
13+
suspend fun deleteDataTableEntry(
14+
table: String,
1615
entity: Int,
1716
rowId: Int
18-
): Observable<DeleteDataTablesDatatableAppTableIdDatatableIdResponse>
17+
): DeleteDataTablesDatatableAppTableIdDatatableIdResponse
1918

2019
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
package com.mifos.core.data.repository
22

33
import com.mifos.core.objects.noncore.DataTable
4-
import rx.Observable
54

65
/**
76
* Created by Aditya Gupta on 08/08/23.
87
*/
98
interface DataTableRepository {
109

11-
fun getDataTable(tableName: String?): Observable<List<DataTable>>
10+
suspend fun getDataTable(tableName: String?): List<DataTable>
1211

1312
}

0 commit comments

Comments
 (0)