Skip to content

Commit 0c99c9b

Browse files
authored
Implement New Share Account – Details Step (#2530)
1 parent 377bbfe commit 0c99c9b

File tree

21 files changed

+677
-179
lines changed

21 files changed

+677
-179
lines changed

core/data/src/commonMain/kotlin/com/mifos/core/data/di/RepositoryModule.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ import com.mifos.core.data.repository.SavingsAccountSummaryRepository
6161
import com.mifos.core.data.repository.SavingsAccountTransactionReceiptRepository
6262
import com.mifos.core.data.repository.SavingsAccountTransactionRepository
6363
import com.mifos.core.data.repository.SearchRepository
64+
import com.mifos.core.data.repository.ShareAccountRepository
6465
import com.mifos.core.data.repository.SignatureRepository
6566
import com.mifos.core.data.repository.SurveyListRepository
6667
import com.mifos.core.data.repository.SurveySubmitRepository
@@ -123,6 +124,7 @@ import com.mifos.core.data.repositoryImp.SavingsAccountSummaryRepositoryImp
123124
import com.mifos.core.data.repositoryImp.SavingsAccountTransactionReceiptRepositoryImpl
124125
import com.mifos.core.data.repositoryImp.SavingsAccountTransactionRepositoryImp
125126
import com.mifos.core.data.repositoryImp.SearchRepositoryImp
127+
import com.mifos.core.data.repositoryImp.ShareAccountRepositoryImpl
126128
import com.mifos.core.data.repositoryImp.SignatureRepositoryImp
127129
import com.mifos.core.data.repositoryImp.SurveyListRepositoryImp
128130
import com.mifos.core.data.repositoryImp.SurveySubmitRepositoryImp
@@ -223,6 +225,7 @@ val RepositoryModule = module {
223225
singleOf(::SignatureRepositoryImp) bind SignatureRepository::class
224226

225227
singleOf(::RecurringAccountRepositoryImp) bind RecurringAccountRepository::class
228+
singleOf(::ShareAccountRepositoryImpl) bind ShareAccountRepository::class
226229

227230
includes(platformModule)
228231
single<PlatformDependentDataModule> { getPlatformDataModule }
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright 2025 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+
*/
10+
package com.mifos.core.data.repository
11+
12+
import com.mifos.core.common.utils.DataState
13+
import com.mifos.core.network.model.share.ShareTemplate
14+
import kotlinx.coroutines.flow.Flow
15+
16+
interface ShareAccountRepository {
17+
18+
fun getShareTemplate(clientId: Int): Flow<DataState<ShareTemplate>>
19+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2025 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+
*/
10+
package com.mifos.core.data.repositoryImp
11+
12+
import com.mifos.core.common.utils.DataState
13+
import com.mifos.core.common.utils.asDataStateFlow
14+
import com.mifos.core.data.repository.ShareAccountRepository
15+
import com.mifos.core.network.datamanager.DataManagerShare
16+
import com.mifos.core.network.model.share.ShareTemplate
17+
import kotlinx.coroutines.flow.Flow
18+
19+
class ShareAccountRepositoryImpl(
20+
private val dataManagerShare: DataManagerShare,
21+
) : ShareAccountRepository {
22+
23+
override fun getShareTemplate(clientId: Int): Flow<DataState<ShareTemplate>> {
24+
return dataManagerShare.getShareTemplate(clientId).asDataStateFlow()
25+
}
26+
}

core/database/src/commonMain/kotlin/com/mifos/room/basemodel/APIEndPoint.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ object APIEndPoint {
4040
const val DISBURSE = "disburse"
4141
const val NOTES = "notes"
4242
const val MAKER_CHECKER = "makercheckers"
43+
const val SHARE = "share"
4344
}

core/network/src/commonMain/kotlin/com/mifos/core/network/BaseApiManager.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import com.mifos.core.network.services.RecurringAccountService
4141
import com.mifos.core.network.services.RunReportsService
4242
import com.mifos.core.network.services.SavingsAccountService
4343
import com.mifos.core.network.services.SearchService
44+
import com.mifos.core.network.services.ShareAccountService
4445
import com.mifos.core.network.services.StaffService
4546
import com.mifos.core.network.services.SurveyService
4647
import com.mifos.core.network.services.createCenterService
@@ -59,6 +60,7 @@ import com.mifos.core.network.services.createRecurringAccountService
5960
import com.mifos.core.network.services.createRunReportsService
6061
import com.mifos.core.network.services.createSavingsAccountService
6162
import com.mifos.core.network.services.createSearchService
63+
import com.mifos.core.network.services.createShareAccountService
6264
import com.mifos.core.network.services.createStaffService
6365
import com.mifos.core.network.services.createSurveyService
6466
import de.jensklingenberg.ktorfit.Ktorfit
@@ -87,6 +89,7 @@ class BaseApiManager(
8789
val collectionSheetService: CollectionSheetService = ktorfit.createCollectionSheetService()
8890
val noteService: NoteService = ktorfit.createNoteService()
8991
val runReportsService: RunReportsService = ktorfit.createRunReportsService()
92+
val shareAccountService: ShareAccountService = ktorfit.createShareAccountService()
9093

9194
// sdk apis
9295
val clientIdentifiersApi: ClientIdentifierApi = ktorfit.createClientIdentifierApi()
@@ -96,7 +99,6 @@ class BaseApiManager(
9699
val groupApi: GroupsApi = ktorfit.createGroupsApi()
97100
val staffApi: StaffApi = ktorfit.createStaffApi()
98101
val dataTableApi: DataTablesApi = ktorfit.createDataTablesApi()
99-
100102
companion object {
101103
fun build(prefManager: UserPreferencesRepository): BaseApiManager {
102104
val ktorfitClient = KtorfitClient.builder()
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright 2025 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+
*/
10+
package com.mifos.core.network.datamanager
11+
12+
import com.mifos.core.network.BaseApiManager
13+
import com.mifos.core.network.model.share.ShareTemplate
14+
import kotlinx.coroutines.flow.Flow
15+
16+
class DataManagerShare(
17+
private val baseApiManager: BaseApiManager,
18+
) {
19+
20+
fun getShareTemplate(clientId: Int): Flow<ShareTemplate> =
21+
baseApiManager.shareAccountService.shareProductTemplate(clientId)
22+
}

core/network/src/commonMain/kotlin/com/mifos/core/network/di/DataMangerModule.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import com.mifos.core.network.datamanager.DataManagerOffices
2727
import com.mifos.core.network.datamanager.DataManagerRunReport
2828
import com.mifos.core.network.datamanager.DataManagerSavings
2929
import com.mifos.core.network.datamanager.DataManagerSearch
30+
import com.mifos.core.network.datamanager.DataManagerShare
3031
import com.mifos.core.network.datamanager.DataManagerStaff
3132
import com.mifos.core.network.datamanager.DataManagerSurveys
3233
import org.koin.dsl.module
@@ -51,4 +52,5 @@ val DataManagerModule = module {
5152
single { DataManagerStaff(get(), get(), get()) }
5253
single { DataManagerSurveys(get(), get(), get()) }
5354
single { DataManagerIdentifiers(get()) }
55+
single { DataManagerShare(get()) }
5456
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright 2025 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+
*/
10+
package com.mifos.core.network.model.share
11+
12+
import kotlinx.serialization.SerialName
13+
import kotlinx.serialization.Serializable
14+
15+
@Serializable
16+
data class ProductOption(
17+
@SerialName("id")
18+
val id: Int,
19+
20+
@SerialName("name")
21+
val name: String,
22+
23+
@SerialName("shortName")
24+
val shortName: String,
25+
26+
@SerialName("totalShares")
27+
val totalShares: Int,
28+
)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright 2025 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+
*/
10+
package com.mifos.core.network.model.share
11+
12+
import kotlinx.serialization.SerialName
13+
import kotlinx.serialization.Serializable
14+
15+
@Serializable
16+
data class ShareTemplate(
17+
@SerialName("clientId")
18+
val clientId: Int,
19+
20+
@SerialName(value = "clientName")
21+
val clientName: String,
22+
23+
@SerialName("productOptions")
24+
val productOptions: List<ProductOption> = emptyList(),
25+
)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2025 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+
*/
10+
package com.mifos.core.network.services
11+
12+
import com.mifos.core.network.model.share.ShareTemplate
13+
import com.mifos.room.basemodel.APIEndPoint
14+
import de.jensklingenberg.ktorfit.http.GET
15+
import de.jensklingenberg.ktorfit.http.Query
16+
import kotlinx.coroutines.flow.Flow
17+
18+
interface ShareAccountService {
19+
20+
@GET("accounts/" + APIEndPoint.SHARE + "/template")
21+
fun shareProductTemplate(
22+
@Query("clientId") clientId: Int,
23+
): Flow<ShareTemplate>
24+
}

0 commit comments

Comments
 (0)