-
Notifications
You must be signed in to change notification settings - Fork 667
feat(core:domain): Migrate to KMP #2350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
niyajali
merged 20 commits into
openMF:kmp-impl
from
biplab1:core-domain-migrate-to-kmp
May 12, 2025
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
395a235
refactor(core:domain): initial setup for KMP
5cdc8ff
fix(core:domain): correct import statements for resources
552b69a
refactor(core:domain): remove rxjava usage
4b3262d
refactor(core:domain): replace callbackFlow with flow
2501afa
remove mistakenly added file
c7eb812
refactor(core:domain): removed try and catch block from inside flow
1839f52
Merge branch 'kmp-impl' into core-domain-migrate-to-kmp
5b6ec78
refactor(core:domain): remove try and catch blocks
242d4b0
fix(core:domain): apply spotless changes
1b10449
refactor(core): added MFErrorparser, migrated classes to KMP
6cdd557
Merge branch 'kmp-impl' into core-domain-migrate-to-kmp
cadbdfa
refactor(core:domain): use case to use combine
754cbd1
Merge branch 'kmp-impl' into core-domain-migrate-to-kmp
76c5d7a
merge kmp-impl branch
4cf9e44
refactor(core:domain): replace OpenAPI model imports with :core:netwo…
fd7a848
Merge branch 'kmp-impl' into core-domain-migrate-to-kmp
eeb4f44
refactor(core:domain): remove paging platform specific files
biplab1 62f3655
refactor(core:domain): replace Resource with DataState
biplab1 e43e005
refactor(core:domain): implement client image upload
biplab1 4df75c9
fix: apply spotless
biplab1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
44 changes: 44 additions & 0 deletions
44
core/common/src/commonMain/kotlin/com/mifos/core/common/utils/MFErrorParser.kt
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /* | ||
| * Copyright 2025 Mifos Initiative | ||
| * | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
| * | ||
| * See https://github.com/openMF/android-client/blob/master/LICENSE.md | ||
| */ | ||
| package com.mifos.core.common.utils | ||
|
|
||
| import com.mifos.core.model.objects.error.MifosError | ||
| import io.ktor.client.plugins.ClientRequestException | ||
| import io.ktor.client.plugins.ServerResponseException | ||
| import io.ktor.client.statement.bodyAsText | ||
| import kotlinx.serialization.json.Json | ||
|
|
||
| object MFErrorParser { | ||
| const val LOG_TAG: String = "MFErrorParser" | ||
|
|
||
| private val json: Json = Json { ignoreUnknownKeys = true } | ||
|
|
||
| private fun parseError(serverResponse: String?): MifosError { | ||
| return json.decodeFromString(serverResponse ?: "{}") | ||
| } | ||
|
|
||
| suspend fun errorMessage(throwableError: Throwable): String { | ||
| return try { | ||
| when (throwableError) { | ||
| is ClientRequestException, is ServerResponseException -> { | ||
| val response = (throwableError as? ClientRequestException)?.response | ||
| ?: (throwableError as? ServerResponseException)?.response | ||
| val errorBody = response?.bodyAsText() ?: "" | ||
| parseError(errorBody).errors.firstOrNull()?.defaultUserMessage | ||
| ?: "Something went wrong!" | ||
| } | ||
|
|
||
| else -> throwableError.message ?: "Unknown error" | ||
| } | ||
| } catch (exception: Exception) { | ||
| "Error processing response" | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or 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 hidden or 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
27 changes: 27 additions & 0 deletions
27
core/domain/src/commonMain/kotlin/com/mifos/core/domain/useCases/ActivateGroupUseCase.kt
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /* | ||
| * Copyright 2024 Mifos Initiative | ||
| * | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
| * | ||
| * See https://github.com/openMF/android-client/blob/master/LICENSE.md | ||
| */ | ||
| package com.mifos.core.domain.useCases | ||
|
|
||
| import com.mifos.core.common.utils.DataState | ||
| import com.mifos.core.data.repository.ActivateRepository | ||
| import com.mifos.core.model.objects.clients.ActivatePayload | ||
| import com.mifos.core.network.GenericResponse | ||
| import kotlinx.coroutines.flow.Flow | ||
|
|
||
| class ActivateGroupUseCase( | ||
| private val activateRepository: ActivateRepository, | ||
| ) { | ||
|
|
||
| operator fun invoke( | ||
| groupId: Int, | ||
| groupPayload: ActivatePayload, | ||
| ): Flow<DataState<GenericResponse>> = | ||
| activateRepository.activateGroup(groupId, groupPayload) | ||
| } |
29 changes: 29 additions & 0 deletions
29
core/domain/src/commonMain/kotlin/com/mifos/core/domain/useCases/ActivateSavingsUseCase.kt
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /* | ||
| * Copyright 2024 Mifos Initiative | ||
| * | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
| * | ||
| * See https://github.com/openMF/android-client/blob/master/LICENSE.md | ||
| */ | ||
| package com.mifos.core.domain.useCases | ||
|
|
||
| import com.mifos.core.common.utils.DataState | ||
| import com.mifos.core.data.repository.SavingsAccountActivateRepository | ||
| import com.mifos.core.network.GenericResponse | ||
| import kotlinx.coroutines.flow.Flow | ||
|
|
||
| /** | ||
| * Created by Pronay Sarker on 04/08/2024 (12:33 PM) | ||
| */ | ||
| class ActivateSavingsUseCase( | ||
| private val repository: SavingsAccountActivateRepository, | ||
| ) { | ||
|
|
||
| operator fun invoke( | ||
| savingsAccountId: Int, | ||
| request: HashMap<String, String>, | ||
| ): Flow<DataState<GenericResponse>> = | ||
| repository.activateSavings(savingsAccountId, request) | ||
| } |
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.