Skip to content

Commit c9854d2

Browse files
Merge pull request #2260 from Aditya-gupta99/new_sdk
feat: Implemented fineract client sdk
2 parents 72142da + c535672 commit c9854d2

File tree

78 files changed

+971
-1458
lines changed

Some content is hidden

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

78 files changed

+971
-1458
lines changed

build-logic/convention/src/main/kotlin/org/mifos/Badging.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import org.gradle.api.tasks.OutputFile
1919
import org.gradle.api.tasks.PathSensitive
2020
import org.gradle.api.tasks.PathSensitivity
2121
import org.gradle.api.tasks.TaskAction
22-
import org.gradle.internal.extensions.stdlib.capitalized
22+
import org.gradle.configurationcache.extensions.capitalized
2323
import org.gradle.kotlin.dsl.register
2424
import org.gradle.language.base.plugins.LifecycleBasePlugin
2525
import org.gradle.process.ExecOperations

core/data/src/main/java/com/mifos/core/data/di/DataModule.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,15 @@ import com.mifos.core.data.repository.SearchRepository
4949
import com.mifos.core.data.repository.SignatureRepository
5050
import com.mifos.core.data.repository.SurveyListRepository
5151
import com.mifos.core.data.repository.SurveySubmitRepository
52-
import com.mifos.core.data.repositoryImp.ActivateRepositoryImp
5352
import com.mifos.core.data.repositoryImp.CenterDetailsRepositoryImp
5453
import com.mifos.core.data.repositoryImp.CenterListRepositoryImp
5554
import com.mifos.core.data.repositoryImp.ChargeDialogRepositoryImp
5655
import com.mifos.core.data.repositoryImp.CheckerInboxRepositoryImp
5756
import com.mifos.core.data.repositoryImp.CheckerInboxTasksRepositoryImp
5857
import com.mifos.core.data.repositoryImp.ClientChargeRepositoryImp
5958
import com.mifos.core.data.repositoryImp.ClientIdentifierDialogRepositoryImp
60-
import com.mifos.core.data.repositoryImp.ClientIdentifiersRepositoryImp
6159
import com.mifos.core.data.repositoryImp.CreateNewCenterRepositoryImp
6260
import com.mifos.core.data.repositoryImp.CreateNewGroupRepositoryImp
63-
import com.mifos.core.data.repositoryImp.DataTableDataRepositoryImp
6461
import com.mifos.core.data.repositoryImp.DataTableListRepositoryImp
6562
import com.mifos.core.data.repositoryImp.DataTableRepositoryImp
6663
import com.mifos.core.data.repositoryImp.DataTableRowDialogRepositoryImp
@@ -89,6 +86,9 @@ import com.mifos.core.data.repositoryImp.SearchRepositoryImp
8986
import com.mifos.core.data.repositoryImp.SignatureRepositoryImp
9087
import com.mifos.core.data.repositoryImp.SurveyListRepositoryImp
9188
import com.mifos.core.data.repositoryImp.SurveySubmitRepositoryImp
89+
import com.mifos.core.data.repository_imp.ActivateRepositoryImp
90+
import com.mifos.core.data.repository_imp.ClientIdentifiersRepositoryImp
91+
import com.mifos.core.data.repository_imp.DataTableDataRepositoryImp
9292
import dagger.Binds
9393
import dagger.Module
9494
import dagger.hilt.InstallIn
Lines changed: 10 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
/*
2-
* Copyright 2024 Mifos Initiative
3-
*
4-
* This Source Code Form is subject to the terms of the Mozilla Public
5-
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7-
*
8-
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
9-
*/
101
package com.mifos.core.data.pagingSource
112

123
import androidx.paging.PagingSource
@@ -27,7 +18,7 @@ class CenterListPagingSource(private val dataManagerCenter: DataManagerCenter) :
2718
override fun getRefreshKey(state: PagingState<Int, Center>): Int? {
2819
return state.anchorPosition?.let { position ->
2920
state.closestPageToPosition(position)?.prevKey?.plus(10) ?: state.closestPageToPosition(
30-
position,
21+
position
3122
)?.nextKey?.minus(10)
3223
}
3324
}
@@ -43,43 +34,21 @@ class CenterListPagingSource(private val dataManagerCenter: DataManagerCenter) :
4334
LoadResult.Page(
4435
data = centerListWithSync,
4536
prevKey = if (position <= 0) null else position - 10,
46-
nextKey = if (position >= totalCenters) null else position + 10,
37+
nextKey = if (position >= totalCenters) null else position + 10
4738
)
4839
} catch (e: Exception) {
4940
LoadResult.Error(e)
5041
}
5142
}
5243

