Skip to content

Commit 0381059

Browse files
committed
Ktorfit Cleanup: Remove Duplicates and Align DI Configuration (openMF#2446)
1 parent 7186de5 commit 0381059

33 files changed

Lines changed: 262 additions & 445 deletions

core/designsystem/src/commonMain/kotlin/com/mifos/core/designsystem/component/MifosTextFieldDropdown.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import androidx.compose.ui.unit.dp
3434
@OptIn(ExperimentalMaterial3Api::class)
3535
@Composable
3636
fun MifosTextFieldDropdown(
37+
enabled: Boolean = true,
3738
value: String,
3839
onValueChanged: (String) -> Unit,
3940
onOptionSelected: (Int, String) -> Unit,
@@ -52,6 +53,7 @@ fun MifosTextFieldDropdown(
5253
onExpandedChange = { isExpanded = !isExpanded },
5354
) {
5455
OutlinedTextField(
56+
enabled = enabled,
5557
isError = errorMessage != null,
5658
supportingText = if (errorMessage != null) {
5759
{

core/model/src/commonMain/kotlin/com/mifos/core/model/objects/account/loan/SavingsApproval.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ package com.mifos.core.model.objects.account.loan
1111

1212
import com.mifos.core.model.utils.Parcelable
1313
import com.mifos.core.model.utils.Parcelize
14+
import kotlinx.serialization.Serializable
1415

1516
@Parcelize
17+
@Serializable
1618
data class SavingsApproval(
1719
var locale: String = "en",
1820

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

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@ package com.mifos.core.network
1111

1212
import com.mifos.core.common.utils.getInstanceUrl
1313
import com.mifos.core.datastore.UserPreferencesRepository
14+
import com.mifos.core.network.apis.CentersApi
15+
import com.mifos.core.network.apis.ClientApi
16+
import com.mifos.core.network.apis.ClientIdentifierApi
17+
import com.mifos.core.network.apis.DataTablesApi
18+
import com.mifos.core.network.apis.GroupsApi
19+
import com.mifos.core.network.apis.OfficesApi
20+
import com.mifos.core.network.apis.StaffApi
21+
import com.mifos.core.network.apis.createCentersApi
22+
import com.mifos.core.network.apis.createClientApi
23+
import com.mifos.core.network.apis.createClientIdentifierApi
24+
import com.mifos.core.network.apis.createDataTablesApi
25+
import com.mifos.core.network.apis.createGroupsApi
26+
import com.mifos.core.network.apis.createOfficesApi
27+
import com.mifos.core.network.apis.createStaffApi
1428
import com.mifos.core.network.services.CenterService
1529
import com.mifos.core.network.services.ChargeService
1630
import com.mifos.core.network.services.CheckerInboxService
@@ -52,24 +66,33 @@ class BaseApiManager(
5266
private val ktorfit: Ktorfit,
5367
) {
5468

55-
val centerApi: CenterService = ktorfit.createCenterService()
56-
val accountsApi: ClientAccountsService = ktorfit.createClientAccountsService()
57-
val clientsApi: ClientService = ktorfit.createClientService()
58-
val dataTableApi: DataTableService = ktorfit.createDataTableService()
59-
val loanApi: LoanService = ktorfit.createLoanService()
60-
val savingsApi: SavingsAccountService = ktorfit.createSavingsAccountService()
61-
val searchApi: SearchService = ktorfit.createSearchService()
62-
val groupApi: GroupService = ktorfit.createGroupService()
63-
val documentApi: DocumentService = ktorfit.createDocumentService()
64-
val officeApi: OfficeService = ktorfit.createOfficeService()
65-
val staffApi: StaffService = ktorfit.createStaffService()
66-
val surveyApi: SurveyService = ktorfit.createSurveyService()
67-
val chargeApi: ChargeService = ktorfit.createChargeService()
68-
val checkerInboxApi: CheckerInboxService = ktorfit.createCheckerInboxService()
69-
val collectionSheetApi: CollectionSheetService = ktorfit.createCollectionSheetService()
70-
val noteApi: NoteService = ktorfit.createNoteService()
69+
val centerService: CenterService = ktorfit.createCenterService()
70+
val accountsService: ClientAccountsService = ktorfit.createClientAccountsService()
71+
val clientService: ClientService = ktorfit.createClientService()
72+
val dataTableService: DataTableService = ktorfit.createDataTableService()
73+
val loanService: LoanService = ktorfit.createLoanService()
74+
val savingsService: SavingsAccountService = ktorfit.createSavingsAccountService()
75+
val searchService: SearchService = ktorfit.createSearchService()
76+
val groupService: GroupService = ktorfit.createGroupService()
77+
val documentService: DocumentService = ktorfit.createDocumentService()
78+
val officeService: OfficeService = ktorfit.createOfficeService()
79+
val staffService: StaffService = ktorfit.createStaffService()
80+
val surveyService: SurveyService = ktorfit.createSurveyService()
81+
val chargeService: ChargeService = ktorfit.createChargeService()
82+
val checkerInboxService: CheckerInboxService = ktorfit.createCheckerInboxService()
83+
val collectionSheetService: CollectionSheetService = ktorfit.createCollectionSheetService()
84+
val noteService: NoteService = ktorfit.createNoteService()
7185
val runReportsService: RunReportsService = ktorfit.createRunReportsService()
7286

87+
// sdk apis
88+
val clientIdentifiersApi: ClientIdentifierApi = ktorfit.createClientIdentifierApi()
89+
val centerApi: CentersApi = ktorfit.createCentersApi()
90+
val officeApi: OfficesApi = ktorfit.createOfficesApi()
91+
val clientsApi: ClientApi = ktorfit.createClientApi()
92+
val groupApi: GroupsApi = ktorfit.createGroupsApi()
93+
val staffApi: StaffApi = ktorfit.createStaffApi()
94+
val dataTableApi: DataTablesApi = ktorfit.createDataTablesApi()
95+
7396
companion object {
7497
fun build(prefManager: UserPreferencesRepository): BaseApiManager {
7598
val ktorfitClient = KtorfitClient.builder()

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

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,27 @@ import org.koin.core.component.inject
4040
class DataManager : KoinComponent {
4141

4242
private val mBaseApiManager: BaseApiManager by inject()
43-
// private val mDataManagerClient: DataManagerClient by inject()
4443

4544
/**
4645
* Center API
4746
*/
4847
fun getGroupsByCenter(id: Int): Flow<CenterWithAssociations> {
49-
return mBaseApiManager.centerApi.getAllGroupsForCenter(id)
48+
return mBaseApiManager.centerService.getAllGroupsForCenter(id)
5049
}
5150

5251
fun getCentersInOffice(id: Int, params: Map<String, String>): Flow<List<CenterEntity>> {
53-
return mBaseApiManager.centerApi.getAllCentersInOffice(id, params)
52+
return mBaseApiManager.centerService.getAllCentersInOffice(id, params)
5453
}
5554

5655
fun getCollectionSheet(id: Long, payload: Payload?): Flow<CollectionSheet> {
57-
return mBaseApiManager.centerApi.getCollectionSheet(id, payload)
56+
return mBaseApiManager.centerService.getCollectionSheet(id, payload)
5857
}
5958

6059
fun saveCollectionSheet(
6160
centerId: Int,
6261
collectionSheetPayload: CollectionSheetPayload?,
6362
): Flow<SaveResponse> {
64-
return mBaseApiManager.centerApi.saveCollectionSheet(
63+
return mBaseApiManager.centerService.saveCollectionSheet(
6564
centerId,
6665
collectionSheetPayload,
6766
)
@@ -71,7 +70,7 @@ class DataManager : KoinComponent {
7170
id: Int,
7271
payload: CollectionSheetPayload?,
7372
): Flow<SaveResponse> {
74-
return mBaseApiManager.centerApi.saveCollectionSheetAsync(id, payload)
73+
return mBaseApiManager.centerService.saveCollectionSheetAsync(id, payload)
7574
}
7675

7776
fun getCenterList(
@@ -81,7 +80,7 @@ class DataManager : KoinComponent {
8180
officeId: Int,
8281
staffId: Int,
8382
): Flow<List<OfflineCenter>> {
84-
return mBaseApiManager.centerApi.getCenterList(
83+
return mBaseApiManager.centerService.getCenterList(
8584
dateFormat,
8685
locale,
8786
meetingDate,
@@ -95,96 +94,96 @@ class DataManager : KoinComponent {
9594
*/
9695
// TODO Remove this Method After fixing the Charge Test
9796
fun getClientCharges(clientId: Int, offset: Int, limit: Int): Flow<Page<ChargesEntity>> {
98-
return mBaseApiManager.chargeApi.getListOfCharges(clientId, offset, limit)
97+
return mBaseApiManager.chargeService.getListOfCharges(clientId, offset, limit)
9998
}
10099

101100
suspend fun getAllChargesV2(clientId: Int): ChargeTemplate {
102-
return mBaseApiManager.chargeApi.getAllChargesS(clientId)
101+
return mBaseApiManager.chargeService.getAllChargesS(clientId)
103102
}
104103

105104
suspend fun createCharges(
106105
clientId: Int,
107106
payload: ChargesPayload,
108107
): ChargeCreationResponse {
109-
return mBaseApiManager.chargeApi.createCharges(clientId, payload)
108+
return mBaseApiManager.chargeService.createCharges(clientId, payload)
110109
}
111110

112111
suspend fun getAllChargesV3(loanId: Int): HttpResponse {
113-
return mBaseApiManager.chargeApi.getAllChargeV3(loanId)
112+
return mBaseApiManager.chargeService.getAllChargeV3(loanId)
114113
}
115114

116115
suspend fun createLoanCharges(
117116
loanId: Int,
118117
chargesPayload: ChargesPayload,
119118
): ChargeCreationResponse {
120-
return mBaseApiManager.chargeApi.createLoanCharges(loanId, chargesPayload)
119+
return mBaseApiManager.chargeService.createLoanCharges(loanId, chargesPayload)
121120
}
122121

123122
/**
124123
* Groups API
125124
*/
126125
fun getGroups(groupid: Int): Flow<GroupWithAssociations> {
127-
return mBaseApiManager.groupApi.getGroupWithAssociations(groupid)
126+
return mBaseApiManager.groupService.getGroupWithAssociations(groupid)
128127
}
129128

130129
fun getGroupsByOffice(
131130
office: Int,
132131
params: Map<String, String>,
133132
): Flow<List<GroupEntity>> {
134-
return mBaseApiManager.groupApi.getAllGroupsInOffice(office, params)
133+
return mBaseApiManager.groupService.getAllGroupsInOffice(office, params)
135134
}
136135

137136
/**
138137
* Offices API
139138
*/
140139
fun offices(): Flow<List<OfficeEntity>> {
141-
return mBaseApiManager.officeApi.allOffices()
140+
return mBaseApiManager.officeService.allOffices()
142141
}
143142

144143
/**
145144
* Staff API
146145
*/
147146
fun getStaffInOffice(officeId: Int): Flow<List<StaffEntity>> {
148-
return mBaseApiManager.staffApi.getStaffForOffice(officeId)
147+
return mBaseApiManager.staffService.getStaffForOffice(officeId)
149148
}
150149

151150
val allStaff: Flow<List<StaffEntity>>
152-
get() = mBaseApiManager.staffApi.allStaff()
151+
get() = mBaseApiManager.staffService.allStaff()
153152

154153
/**
155154
* Loans API
156155
*/
157156
fun getLoanTransactions(loan: Int): Flow<LoanWithAssociationsEntity> {
158-
return mBaseApiManager.loanApi.getLoanWithTransactions(loan)
157+
return mBaseApiManager.loanService.getLoanWithTransactions(loan)
159158
}
160159

161160
val allLoans: Flow<List<com.mifos.core.model.objects.organisations.LoanProducts>>
162-
get() = mBaseApiManager.loanApi.getAllLoans()
161+
get() = mBaseApiManager.loanService.getAllLoans()
163162

164163
fun getGroupLoansAccountTemplate(groupId: Int, productId: Int): Flow<GroupLoanTemplate> {
165-
return mBaseApiManager.loanApi.getGroupLoansAccountTemplate(groupId, productId)
164+
return mBaseApiManager.loanService.getGroupLoansAccountTemplate(groupId, productId)
166165
}
167166

168167
fun createGroupLoansAccount(loansPayload: GroupLoanPayload?): Flow<Loan> {
169-
return mBaseApiManager.loanApi.createGroupLoansAccount(loansPayload)
168+
return mBaseApiManager.loanService.createGroupLoansAccount(loansPayload)
170169
}
171170

172171
fun getLoanRepaySchedule(loanId: Int): Flow<LoanWithAssociationsEntity> {
173-
return mBaseApiManager.loanApi.getLoanRepaymentSchedule(loanId)
172+
return mBaseApiManager.loanService.getLoanRepaymentSchedule(loanId)
174173
}
175174

176175
fun approveLoan(
177176
loanId: Int,
178177
loanApproval: com.mifos.core.model.objects.account.loan.LoanApproval?,
179178
): Flow<GenericResponse> {
180-
return mBaseApiManager.loanApi.approveLoanApplication(loanId, loanApproval)
179+
return mBaseApiManager.loanService.approveLoanApplication(loanId, loanApproval)
181180
}
182181

183182
fun getListOfLoanCharges(loanId: Int): Flow<List<ChargesEntity>> {
184-
return mBaseApiManager.loanApi.getListOfLoanCharges(loanId)
183+
return mBaseApiManager.loanService.getListOfLoanCharges(loanId)
185184
}
186185

187186
fun getListOfCharges(clientId: Int): Flow<Page<ChargesEntity>> {
188-
return mBaseApiManager.loanApi.getListOfCharges(clientId)
187+
return mBaseApiManager.loanService.getListOfCharges(clientId)
189188
}
190189
}

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

Lines changed: 0 additions & 49 deletions
This file was deleted.

core/network/src/commonMain/kotlin/com/mifos/core/network/apimanager/BaseApiManagerImpl.kt

Lines changed: 0 additions & 55 deletions
This file was deleted.

core/network/src/commonMain/kotlin/com/mifos/core/network/apis/CentersApi.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ interface CentersApi {
4141
* @param locale locale (optional)
4242
* @return [GetCentersResponse]
4343
*/
44-
@GET("v1/centers")
44+
@GET("centers")
4545
suspend fun retrieveAll23(
4646
@Query("officeId") officeId: Long? = null,
4747
@Query("staffId") staffId: Long? = null,
@@ -69,7 +69,7 @@ interface CentersApi {
6969
* @param command command (optional)
7070
* @return [PostCentersCenterIdResponse]
7171
*/
72-
@POST("v1/centers/{centerId}")
72+
@POST("centers/{centerId}")
7373
suspend fun activate2(
7474
@Path("centerId") centerId: Long,
7575
@Body postCentersCenterIdRequest: PostCentersCenterIdRequest,

0 commit comments

Comments
 (0)