Skip to content

Commit befb189

Browse files
refactor (core:network ) Network converted to KMP (#2346)
* initial setup * updated * Updated * Changed Imports in Services * Updated * Updated * Added ktorHttpClient * Added ktorHttpClient * Updated * Updated * Updated * updated mappers * updated mappers * Updated * Updated * Updated * Updated * Updated * Updated ImageLoader.Utils * changed observable to flow in data * Updated * Updated * Updated * Updated based on suggestions * Updated * Updated * Updated
1 parent 8548bf8 commit befb189

File tree

201 files changed

+3463
-1097
lines changed

Some content is hidden

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

201 files changed

+3463
-1097
lines changed

core/data/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,6 @@ dependencies {
5252

5353
implementation(libs.androidx.core.ktx)
5454
implementation(libs.androidx.tracing.ktx)
55+
56+
implementation(libs.ktor.client.okhttp)
5557
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ package com.mifos.core.data.repository
1111

1212
import com.mifos.core.model.objects.clients.ActivatePayload
1313
import com.mifos.core.network.GenericResponse
14-
import org.openapitools.client.models.PostCentersCenterIdResponse
15-
import org.openapitools.client.models.PostClientsClientIdResponse
16-
import rx.Observable
14+
import com.mifos.core.network.model.PostCentersCenterIdResponse
15+
import com.mifos.core.network.model.PostClientsClientIdResponse
16+
import kotlinx.coroutines.flow.Flow
1717

1818
/**
1919
* Created by Aditya Gupta on 06/08/23.
@@ -34,5 +34,5 @@ interface ActivateRepository {
3434
fun activateGroup(
3535
groupId: Int,
3636
activatePayload: ActivatePayload?,
37-
): Observable<GenericResponse>
37+
): Flow<GenericResponse>
3838
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ package com.mifos.core.data.repository
1212
import com.mifos.core.model.objects.checkerinboxtask.CheckerInboxSearchTemplate
1313
import com.mifos.core.model.objects.checkerinboxtask.CheckerTask
1414
import com.mifos.core.network.GenericResponse
15+
import kotlinx.coroutines.flow.Flow
1516

1617
interface CheckerInboxRepository {
1718

18-
suspend fun loadCheckerTasks(
19+
fun loadCheckerTasks(
1920
actionName: String? = null,
2021
entityName: String? = null,
2122
resourceId: Int? = null,
22-
): List<CheckerTask>
23+
): Flow<List<CheckerTask>>
2324

2425
suspend fun approveCheckerEntry(auditId: Int): GenericResponse
2526

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
@@ -11,14 +11,14 @@ package com.mifos.core.data.repository
1111

1212
import com.mifos.room.entities.accounts.ClientAccounts
1313
import com.mifos.room.entities.client.ClientEntity
14-
import okhttp3.MultipartBody
14+
import io.ktor.http.content.PartData
1515

1616
/**
1717
* Created by Aditya Gupta on 06/08/23.
1818
*/
1919
interface ClientDetailsRepository {
2020

21-
suspend fun uploadClientImage(id: Int, file: MultipartBody.Part?)
21+
suspend fun uploadClientImage(id: Int, file: PartData?)
2222

2323
suspend fun deleteClientImage(clientId: Int)
2424

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
package com.mifos.core.data.repository
1111

1212
import com.mifos.core.model.objects.noncoreobjects.Identifier
13+
import com.mifos.core.network.model.DeleteClientsClientIdIdentifiersIdentifierIdResponse
1314
import kotlinx.coroutines.flow.Flow
14-
import org.openapitools.client.models.DeleteClientsClientIdIdentifiersIdentifierIdResponse
1515

1616
/**
1717
* Created by Aditya Gupta on 08/08/23.

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
@@ -13,8 +13,8 @@ import com.mifos.room.entities.client.ClientPayloadEntity
1313
import com.mifos.room.entities.organisation.OfficeEntity
1414
import com.mifos.room.entities.organisation.StaffEntity
1515
import com.mifos.room.entities.templates.clients.ClientsTemplateEntity
16+
import io.ktor.http.content.PartData
1617
import kotlinx.coroutines.flow.Flow
17-
import okhttp3.MultipartBody
1818

1919
/**
2020
* Created by Aditya Gupta on 10/08/23.
@@ -29,5 +29,5 @@ interface CreateNewClientRepository {
2929

3030
suspend fun createClient(clientPayload: ClientPayloadEntity): Int?
3131

32-
suspend fun uploadClientImage(id: Int, file: MultipartBody.Part?)
32+
suspend fun uploadClientImage(id: Int, file: PartData?)
3333
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
*/
1010
package com.mifos.core.data.repository
1111

12+
import com.mifos.core.network.model.DeleteDataTablesDatatableAppTableIdDatatableIdResponse
1213
import kotlinx.serialization.json.JsonArray
13-
import org.openapitools.client.models.DeleteDataTablesDatatableAppTableIdDatatableIdResponse
1414

1515
/**
1616
* Created by Aditya Gupta on 10/08/23.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ import com.mifos.core.model.objects.payloads.GroupLoanPayload
1313
import com.mifos.core.network.model.LoansPayload
1414
import com.mifos.room.entities.accounts.loans.Loan
1515
import com.mifos.room.entities.client.ClientPayloadEntity
16-
import rx.Observable
16+
import kotlinx.coroutines.flow.Flow
1717

1818
/**
1919
* Created by Aditya Gupta on 10/08/23.
2020
*/
2121
interface DataTableListRepository {
2222

23-
fun createLoansAccount(loansPayload: LoansPayload?): Observable<Loan>
23+
fun createLoansAccount(loansPayload: LoansPayload?): Flow<Loan>
2424

25-
fun createGroupLoansAccount(loansPayload: GroupLoanPayload?): Observable<Loan>
25+
fun createGroupLoansAccount(loansPayload: GroupLoanPayload?): Flow<Loan>
2626

2727
suspend fun createClient(clientPayload: ClientPayloadEntity): Int?
2828
}

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

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

1212
import com.mifos.core.network.GenericResponse
13-
import okhttp3.MultipartBody
14-
import rx.Observable
13+
import io.ktor.http.content.PartData
14+
import kotlinx.coroutines.flow.Flow
1515

1616
/**
1717
* Created by Aditya Gupta on 16/08/23.
@@ -23,15 +23,15 @@ interface DocumentDialogRepository {
2323
entityId: Int,
2424
name: String?,
2525
desc: String?,
26-
file: MultipartBody.Part?,
27-
): Observable<GenericResponse>
26+
file: PartData?,
27+
): Flow<GenericResponse>
2828

2929
fun updateDocument(
3030
entityType: String?,
3131
entityId: Int,
3232
documentId: Int,
3333
name: String?,
3434
desc: String?,
35-
file: MultipartBody.Part?,
36-
): Observable<GenericResponse>
35+
file: PartData?,
36+
): Flow<GenericResponse>
3737
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ package com.mifos.core.data.repository
1111

1212
import com.mifos.core.model.objects.noncoreobjects.Document
1313
import com.mifos.core.network.GenericResponse
14-
import okhttp3.ResponseBody
14+
import io.ktor.client.statement.HttpResponse
1515

1616
/**
1717
* Created by Aditya Gupta on 08/08/23.
@@ -24,7 +24,7 @@ interface DocumentListRepository {
2424
entityType: String,
2525
entityId: Int,
2626
documentId: Int,
27-
): ResponseBody
27+
): HttpResponse
2828

2929
suspend fun removeDocument(
3030
entityType: String,

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,29 @@ import com.mifos.room.entities.collectionsheet.ProductiveCollectionSheetPayload
1818
import com.mifos.room.entities.group.CenterEntity
1919
import com.mifos.room.entities.group.CenterWithAssociations
2020
import com.mifos.room.entities.group.GroupEntity
21+
import kotlinx.coroutines.flow.Flow
2122

2223
/**
2324
* Created by Aditya Gupta on 12/08/23.
2425
*/
2526
interface GenerateCollectionSheetRepository {
2627

27-
suspend fun getCentersInOffice(id: Int, params: Map<String, String>): List<CenterEntity>
28+
fun getCentersInOffice(id: Int, params: Map<String, String>): Flow<List<CenterEntity>>
2829

29-
suspend fun getGroupsByOffice(
30+
fun getGroupsByOffice(
3031
office: Int,
3132
params: Map<String, String>,
32-
): List<GroupEntity>
33+
): Flow<List<GroupEntity>>
3334

3435
suspend fun fetchGroupsAssociatedWithCenter(centerId: Int): CenterWithAssociations
3536

36-
suspend fun fetchCenterDetails(
37+
fun fetchCenterDetails(
3738
format: String?,
3839
locale: String?,
3940
meetingDate: String?,
4041
officeId: Int,
4142
staffId: Int,
42-
): List<CenterDetail>
43+
): Flow<List<CenterDetail>>
4344

4445
suspend fun fetchProductiveCollectionSheet(
4546
centerId: Int,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ package com.mifos.core.data.repository
1212
import com.mifos.core.model.objects.payloads.GroupLoanPayload
1313
import com.mifos.core.model.objects.template.loan.GroupLoanTemplate
1414
import com.mifos.room.entities.accounts.loans.Loan
15-
import rx.Observable
15+
import kotlinx.coroutines.flow.Flow
1616

1717
/**
1818
* Created by Aditya Gupta on 12/08/23.
1919
*/
2020
interface GroupLoanAccountRepository {
2121

22-
fun getGroupLoansAccountTemplate(groupId: Int, productId: Int): Observable<GroupLoanTemplate>
22+
fun getGroupLoansAccountTemplate(groupId: Int, productId: Int): Flow<GroupLoanTemplate>
2323

24-
fun createGroupLoansAccount(loansPayload: GroupLoanPayload): Observable<Loan>
24+
fun createGroupLoansAccount(loansPayload: GroupLoanPayload): Flow<Loan>
2525
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ package com.mifos.core.data.repository
1111

1212
import com.mifos.core.model.objects.account.loan.LoanApproval
1313
import com.mifos.core.network.GenericResponse
14-
import rx.Observable
14+
import kotlinx.coroutines.flow.Flow
1515

1616
/**
1717
* Created by Aditya Gupta on 10/08/23.
1818
*/
1919
interface LoanAccountApprovalRepository {
2020

21-
fun approveLoan(loanId: Int, loanApproval: LoanApproval?): Observable<GenericResponse>
21+
fun approveLoan(loanId: Int, loanApproval: LoanApproval?): Flow<GenericResponse>
2222
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ package com.mifos.core.data.repository
1212
import com.mifos.core.model.objects.account.loan.LoanDisbursement
1313
import com.mifos.core.network.GenericResponse
1414
import com.mifos.room.entities.templates.loans.LoanTransactionTemplate
15-
import rx.Observable
15+
import kotlinx.coroutines.flow.Flow
1616

1717
/**
1818
* Created by Aditya Gupta on 10/08/23.
@@ -22,10 +22,10 @@ interface LoanAccountDisbursementRepository {
2222
fun getLoanTransactionTemplate(
2323
loanId: Int,
2424
command: String?,
25-
): Observable<LoanTransactionTemplate>
25+
): Flow<LoanTransactionTemplate>
2626

2727
fun disburseLoan(
2828
loanId: Int,
2929
loanDisbursement: LoanDisbursement?,
30-
): Observable<GenericResponse>
30+
): Flow<GenericResponse>
3131
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ package com.mifos.core.data.repository
1212
import com.mifos.core.network.model.LoansPayload
1313
import com.mifos.room.entities.accounts.loans.Loan
1414
import com.mifos.room.entities.templates.loans.LoanTemplate
15-
import rx.Observable
15+
import kotlinx.coroutines.flow.Flow
1616

1717
/**
1818
* Created by Aditya Gupta on 08/08/23.
1919
*/
2020
interface LoanAccountRepository {
2121

22-
suspend fun allLoans(): Observable<List<com.mifos.core.model.objects.organisations.LoanProducts>>
22+
fun allLoans(): Flow<List<com.mifos.core.model.objects.organisations.LoanProducts>>
2323

24-
suspend fun getLoansAccountTemplate(clientId: Int, productId: Int): Observable<LoanTemplate>
24+
fun getLoansAccountTemplate(clientId: Int, productId: Int): Flow<LoanTemplate>
2525

26-
suspend fun createLoansAccount(loansPayload: LoansPayload): Observable<Loan>
26+
fun createLoansAccount(loansPayload: LoansPayload): Flow<Loan>
2727
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ package com.mifos.core.data.repository
1111

1212
import com.mifos.core.model.objects.clients.ChargeCreationResponse
1313
import com.mifos.core.model.objects.payloads.ChargesPayload
14-
import okhttp3.ResponseBody
14+
import io.ktor.client.statement.HttpResponse
1515

1616
/**
1717
* Created by Aditya Gupta on 16/08/23.
1818
*/
1919
interface LoanChargeDialogRepository {
2020

21-
suspend fun getAllChargesV3(loanId: Int): ResponseBody
21+
suspend fun getAllChargesV3(loanId: Int): HttpResponse
2222

2323
suspend fun createLoanCharges(
2424
loanId: Int,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
package com.mifos.core.data.repository
1111

1212
import com.mifos.room.entities.accounts.loans.LoanWithAssociationsEntity
13-
import rx.Observable
13+
import kotlinx.coroutines.flow.Flow
1414

1515
/**
1616
* Created by Aditya Gupta on 12/08/23.
1717
*/
1818
interface LoanRepaymentScheduleRepository {
1919

20-
fun getLoanRepaySchedule(loanId: Int): Observable<LoanWithAssociationsEntity>
20+
fun getLoanRepaySchedule(loanId: Int): Flow<LoanWithAssociationsEntity>
2121
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
package com.mifos.core.data.repository
1111

1212
import com.mifos.room.entities.accounts.loans.LoanWithAssociationsEntity
13-
import rx.Observable
13+
import kotlinx.coroutines.flow.Flow
1414

1515
/**
1616
* Created by Aditya Gupta on 12/08/23.
1717
*/
1818
interface LoanTransactionsRepository {
1919

20-
fun getLoanTransactions(loan: Int): Observable<LoanWithAssociationsEntity>
20+
fun getLoanTransactions(loan: Int): Flow<LoanWithAssociationsEntity>
2121
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
package com.mifos.core.data.repository
1111

12-
import org.openapitools.client.models.PostAuthenticationResponse
12+
import com.mifos.core.network.model.PostAuthenticationResponse
1313

1414
/**
1515
* Created by Aditya Gupta on 06/08/23.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ interface NewIndividualCollectionSheetRepository {
2626

2727
fun offices(): Flow<List<OfficeEntity>>
2828

29-
suspend fun getStaffInOffice(officeId: Int): List<StaffEntity>
29+
fun getStaffInOffice(officeId: Int): Flow<List<StaffEntity>>
3030
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@
1010
package com.mifos.core.data.repository
1111

1212
import com.mifos.core.model.objects.runreport.client.ClientReportTypeItem
13+
import kotlinx.coroutines.flow.Flow
1314

1415
/**
1516
* Created by Aditya Gupta on 12/08/23.
1617
*/
1718
interface ReportCategoryRepository {
1819

19-
suspend fun getReportCategories(
20+
fun getReportCategories(
2021
reportCategory: String,
2122
genericResultSet: Boolean,
2223
parameterType: Boolean,
23-
): List<ClientReportTypeItem>
24+
): Flow<List<ClientReportTypeItem>>
2425
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
package com.mifos.core.data.repository
1111

1212
import com.mifos.core.network.GenericResponse
13-
import rx.Observable
13+
import kotlinx.coroutines.flow.Flow
1414

1515
/**
1616
* Created by Aditya Gupta on 13/08/23.
@@ -20,5 +20,5 @@ interface SavingsAccountActivateRepository {
2020
fun activateSavings(
2121
savingsAccountId: Int,
2222
request: HashMap<String, String>,
23-
): Observable<GenericResponse>
23+
): Flow<GenericResponse>
2424
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ package com.mifos.core.data.repository
1111

1212
import com.mifos.core.model.objects.account.loan.SavingsApproval
1313
import com.mifos.core.network.GenericResponse
14-
import rx.Observable
14+
import kotlinx.coroutines.flow.Flow
1515

1616
/**
1717
* Created by Aditya Gupta on 13/08/23.
@@ -21,5 +21,5 @@ interface SavingsAccountApprovalRepository {
2121
fun approveSavingsApplication(
2222
savingsAccountId: Int,
2323
savingsApproval: SavingsApproval?,
24-
): Observable<GenericResponse>
24+
): Flow<GenericResponse>
2525
}

0 commit comments

Comments
 (0)