forked from openMF/mifos-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor openMF#2415: beneficiary,tpt to stateflow
- Loading branch information
1 parent
4be93df
commit 237a078
Showing
17 changed files
with
242 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
app/src/main/java/org/mifos/mobile/repositories/BeneficiaryRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
package org.mifos.mobile.repositories | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import okhttp3.ResponseBody | ||
import org.mifos.mobile.models.beneficiary.Beneficiary | ||
import org.mifos.mobile.models.beneficiary.BeneficiaryPayload | ||
import org.mifos.mobile.models.beneficiary.BeneficiaryUpdatePayload | ||
import org.mifos.mobile.models.templates.beneficiary.BeneficiaryTemplate | ||
import retrofit2.Response | ||
|
||
interface BeneficiaryRepository { | ||
|
||
suspend fun beneficiaryTemplate(): Response<BeneficiaryTemplate?>? | ||
suspend fun beneficiaryTemplate(): Flow<BeneficiaryTemplate> | ||
|
||
suspend fun createBeneficiary(beneficiaryPayload: BeneficiaryPayload?): Response<ResponseBody?>? | ||
suspend fun createBeneficiary(beneficiaryPayload: BeneficiaryPayload?): Flow<ResponseBody> | ||
|
||
suspend fun updateBeneficiary( | ||
beneficiaryId: Long?, | ||
payload: BeneficiaryUpdatePayload?, | ||
): Response<ResponseBody?>? | ||
): Flow<ResponseBody> | ||
|
||
suspend fun deleteBeneficiary(beneficiaryId: Long?): Response<ResponseBody?>? | ||
suspend fun deleteBeneficiary(beneficiaryId: Long?): Flow<ResponseBody> | ||
|
||
suspend fun beneficiaryList(): Response<List<Beneficiary?>?>? | ||
suspend fun beneficiaryList(): Flow<List<Beneficiary>> | ||
|
||
} |
33 changes: 22 additions & 11 deletions
33
app/src/main/java/org/mifos/mobile/repositories/BeneficiaryRepositoryImp.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,49 @@ | ||
package org.mifos.mobile.repositories | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import okhttp3.ResponseBody | ||
import org.mifos.mobile.api.DataManager | ||
import org.mifos.mobile.models.beneficiary.Beneficiary | ||
import org.mifos.mobile.models.beneficiary.BeneficiaryPayload | ||
import org.mifos.mobile.models.beneficiary.BeneficiaryUpdatePayload | ||
import org.mifos.mobile.models.templates.beneficiary.BeneficiaryTemplate | ||
import retrofit2.Response | ||
import javax.inject.Inject | ||
|
||
class BeneficiaryRepositoryImp @Inject constructor(private val dataManager: DataManager) : | ||
BeneficiaryRepository { | ||
|
||
override suspend fun beneficiaryTemplate(): Response<BeneficiaryTemplate?>? { | ||
return dataManager.beneficiaryTemplate() | ||
override suspend fun beneficiaryTemplate(): Flow<BeneficiaryTemplate> { | ||
return flow { | ||
emit(dataManager.beneficiaryTemplate()) | ||
} | ||
} | ||
|
||
override suspend fun createBeneficiary(beneficiaryPayload: BeneficiaryPayload?): Response<ResponseBody?>? { | ||
return dataManager.createBeneficiary(beneficiaryPayload) | ||
override suspend fun createBeneficiary(beneficiaryPayload: BeneficiaryPayload?): Flow<ResponseBody> { | ||
return flow { | ||
emit(dataManager.createBeneficiary(beneficiaryPayload)) | ||
} | ||
} | ||
|
||
override suspend fun updateBeneficiary( | ||
beneficiaryId: Long?, | ||
payload: BeneficiaryUpdatePayload? | ||
): Response<ResponseBody?>? { | ||
return dataManager.updateBeneficiary(beneficiaryId, payload) | ||
): Flow<ResponseBody> { | ||
return flow { | ||
emit(dataManager.updateBeneficiary(beneficiaryId, payload)) | ||
} | ||
} | ||
|
||
override suspend fun deleteBeneficiary(beneficiaryId: Long?): Response<ResponseBody?>? { | ||
return dataManager.deleteBeneficiary(beneficiaryId) | ||
override suspend fun deleteBeneficiary(beneficiaryId: Long?): Flow<ResponseBody> { | ||
return flow { | ||
emit(dataManager.deleteBeneficiary(beneficiaryId)) | ||
} | ||
} | ||
|
||
override suspend fun beneficiaryList(): Response<List<Beneficiary?>?>? { | ||
return dataManager.beneficiaryList() | ||
override suspend fun beneficiaryList(): Flow<List<Beneficiary>> { | ||
return flow { | ||
emit(dataManager.beneficiaryList()) | ||
} | ||
} | ||
|
||
} |
4 changes: 2 additions & 2 deletions
4
app/src/main/java/org/mifos/mobile/repositories/ThirdPartyTransferRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
package org.mifos.mobile.repositories | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import org.mifos.mobile.models.templates.account.AccountOptionsTemplate | ||
import retrofit2.Response | ||
|
||
interface ThirdPartyTransferRepository { | ||
|
||
suspend fun thirdPartyTransferTemplate(): Response<AccountOptionsTemplate?>? | ||
suspend fun thirdPartyTransferTemplate(): Flow<AccountOptionsTemplate> | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.