53-
private suspend fun getCenterList(position: Int): Pair<List<Center>, Int> =
54-
suspendCoroutine { continuation ->
55-
try {
56-
dataManagerCenter.getCenters(true, position, 10)
57-
.observeOn(AndroidSchedulers.mainThread())
58-
.subscribeOn(Schedulers.io())
59-
.subscribe(object : Subscriber<Page<Center>>() {
60-
override fun onCompleted() {
61-
}
62-
63-
override fun onError(exception: Throwable) {
64-
continuation.resumeWithException(exception)
65-
}
66-
67-
override fun onNext(center: Page<Center>) {
68-
continuation.resume(
69-
Pair(
70-
center.pageItems,
71-
center.totalFilteredRecords,
72-
),
73-
)
74-
}
75-
})
76-
} catch (exception: Exception) {
77-
continuation.resumeWithException(exception)
78-
}
79-
}
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+
}
8048

8149
private suspend fun getCenterDbList(): List<Center> = suspendCoroutine { continuation ->
8250
try {
51+
8352
dataManagerCenter.allDatabaseCenters
8453
.observeOn(AndroidSchedulers.mainThread())
8554
.subscribeOn(Schedulers.io())
@@ -100,9 +69,10 @@ class CenterListPagingSource(private val dataManagerCenter: DataManagerCenter) :
10069
}
10170
}
10271

72+
10373
private fun getCenterListWithSync(
10474
centerList: List<Center>,
105-
centerDbList: List<Center>,
75+
centerDbList: List<Center>
10676
): List<Center> {
10777
if (centerDbList.isNotEmpty()) {
10878
centerList.forEach { center ->
@@ -115,4 +85,4 @@ class CenterListPagingSource(private val dataManagerCenter: DataManagerCenter) :
11585
}
11686
return centerList
11787
}
118-
}
88+
}

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

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
1-
/*
2-
* Copyright 2024 Mifos Initiative
3-
*
4-
* This Source Code Form is subject to the terms of the Mozilla Public
5-
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7-
*
8-
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
9-
*/
101
package com.mifos.core.data.pagingSource
112

123
import androidx.paging.PagingSource
134
import androidx.paging.PagingState
145
import com.mifos.core.network.datamanager.DataManagerClient
156
import com.mifos.core.objects.client.Client
167
import com.mifos.core.objects.client.Page
17-
import kotlinx.coroutines.suspendCancellableCoroutine
188
import rx.Subscriber
199
import rx.android.schedulers.AndroidSchedulers
2010
import rx.schedulers.Schedulers
@@ -27,13 +17,13 @@ import kotlin.coroutines.suspendCoroutine
2717
*/
2818

2919
class ClientListPagingSource(
30-
private val dataManagerClient: DataManagerClient,
20+
private val dataManagerClient: DataManagerClient
3121
) : PagingSource<Int, Client>() {
3222

3323
override fun getRefreshKey(state: PagingState<Int, Client>): Int? {
3424
return state.anchorPosition?.let { position ->
3525
state.closestPageToPosition(position)?.prevKey?.plus(10) ?: state.closestPageToPosition(
36-
position,
26+
position
3727
)?.nextKey?.minus(10)
3828
}
3929
}
@@ -49,31 +39,16 @@ class ClientListPagingSource(
4939
LoadResult.Page(
5040
data = clientListWithSync,
5141
prevKey = if (position <= 0) null else position - 10,
52-
nextKey = if (position >= totalClients) null else position + 10,
42+
nextKey = if (position >= totalClients) null else position + 10
5343
)
5444
} catch (e: Exception) {
5545
LoadResult.Error(e)
5646
}
5747
}
5848

5949
private suspend fun getClientList(position: Int): Pair<List<Client>, Int> {
60-
return suspendCancellableCoroutine { continuation ->
61-
dataManagerClient.getAllClients(offset = position, 10)
62-
.observeOn(AndroidSchedulers.mainThread())
63-
.subscribeOn(Schedulers.io())
64-
.subscribe(object : Subscriber<Page<Client>>() {
65-
override fun onCompleted() {
66-
}
67-
68-
override fun onError(e: Throwable) {
69-
continuation.resumeWithException(e)
70-
}
71-
72-
override fun onNext(t: Page<Client>) {
73-
continuation.resume(Pair(t.pageItems, t.totalFilteredRecords))
74-
}
75-
})
76-
}
50+
val response = dataManagerClient.getAllClients(position, 10)
51+
return Pair(response.pageItems, response.totalFilteredRecords)
7752
}
7853

7954
private suspend fun getClientDbList(): List<Client> {
@@ -98,7 +73,7 @@ class ClientListPagingSource(
9873

9974
private fun getClientListWithSync(
10075
clientList: List<Client>,
101-
clientDbList: List<Client>,
76+
clientDbList: List<Client>
10277
): List<Client> {
10378
if (clientDbList.isNotEmpty()) {
10479
clientList.forEach { client ->
@@ -111,4 +86,4 @@ class ClientListPagingSource(
11186
}
11287
return clientList
11388
}
114-
}
89+
}
Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
1-
/*
2-
* Copyright 2024 Mifos Initiative
3-
*
4-
* This Source Code Form is subject to the terms of the Mozilla Public
5-
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7-
*
8-
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
9-
*/
101
package com.mifos.core.data.repository
112

123
import com.mifos.core.network.GenericResponse
134
import com.mifos.core.objects.client.ActivatePayload
14-
import org.apache.fineract.client.models.PostCentersCenterIdResponse
15-
import org.apache.fineract.client.models.PostClientsClientIdResponse
5+
import org.openapitools.client.models.PostCentersCenterIdResponse
6+
import org.openapitools.client.models.PostClientsClientIdResponse
167
import rx.Observable
178

189
/**
@@ -21,18 +12,19 @@ import rx.Observable
2112

2213
interface ActivateRepository {
2314

24-
fun activateClient(
15+
suspend fun activateClient(
2516
clientId: Int,
26-
clientActivate: ActivatePayload?,
27-
): Observable<PostClientsClientIdResponse>
17+
clientActivate: ActivatePayload?
18+
): PostClientsClientIdResponse
2819

29-
fun activateCenter(
20+
suspend fun activateCenter(
3021
centerId: Int,
31-
activatePayload: ActivatePayload?,
32-
): Observable<PostCentersCenterIdResponse>
22+
activatePayload: ActivatePayload?
23+
): PostCentersCenterIdResponse
3324

3425
fun activateGroup(
3526
groupId: Int,
36-
activatePayload: ActivatePayload?,
27+
activatePayload: ActivatePayload?
3728
): Observable<GenericResponse>
38-
}
29+
30+
}
Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
/*
2-
* Copyright 2024 Mifos Initiative
3-
*
4-
* This Source Code Form is subject to the terms of the Mozilla Public
5-
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7-
*
8-
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
9-
*/
101
package com.mifos.core.data.repository
112

123
import com.mifos.core.objects.accounts.ClientAccounts
@@ -24,7 +15,8 @@ interface ClientDetailsRepository {
2415

2516
fun deleteClientImage(clientId: Int): Observable<ResponseBody>
2617

27-
fun getClientAccounts(clientId: Int): Observable<ClientAccounts>
18+
suspend fun getClientAccounts(clientId: Int): ClientAccounts
19+
20+
suspend fun getClient(clientId: Int): Client
2821

29-
fun getClient(clientId: Int): Observable<Client>
30-
}
22+
}

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
@@ -12,14 +12,13 @@ package com.mifos.core.data.repository
1212
import com.mifos.core.objects.noncore.IdentifierCreationResponse
1313
import com.mifos.core.objects.noncore.IdentifierPayload
1414
import com.mifos.core.objects.noncore.IdentifierTemplate
15-
import rx.Observable
1615

1716
/**
1817
* Created by Aditya Gupta on 16/08/23.
1918
*/
2019
interface ClientIdentifierDialogRepository {
2120

22-
fun getClientIdentifierTemplate(clientId: Int): Observable<IdentifierTemplate>
21+
suspend fun getClientIdentifierTemplate(clientId: Int): IdentifierTemplate
2322

2423
suspend fun createClientIdentifier(
2524
clientId: Int,
Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,17 @@
1-
/*
2-
* Copyright 2024 Mifos Initiative
3-
*
4-
* This Source Code Form is subject to the terms of the Mozilla Public
5-
* License, v. 2.0. If a copy of the MPL was not distributed with this
6-
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7-
*
8-
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
9-
*/
101
package com.mifos.core.data.repository
112

123
import com.mifos.core.objects.noncore.Identifier
13-
import org.apache.fineract.client.models.DeleteClientsClientIdIdentifiersIdentifierIdResponse
14-
import rx.Observable
4+
import org.openapitools.client.models.DeleteClientsClientIdIdentifiersIdentifierIdResponse
155

166
/**
177
* Created by Aditya Gupta on 08/08/23.
188
*/
199
interface ClientIdentifiersRepository {
2010

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

23-
fun deleteClientIdentifier(
13+
suspend fun deleteClientIdentifier(
2414
clientId: Int,
25-
identifierId: Int,
26-
): Observable<DeleteClientsClientIdIdentifiersIdentifierIdResponse>
27-
}
15+
identifierId: Int
16+
): DeleteClientsClientIdIdentifiersIdentifierIdResponse
17+
}

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
@@ -25,9 +25,9 @@ interface CreateNewClientRepository {
2525

2626
fun clientTemplate(): Observable<ClientsTemplate>
2727

28-
fun offices(): Observable<List<Office>>
28+
suspend fun offices(): List<Office>
2929

30-
fun getStaffInOffice(officeId: Int): Observable<List<Staff>>
30+
suspend fun getStaffInOffice(officeId: Int): List<Staff>
3131

3232
fun createClient(clientPayload: ClientPayload): Observable<Client>
3333

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import rx.Observable
1919
*/
2020
interface CreateNewGroupRepository {
2121

22-
fun offices(): Observable<List<Office>>
22+
suspend fun offices(): List<Office>
2323

2424
fun createGroup(groupPayload: GroupPayload): Observable<SaveResponse>
2525
}

0 commit comments

Comments
 (0)