From 1eb3ec5a926ce51605608aea4b477e4bdebc2218 Mon Sep 17 00:00:00 2001 From: Nagarjuna0033 Date: Thu, 16 Jan 2025 15:49:16 +0530 Subject: [PATCH 1/3] Feat: [:core:data] - Migrated to KMP --- .../demoDebugRuntimeClasspath.txt | 15 +- .../demoReleaseRuntimeClasspath.txt | 68 +++++---- .../prodDebugRuntimeClasspath.txt | 66 ++++++--- .../prodReleaseRuntimeClasspath.txt | 64 ++++++--- core/data/build.gradle.kts | 44 +++--- .../{main => androidMain}/AndroidManifest.xml | 0 .../di/AndroidPlatformDependentDataModule.kt | 24 ++++ .../core/data/di/AndroidPlatformModule.kt | 36 +++++ .../ConnectivityManagerNetworkMonitor.kt | 14 +- .../data/di/PlatformDependentDataModule.kt | 21 +++ .../mobile/core/data/di/RepositoryModule.kt | 75 ++++++++++ .../mifos/mobile/core/data/model/Charge.kt | 0 .../core/data/model/MifosNotification.kt | 0 .../data/repository/AccountsRepository.kt | 3 +- .../data/repository/BeneficiaryRepository.kt | 12 +- .../data/repository/ClientChargeRepository.kt | 12 +- .../core/data/repository/ClientRepository.kt | 11 +- .../data/repository/GuarantorRepository.kt | 16 +-- .../core/data/repository/HomeRepository.kt | 11 +- .../core/data/repository/LoanRepository.kt | 13 +- .../data/repository/NotificationRepository.kt | 5 +- .../repository/RecentTransactionRepository.kt | 6 +- .../ReviewLoanApplicationRepository.kt | 5 +- .../repository/SavingsAccountRepository.kt | 16 +-- .../ThirdPartyTransferRepository.kt | 3 +- .../data/repository/TransferRepository.kt | 5 +- .../data/repository/UserAuthRepository.kt | 11 +- .../data/repository/UserDataRepository.kt | 5 +- .../data/repository/UserDetailRepository.kt | 10 +- .../repositoryImpl/AccountsRepositoryImp.kt | 16 ++- .../AuthenticationUserRepository.kt | 51 +++++++ .../BeneficiaryRepositoryImp.kt | 75 ++++++++++ .../ClientChargeRepositoryImp.kt | 31 ++-- .../repositoryImpl/ClientRepositoryImp.kt | 100 +++++++++++++ .../repositoryImpl/GuarantorRepositoryImp.kt | 78 ++++++++++ .../data/repositoryImpl/HomeRepositoryImp.kt | 48 +++++++ .../data/repositoryImpl/LoanRepositoryImp.kt | 60 ++++++++ .../NotificationRepositoryImp.kt | 7 +- .../RecentTransactionRepositoryImp.kt | 25 ++-- .../ReviewLoanApplicationRepositoryImpl.kt | 28 ++-- .../SavingsAccountRepositoryImp.kt | 98 +++++++++++++ .../ThirdPartyTransferRepositoryImp.kt | 17 +-- .../repositoryImpl/TransferRepositoryImp.kt | 71 ++++++++++ .../repositoryImpl/UserAuthRepositoryImp.kt | 108 ++++++++++++++ .../repositoryImpl/UserDetailRepositoryImp.kt | 57 ++++++++ .../mobile/core/data/util}/NetworkMonitor.kt | 4 +- .../data/JsPlatformDependentDataModule.kt | 23 +++ .../di/PlatformDependentDataModule.desktop.kt | 22 +++ .../data/JsPlatformDependentDataModule.kt | 23 +++ .../data/di/PlatformDependentDataModule.js.kt | 22 +++ .../mobile/core/data/di/RepositoryModule.kt | 133 ------------------ .../AuthenticationUserRepository.kt | 36 ----- .../BeneficiaryRepositoryImp.kt | 59 -------- .../repositoryImpl/ClientRepositoryImp.kt | 75 ---------- .../repositoryImpl/GuarantorRepositoryImp.kt | 62 -------- .../data/repositoryImpl/HomeRepositoryImp.kt | 48 ------- .../data/repositoryImpl/LoanRepositoryImp.kt | 55 -------- .../SavingsAccountRepositoryImp.kt | 85 ----------- .../repositoryImpl/TransferRepositoryImp.kt | 68 --------- .../repositoryImpl/UserAuthRepositoryImp.kt | 90 ------------ .../repositoryImpl/UserDetailRepositoryImp.kt | 45 ------ .../data/NativePlatformDependentDataModule.kt | 23 +++ .../di/PlatformDependentDataModule.native.kt | 22 +++ .../data/JsPlatformDependentDataModule.kt | 23 +++ .../di/PlatformDependentDataModule.wasmJs.kt | 22 +++ .../datastore/UserPreferencesDataSource.kt | 12 ++ .../datastore/UserPreferencesRepository.kt | 2 + .../UserPreferencesRepositoryImpl.kt | 9 ++ .../model/entity/UpdatePasswordPayload.kt | 10 +- .../mifos/mobile/core/network/DataManager.kt | 24 ++-- 70 files changed, 1432 insertions(+), 1006 deletions(-) rename core/data/src/{main => androidMain}/AndroidManifest.xml (100%) create mode 100644 core/data/src/androidMain/kotlin/org/mifos/mobile/core/data/di/AndroidPlatformDependentDataModule.kt create mode 100644 core/data/src/androidMain/kotlin/org/mifos/mobile/core/data/di/AndroidPlatformModule.kt rename core/data/src/{main/java/org/mifos/mobile/core/data/utils => androidMain/kotlin/org/mifos/mobile/core/data/util}/ConnectivityManagerNetworkMonitor.kt (89%) create mode 100644 core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/di/PlatformDependentDataModule.kt create mode 100644 core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/di/RepositoryModule.kt rename core/data/src/{main/java => commonMain/kotlin}/org/mifos/mobile/core/data/model/Charge.kt (100%) rename core/data/src/{main/java => commonMain/kotlin}/org/mifos/mobile/core/data/model/MifosNotification.kt (100%) rename core/data/src/{main/java => commonMain/kotlin}/org/mifos/mobile/core/data/repository/AccountsRepository.kt (78%) rename core/data/src/{main/java => commonMain/kotlin}/org/mifos/mobile/core/data/repository/BeneficiaryRepository.kt (74%) rename core/data/src/{main/java => commonMain/kotlin}/org/mifos/mobile/core/data/repository/ClientChargeRepository.kt (57%) rename core/data/src/{main/java => commonMain/kotlin}/org/mifos/mobile/core/data/repository/ClientRepository.kt (66%) rename core/data/src/{main/java => commonMain/kotlin}/org/mifos/mobile/core/data/repository/GuarantorRepository.kt (66%) rename core/data/src/{main/java => commonMain/kotlin}/org/mifos/mobile/core/data/repository/HomeRepository.kt (61%) rename core/data/src/{main/java => commonMain/kotlin}/org/mifos/mobile/core/data/repository/LoanRepository.kt (75%) rename core/data/src/{main/java => commonMain/kotlin}/org/mifos/mobile/core/data/repository/NotificationRepository.kt (80%) rename core/data/src/{main/java => commonMain/kotlin}/org/mifos/mobile/core/data/repository/RecentTransactionRepository.kt (81%) rename core/data/src/{main/java => commonMain/kotlin}/org/mifos/mobile/core/data/repository/ReviewLoanApplicationRepository.kt (87%) rename core/data/src/{main/java => commonMain/kotlin}/org/mifos/mobile/core/data/repository/SavingsAccountRepository.kt (78%) rename core/data/src/{main/java => commonMain/kotlin}/org/mifos/mobile/core/data/repository/ThirdPartyTransferRepository.kt (81%) rename core/data/src/{main/java => commonMain/kotlin}/org/mifos/mobile/core/data/repository/TransferRepository.kt (91%) rename core/data/src/{main/java => commonMain/kotlin}/org/mifos/mobile/core/data/repository/UserAuthRepository.kt (80%) rename core/data/src/{main/java => commonMain/kotlin}/org/mifos/mobile/core/data/repository/UserDataRepository.kt (80%) rename core/data/src/{main/java => commonMain/kotlin}/org/mifos/mobile/core/data/repository/UserDetailRepository.kt (69%) rename core/data/src/{main/java => commonMain/kotlin}/org/mifos/mobile/core/data/repositoryImpl/AccountsRepositoryImp.kt (57%) create mode 100644 core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/AuthenticationUserRepository.kt create mode 100644 core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/BeneficiaryRepositoryImp.kt rename core/data/src/{main/java => commonMain/kotlin}/org/mifos/mobile/core/data/repositoryImpl/ClientChargeRepositoryImp.kt (66%) create mode 100644 core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/ClientRepositoryImp.kt create mode 100644 core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/GuarantorRepositoryImp.kt create mode 100644 core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/HomeRepositoryImp.kt create mode 100644 core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/LoanRepositoryImp.kt rename core/data/src/{main/java => commonMain/kotlin}/org/mifos/mobile/core/data/repositoryImpl/NotificationRepositoryImp.kt (91%) rename core/data/src/{main/java => commonMain/kotlin}/org/mifos/mobile/core/data/repositoryImpl/RecentTransactionRepositoryImp.kt (57%) rename core/data/src/{main/java => commonMain/kotlin}/org/mifos/mobile/core/data/repositoryImpl/ReviewLoanApplicationRepositoryImpl.kt (56%) create mode 100644 core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/SavingsAccountRepositoryImp.kt rename core/data/src/{main/java => commonMain/kotlin}/org/mifos/mobile/core/data/repositoryImpl/ThirdPartyTransferRepositoryImp.kt (59%) create mode 100644 core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/TransferRepositoryImp.kt create mode 100644 core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/UserAuthRepositoryImp.kt create mode 100644 core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/UserDetailRepositoryImp.kt rename core/data/src/{main/java/org/mifos/mobile/core/data/utils => commonMain/kotlin/org/mifos/mobile/core/data/util}/NetworkMonitor.kt (85%) create mode 100644 core/data/src/desktopMain/kotlin/org/mifos/mobile/core/data/JsPlatformDependentDataModule.kt create mode 100644 core/data/src/desktopMain/kotlin/org/mifos/mobile/core/data/di/PlatformDependentDataModule.desktop.kt create mode 100644 core/data/src/jsMain/kotlin/org/mifos/mobile/core/data/JsPlatformDependentDataModule.kt create mode 100644 core/data/src/jsMain/kotlin/org/mifos/mobile/core/data/di/PlatformDependentDataModule.js.kt delete mode 100644 core/data/src/main/java/org/mifos/mobile/core/data/di/RepositoryModule.kt delete mode 100644 core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/AuthenticationUserRepository.kt delete mode 100644 core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/BeneficiaryRepositoryImp.kt delete mode 100644 core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/ClientRepositoryImp.kt delete mode 100644 core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/GuarantorRepositoryImp.kt delete mode 100644 core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/HomeRepositoryImp.kt delete mode 100644 core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/LoanRepositoryImp.kt delete mode 100644 core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/SavingsAccountRepositoryImp.kt delete mode 100644 core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/TransferRepositoryImp.kt delete mode 100644 core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/UserAuthRepositoryImp.kt delete mode 100644 core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/UserDetailRepositoryImp.kt create mode 100644 core/data/src/nativeMain/kotlin/org/mifos/mobile/core/data/NativePlatformDependentDataModule.kt create mode 100644 core/data/src/nativeMain/kotlin/org/mifos/mobile/core/data/di/PlatformDependentDataModule.native.kt create mode 100644 core/data/src/wasmJsMain/kotlin/org/mifos/mobile/core/data/JsPlatformDependentDataModule.kt create mode 100644 core/data/src/wasmJsMain/kotlin/org/mifos/mobile/core/data/di/PlatformDependentDataModule.wasmJs.kt diff --git a/androidApp/dependencies/demoDebugRuntimeClasspath.txt b/androidApp/dependencies/demoDebugRuntimeClasspath.txt index 8a10a41f0..48fd55259 100644 --- a/androidApp/dependencies/demoDebugRuntimeClasspath.txt +++ b/androidApp/dependencies/demoDebugRuntimeClasspath.txt @@ -195,11 +195,18 @@ com.russhwolf:multiplatform-settings-no-arg:1.2.0 com.russhwolf:multiplatform-settings-serialization-android-debug:1.2.0 com.russhwolf:multiplatform-settings-serialization:1.2.0 com.russhwolf:multiplatform-settings:1.2.0 +com.squareup.okhttp3:okhttp-sse:4.12.0 com.squareup.okhttp3:okhttp:4.12.0 com.squareup.okio:okio-jvm:3.9.1 com.squareup.okio:okio:3.9.1 com.squareup.retrofit2:converter-gson:2.11.0 com.squareup.retrofit2:retrofit:2.11.0 +de.jensklingenberg.ktorfit:ktorfit-annotations-android-debug:2.2.0 +de.jensklingenberg.ktorfit:ktorfit-annotations:2.2.0 +de.jensklingenberg.ktorfit:ktorfit-lib-android-debug:2.2.0 +de.jensklingenberg.ktorfit:ktorfit-lib-light-android-debug:2.2.0 +de.jensklingenberg.ktorfit:ktorfit-lib-light:2.2.0 +de.jensklingenberg.ktorfit:ktorfit-lib:2.2.0 dev.chrisbanes.material3:material3-window-size-class-multiplatform-android:0.5.0 dev.chrisbanes.material3:material3-window-size-class-multiplatform:0.5.0 dev.chrisbanes.snapper:snapper:0.2.2 @@ -250,8 +257,6 @@ io.ktor:ktor-websockets:3.0.1 io.michaelrocks:libphonenumber-android:8.13.35 jakarta.inject:jakarta.inject-api:2.0.1 javax.inject:javax.inject:1 -net.bytebuddy:byte-buddy-agent:1.14.8 -net.bytebuddy:byte-buddy:1.14.8 org.checkerframework:checker-qual:3.12.0 org.jetbrains.androidx.core:core-bundle-android-debug:1.0.1 org.jetbrains.androidx.core:core-bundle:1.0.1 @@ -301,8 +306,6 @@ org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.10.1 org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1 org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.10.1 org.jetbrains.kotlinx:kotlinx-coroutines-slf4j:1.10.1 -org.jetbrains.kotlinx:kotlinx-coroutines-test-jvm:1.10.1 -org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1 org.jetbrains.kotlinx:kotlinx-datetime-jvm:0.6.1 org.jetbrains.kotlinx:kotlinx-datetime:0.6.1 org.jetbrains.kotlinx:kotlinx-io-bytestring-jvm:0.5.4 @@ -312,10 +315,10 @@ org.jetbrains.kotlinx:kotlinx-io-core:0.5.4 org.jetbrains.kotlinx:kotlinx-serialization-bom:1.7.3 org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.7.3 org.jetbrains.kotlinx:kotlinx-serialization-core:1.7.3 +org.jetbrains.kotlinx:kotlinx-serialization-json-io-jvm:1.7.3 +org.jetbrains.kotlinx:kotlinx-serialization-json-io:1.7.3 org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.7.3 org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3 org.jetbrains:annotations:23.0.0 org.jspecify:jspecify:1.0.0 -org.mockito:mockito-core:5.6.0 -org.objenesis:objenesis:3.3 org.slf4j:slf4j-api:2.0.16 diff --git a/androidApp/dependencies/demoReleaseRuntimeClasspath.txt b/androidApp/dependencies/demoReleaseRuntimeClasspath.txt index 96c9c7de9..0e527bafe 100644 --- a/androidApp/dependencies/demoReleaseRuntimeClasspath.txt +++ b/androidApp/dependencies/demoReleaseRuntimeClasspath.txt @@ -190,6 +190,7 @@ com.russhwolf:multiplatform-settings-no-arg:1.2.0 com.russhwolf:multiplatform-settings-serialization-android:1.2.0 com.russhwolf:multiplatform-settings-serialization:1.2.0 com.russhwolf:multiplatform-settings:1.2.0 +com.squareup.okhttp3:okhttp-sse:4.12.0 com.squareup.okhttp3:okhttp:4.12.0 com.squareup.okio:okio-jvm:3.9.1 com.squareup.okio:okio:3.9.1 @@ -197,6 +198,12 @@ com.squareup.retrofit2:converter-gson:2.11.0 com.squareup.retrofit2:retrofit:2.11.0 dev.chrisbanes.material3:material3-window-size-class-multiplatform-android:0.5.0 dev.chrisbanes.material3:material3-window-size-class-multiplatform:0.5.0 +de.jensklingenberg.ktorfit:ktorfit-annotations-android:2.2.0 +de.jensklingenberg.ktorfit:ktorfit-annotations:2.2.0 +de.jensklingenberg.ktorfit:ktorfit-lib-android:2.2.0 +de.jensklingenberg.ktorfit:ktorfit-lib-light-android:2.2.0 +de.jensklingenberg.ktorfit:ktorfit-lib-light:2.2.0 +de.jensklingenberg.ktorfit:ktorfit-lib:2.2.0 dev.chrisbanes.snapper:snapper:0.2.2 io.coil-kt.coil3:coil-android:3.0.4 io.coil-kt.coil3:coil-compose-core-android:3.0.4 @@ -224,29 +231,43 @@ io.insert-koin:koin-core-jvm:4.0.1-RC1 io.insert-koin:koin-core-viewmodel-jvm:4.0.1-RC1 io.insert-koin:koin-core-viewmodel:4.0.1-RC1 io.insert-koin:koin-core:4.0.1-RC1 -io.ktor:ktor-client-core-jvm:3.0.1 -io.ktor:ktor-client-core:3.0.1 -io.ktor:ktor-events-jvm:3.0.1 -io.ktor:ktor-events:3.0.1 -io.ktor:ktor-http-jvm:3.0.1 -io.ktor:ktor-http:3.0.1 -io.ktor:ktor-io-jvm:3.0.1 -io.ktor:ktor-io:3.0.1 -io.ktor:ktor-serialization-jvm:3.0.1 -io.ktor:ktor-serialization:3.0.1 -io.ktor:ktor-sse-jvm:3.0.1 -io.ktor:ktor-sse:3.0.1 -io.ktor:ktor-utils-jvm:3.0.1 -io.ktor:ktor-utils:3.0.1 -io.ktor:ktor-websocket-serialization-jvm:3.0.1 -io.ktor:ktor-websocket-serialization:3.0.1 -io.ktor:ktor-websockets-jvm:3.0.1 -io.ktor:ktor-websockets:3.0.1 +io.ktor:ktor-client-auth-jvm:3.0.3 +io.ktor:ktor-client-auth:3.0.3 +io.ktor:ktor-client-content-negotiation-jvm:3.0.3 +io.ktor:ktor-client-content-negotiation:3.0.3 +io.ktor:ktor-client-core-jvm:3.0.3 +io.ktor:ktor-client-core:3.0.3 +io.ktor:ktor-client-json-jvm:3.0.3 +io.ktor:ktor-client-json:3.0.3 +io.ktor:ktor-client-logging-jvm:3.0.3 +io.ktor:ktor-client-logging:3.0.3 +io.ktor:ktor-client-okhttp-jvm:3.0.3 +io.ktor:ktor-client-okhttp:3.0.3 +io.ktor:ktor-client-serialization-jvm:3.0.3 +io.ktor:ktor-client-serialization:3.0.3 +io.ktor:ktor-events-jvm:3.0.3 +io.ktor:ktor-events:3.0.3 +io.ktor:ktor-http-jvm:3.0.3 +io.ktor:ktor-http:3.0.3 +io.ktor:ktor-io-jvm:3.0.3 +io.ktor:ktor-io:3.0.3 +io.ktor:ktor-serialization-jvm:3.0.3 +io.ktor:ktor-serialization-kotlinx-json-jvm:3.0.3 +io.ktor:ktor-serialization-kotlinx-json:3.0.3 +io.ktor:ktor-serialization-kotlinx-jvm:3.0.3 +io.ktor:ktor-serialization-kotlinx:3.0.3 +io.ktor:ktor-serialization:3.0.3 +io.ktor:ktor-sse-jvm:3.0.3 +io.ktor:ktor-sse:3.0.3 +io.ktor:ktor-utils-jvm:3.0.3 +io.ktor:ktor-utils:3.0.3 +io.ktor:ktor-websocket-serialization-jvm:3.0.3 +io.ktor:ktor-websocket-serialization:3.0.3 +io.ktor:ktor-websockets-jvm:3.0.3 +io.ktor:ktor-websockets:3.0.3 io.michaelrocks:libphonenumber-android:8.13.35 jakarta.inject:jakarta.inject-api:2.0.1 javax.inject:javax.inject:1 -net.bytebuddy:byte-buddy-agent:1.14.8 -net.bytebuddy:byte-buddy:1.14.8 org.checkerframework:checker-qual:3.12.0 org.jetbrains.androidx.core:core-bundle-android:1.0.1 org.jetbrains.androidx.core:core-bundle:1.0.1 @@ -283,6 +304,7 @@ org.jetbrains.compose.ui:ui-util:1.7.0-rc01 org.jetbrains.compose.ui:ui:1.7.0-rc01 org.jetbrains.kotlin:kotlin-android-extensions-runtime:2.1.0 org.jetbrains.kotlin:kotlin-parcelize-runtime:2.1.0 +org.jetbrains.kotlin:kotlin-stdlib-common:2.1.0 org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.23 org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22 org.jetbrains.kotlin:kotlin-stdlib:2.1.0 @@ -296,8 +318,6 @@ org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.10.1 org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1 org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.10.1 org.jetbrains.kotlinx:kotlinx-coroutines-slf4j:1.10.1 -org.jetbrains.kotlinx:kotlinx-coroutines-test-jvm:1.10.1 -org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1 org.jetbrains.kotlinx:kotlinx-datetime-jvm:0.6.1 org.jetbrains.kotlinx:kotlinx-datetime:0.6.1 org.jetbrains.kotlinx:kotlinx-io-bytestring-jvm:0.5.4 @@ -307,10 +327,10 @@ org.jetbrains.kotlinx:kotlinx-io-core:0.5.4 org.jetbrains.kotlinx:kotlinx-serialization-bom:1.7.3 org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.7.3 org.jetbrains.kotlinx:kotlinx-serialization-core:1.7.3 +org.jetbrains.kotlinx:kotlinx-serialization-json-io-jvm:1.7.3 +org.jetbrains.kotlinx:kotlinx-serialization-json-io:1.7.3 org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.7.3 org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3 org.jetbrains:annotations:23.0.0 org.jspecify:jspecify:1.0.0 -org.mockito:mockito-core:5.6.0 -org.objenesis:objenesis:3.3 org.slf4j:slf4j-api:2.0.16 diff --git a/androidApp/dependencies/prodDebugRuntimeClasspath.txt b/androidApp/dependencies/prodDebugRuntimeClasspath.txt index 8a10a41f0..3b88adf6b 100644 --- a/androidApp/dependencies/prodDebugRuntimeClasspath.txt +++ b/androidApp/dependencies/prodDebugRuntimeClasspath.txt @@ -195,11 +195,18 @@ com.russhwolf:multiplatform-settings-no-arg:1.2.0 com.russhwolf:multiplatform-settings-serialization-android-debug:1.2.0 com.russhwolf:multiplatform-settings-serialization:1.2.0 com.russhwolf:multiplatform-settings:1.2.0 +com.squareup.okhttp3:okhttp-sse:4.12.0 com.squareup.okhttp3:okhttp:4.12.0 com.squareup.okio:okio-jvm:3.9.1 com.squareup.okio:okio:3.9.1 com.squareup.retrofit2:converter-gson:2.11.0 com.squareup.retrofit2:retrofit:2.11.0 +de.jensklingenberg.ktorfit:ktorfit-annotations-android-debug:2.2.0 +de.jensklingenberg.ktorfit:ktorfit-annotations:2.2.0 +de.jensklingenberg.ktorfit:ktorfit-lib-android-debug:2.2.0 +de.jensklingenberg.ktorfit:ktorfit-lib-light-android-debug:2.2.0 +de.jensklingenberg.ktorfit:ktorfit-lib-light:2.2.0 +de.jensklingenberg.ktorfit:ktorfit-lib:2.2.0 dev.chrisbanes.material3:material3-window-size-class-multiplatform-android:0.5.0 dev.chrisbanes.material3:material3-window-size-class-multiplatform:0.5.0 dev.chrisbanes.snapper:snapper:0.2.2 @@ -229,24 +236,40 @@ io.insert-koin:koin-core-jvm:4.0.1-RC1 io.insert-koin:koin-core-viewmodel-jvm:4.0.1-RC1 io.insert-koin:koin-core-viewmodel:4.0.1-RC1 io.insert-koin:koin-core:4.0.1-RC1 -io.ktor:ktor-client-core-jvm:3.0.1 -io.ktor:ktor-client-core:3.0.1 -io.ktor:ktor-events-jvm:3.0.1 -io.ktor:ktor-events:3.0.1 -io.ktor:ktor-http-jvm:3.0.1 -io.ktor:ktor-http:3.0.1 -io.ktor:ktor-io-jvm:3.0.1 -io.ktor:ktor-io:3.0.1 -io.ktor:ktor-serialization-jvm:3.0.1 -io.ktor:ktor-serialization:3.0.1 -io.ktor:ktor-sse-jvm:3.0.1 -io.ktor:ktor-sse:3.0.1 -io.ktor:ktor-utils-jvm:3.0.1 -io.ktor:ktor-utils:3.0.1 -io.ktor:ktor-websocket-serialization-jvm:3.0.1 -io.ktor:ktor-websocket-serialization:3.0.1 -io.ktor:ktor-websockets-jvm:3.0.1 -io.ktor:ktor-websockets:3.0.1 +io.ktor:ktor-client-auth-jvm:3.0.3 +io.ktor:ktor-client-auth:3.0.3 +io.ktor:ktor-client-content-negotiation-jvm:3.0.3 +io.ktor:ktor-client-content-negotiation:3.0.3 +io.ktor:ktor-client-core-jvm:3.0.3 +io.ktor:ktor-client-core:3.0.3 +io.ktor:ktor-client-json-jvm:3.0.3 +io.ktor:ktor-client-json:3.0.3 +io.ktor:ktor-client-logging-jvm:3.0.3 +io.ktor:ktor-client-logging:3.0.3 +io.ktor:ktor-client-okhttp-jvm:3.0.3 +io.ktor:ktor-client-okhttp:3.0.3 +io.ktor:ktor-client-serialization-jvm:3.0.3 +io.ktor:ktor-client-serialization:3.0.3 +io.ktor:ktor-events-jvm:3.0.3 +io.ktor:ktor-events:3.0.3 +io.ktor:ktor-http-jvm:3.0.3 +io.ktor:ktor-http:3.0.3 +io.ktor:ktor-io-jvm:3.0.3 +io.ktor:ktor-io:3.0.3 +io.ktor:ktor-serialization-jvm:3.0.3 +io.ktor:ktor-serialization-kotlinx-json-jvm:3.0.3 +io.ktor:ktor-serialization-kotlinx-json:3.0.3 +io.ktor:ktor-serialization-kotlinx-jvm:3.0.3 +io.ktor:ktor-serialization-kotlinx:3.0.3 +io.ktor:ktor-serialization:3.0.3 +io.ktor:ktor-sse-jvm:3.0.3 +io.ktor:ktor-sse:3.0.3 +io.ktor:ktor-utils-jvm:3.0.3 +io.ktor:ktor-utils:3.0.3 +io.ktor:ktor-websocket-serialization-jvm:3.0.3 +io.ktor:ktor-websocket-serialization:3.0.3 +io.ktor:ktor-websockets-jvm:3.0.3 +io.ktor:ktor-websockets:3.0.3 io.michaelrocks:libphonenumber-android:8.13.35 jakarta.inject:jakarta.inject-api:2.0.1 javax.inject:javax.inject:1 @@ -288,6 +311,7 @@ org.jetbrains.compose.ui:ui-util:1.7.0-rc01 org.jetbrains.compose.ui:ui:1.7.0-rc01 org.jetbrains.kotlin:kotlin-android-extensions-runtime:2.1.0 org.jetbrains.kotlin:kotlin-parcelize-runtime:2.1.0 +org.jetbrains.kotlin:kotlin-stdlib-common:2.1.0 org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.23 org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22 org.jetbrains.kotlin:kotlin-stdlib:2.1.0 @@ -301,8 +325,6 @@ org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.10.1 org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1 org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.10.1 org.jetbrains.kotlinx:kotlinx-coroutines-slf4j:1.10.1 -org.jetbrains.kotlinx:kotlinx-coroutines-test-jvm:1.10.1 -org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1 org.jetbrains.kotlinx:kotlinx-datetime-jvm:0.6.1 org.jetbrains.kotlinx:kotlinx-datetime:0.6.1 org.jetbrains.kotlinx:kotlinx-io-bytestring-jvm:0.5.4 @@ -312,10 +334,10 @@ org.jetbrains.kotlinx:kotlinx-io-core:0.5.4 org.jetbrains.kotlinx:kotlinx-serialization-bom:1.7.3 org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.7.3 org.jetbrains.kotlinx:kotlinx-serialization-core:1.7.3 +org.jetbrains.kotlinx:kotlinx-serialization-json-io-jvm:1.7.3 +org.jetbrains.kotlinx:kotlinx-serialization-json-io:1.7.3 org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.7.3 org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3 org.jetbrains:annotations:23.0.0 org.jspecify:jspecify:1.0.0 -org.mockito:mockito-core:5.6.0 -org.objenesis:objenesis:3.3 org.slf4j:slf4j-api:2.0.16 diff --git a/androidApp/dependencies/prodReleaseRuntimeClasspath.txt b/androidApp/dependencies/prodReleaseRuntimeClasspath.txt index 96c9c7de9..bdd40d9c1 100644 --- a/androidApp/dependencies/prodReleaseRuntimeClasspath.txt +++ b/androidApp/dependencies/prodReleaseRuntimeClasspath.txt @@ -190,11 +190,18 @@ com.russhwolf:multiplatform-settings-no-arg:1.2.0 com.russhwolf:multiplatform-settings-serialization-android:1.2.0 com.russhwolf:multiplatform-settings-serialization:1.2.0 com.russhwolf:multiplatform-settings:1.2.0 +com.squareup.okhttp3:okhttp-sse:4.12.0 com.squareup.okhttp3:okhttp:4.12.0 com.squareup.okio:okio-jvm:3.9.1 com.squareup.okio:okio:3.9.1 com.squareup.retrofit2:converter-gson:2.11.0 com.squareup.retrofit2:retrofit:2.11.0 +de.jensklingenberg.ktorfit:ktorfit-annotations-android:2.2.0 +de.jensklingenberg.ktorfit:ktorfit-annotations:2.2.0 +de.jensklingenberg.ktorfit:ktorfit-lib-android:2.2.0 +de.jensklingenberg.ktorfit:ktorfit-lib-light-android:2.2.0 +de.jensklingenberg.ktorfit:ktorfit-lib-light:2.2.0 +de.jensklingenberg.ktorfit:ktorfit-lib:2.2.0 dev.chrisbanes.material3:material3-window-size-class-multiplatform-android:0.5.0 dev.chrisbanes.material3:material3-window-size-class-multiplatform:0.5.0 dev.chrisbanes.snapper:snapper:0.2.2 @@ -224,24 +231,40 @@ io.insert-koin:koin-core-jvm:4.0.1-RC1 io.insert-koin:koin-core-viewmodel-jvm:4.0.1-RC1 io.insert-koin:koin-core-viewmodel:4.0.1-RC1 io.insert-koin:koin-core:4.0.1-RC1 -io.ktor:ktor-client-core-jvm:3.0.1 -io.ktor:ktor-client-core:3.0.1 -io.ktor:ktor-events-jvm:3.0.1 -io.ktor:ktor-events:3.0.1 -io.ktor:ktor-http-jvm:3.0.1 -io.ktor:ktor-http:3.0.1 -io.ktor:ktor-io-jvm:3.0.1 -io.ktor:ktor-io:3.0.1 -io.ktor:ktor-serialization-jvm:3.0.1 -io.ktor:ktor-serialization:3.0.1 -io.ktor:ktor-sse-jvm:3.0.1 -io.ktor:ktor-sse:3.0.1 -io.ktor:ktor-utils-jvm:3.0.1 -io.ktor:ktor-utils:3.0.1 -io.ktor:ktor-websocket-serialization-jvm:3.0.1 -io.ktor:ktor-websocket-serialization:3.0.1 -io.ktor:ktor-websockets-jvm:3.0.1 -io.ktor:ktor-websockets:3.0.1 +io.ktor:ktor-client-auth-jvm:3.0.3 +io.ktor:ktor-client-auth:3.0.3 +io.ktor:ktor-client-content-negotiation-jvm:3.0.3 +io.ktor:ktor-client-content-negotiation:3.0.3 +io.ktor:ktor-client-core-jvm:3.0.3 +io.ktor:ktor-client-core:3.0.3 +io.ktor:ktor-client-json-jvm:3.0.3 +io.ktor:ktor-client-json:3.0.3 +io.ktor:ktor-client-logging-jvm:3.0.3 +io.ktor:ktor-client-logging:3.0.3 +io.ktor:ktor-client-okhttp-jvm:3.0.3 +io.ktor:ktor-client-okhttp:3.0.3 +io.ktor:ktor-client-serialization-jvm:3.0.3 +io.ktor:ktor-client-serialization:3.0.3 +io.ktor:ktor-events-jvm:3.0.3 +io.ktor:ktor-events:3.0.3 +io.ktor:ktor-http-jvm:3.0.3 +io.ktor:ktor-http:3.0.3 +io.ktor:ktor-io-jvm:3.0.3 +io.ktor:ktor-io:3.0.3 +io.ktor:ktor-serialization-jvm:3.0.3 +io.ktor:ktor-serialization-kotlinx-json-jvm:3.0.3 +io.ktor:ktor-serialization-kotlinx-json:3.0.3 +io.ktor:ktor-serialization-kotlinx-jvm:3.0.3 +io.ktor:ktor-serialization-kotlinx:3.0.3 +io.ktor:ktor-serialization:3.0.3 +io.ktor:ktor-sse-jvm:3.0.3 +io.ktor:ktor-sse:3.0.3 +io.ktor:ktor-utils-jvm:3.0.3 +io.ktor:ktor-utils:3.0.3 +io.ktor:ktor-websocket-serialization-jvm:3.0.3 +io.ktor:ktor-websocket-serialization:3.0.3 +io.ktor:ktor-websockets-jvm:3.0.3 +io.ktor:ktor-websockets:3.0.3 io.michaelrocks:libphonenumber-android:8.13.35 jakarta.inject:jakarta.inject-api:2.0.1 javax.inject:javax.inject:1 @@ -283,6 +306,7 @@ org.jetbrains.compose.ui:ui-util:1.7.0-rc01 org.jetbrains.compose.ui:ui:1.7.0-rc01 org.jetbrains.kotlin:kotlin-android-extensions-runtime:2.1.0 org.jetbrains.kotlin:kotlin-parcelize-runtime:2.1.0 +org.jetbrains.kotlin:kotlin-stdlib-common:2.1.0 org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.23 org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22 org.jetbrains.kotlin:kotlin-stdlib:2.1.0 @@ -307,10 +331,10 @@ org.jetbrains.kotlinx:kotlinx-io-core:0.5.4 org.jetbrains.kotlinx:kotlinx-serialization-bom:1.7.3 org.jetbrains.kotlinx:kotlinx-serialization-core-jvm:1.7.3 org.jetbrains.kotlinx:kotlinx-serialization-core:1.7.3 +org.jetbrains.kotlinx:kotlinx-serialization-json-io-jvm:1.7.3 +org.jetbrains.kotlinx:kotlinx-serialization-json-io:1.7.3 org.jetbrains.kotlinx:kotlinx-serialization-json-jvm:1.7.3 org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3 org.jetbrains:annotations:23.0.0 org.jspecify:jspecify:1.0.0 -org.mockito:mockito-core:5.6.0 -org.objenesis:objenesis:3.3 org.slf4j:slf4j-api:2.0.16 diff --git a/core/data/build.gradle.kts b/core/data/build.gradle.kts index b4c71445d..f831942a3 100644 --- a/core/data/build.gradle.kts +++ b/core/data/build.gradle.kts @@ -8,10 +8,9 @@ * See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md */ plugins { - alias(libs.plugins.mifos.android.library) - alias(libs.plugins.mifos.android.hilt) + alias(libs.plugins.mifos.kmp.library) alias(libs.plugins.kotlin.parcelize) - alias(libs.plugins.kotlin.serialization) + id("kotlinx-serialization") } android { @@ -24,27 +23,26 @@ android { } } - defaultConfig { - consumerProguardFiles("consumer-rules.pro") - } +// defaultConfig { +// consumerProguardFiles("consumer-rules.pro") +// } } -dependencies { - api(projects.core.common) -// api(projects.core.model) -// api(projects.core.network) - api(projects.core.database) - api(projects.core.datastore) - - implementation(libs.squareup.retrofit2) - implementation(libs.squareup.okhttp) - implementation(libs.mockito.core) - implementation(libs.turbine) - - testImplementation(projects.core.testing) - testImplementation(libs.junit) - testImplementation(libs.mockito.core) - testImplementation(libs.turbine) - testImplementation(libs.kotlinx.coroutines.test) +kotlin { + sourceSets { + commonMain.dependencies { + api(projects.core.common) + api(projects.core.datastore) + api(projects.core.model) +// api(projects.core.database) + implementation(projects.core.network) + implementation(libs.kotlinx.serialization.json) + } + androidMain.dependencies { + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.tracing.ktx) + implementation(libs.koin.android) + } + } } \ No newline at end of file diff --git a/core/data/src/main/AndroidManifest.xml b/core/data/src/androidMain/AndroidManifest.xml similarity index 100% rename from core/data/src/main/AndroidManifest.xml rename to core/data/src/androidMain/AndroidManifest.xml diff --git a/core/data/src/androidMain/kotlin/org/mifos/mobile/core/data/di/AndroidPlatformDependentDataModule.kt b/core/data/src/androidMain/kotlin/org/mifos/mobile/core/data/di/AndroidPlatformDependentDataModule.kt new file mode 100644 index 000000000..041eab53d --- /dev/null +++ b/core/data/src/androidMain/kotlin/org/mifos/mobile/core/data/di/AndroidPlatformDependentDataModule.kt @@ -0,0 +1,24 @@ +/* + * 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/mobile-mobile/blob/master/LICENSE.md + */ +package org.mifos.mobile.core.data.di + +import android.content.Context +import kotlinx.coroutines.CoroutineDispatcher +import org.mifos.mobile.core.data.util.ConnectivityManagerNetworkMonitor +import org.mifos.mobile.core.data.util.NetworkMonitor + +class AndroidPlatformDependentDataModule( + private val context: Context, + private val dispatcher: CoroutineDispatcher, +) : PlatformDependentDataModule { + override val networkMonitor: NetworkMonitor by lazy { + ConnectivityManagerNetworkMonitor(context, dispatcher) + } +} diff --git a/core/data/src/androidMain/kotlin/org/mifos/mobile/core/data/di/AndroidPlatformModule.kt b/core/data/src/androidMain/kotlin/org/mifos/mobile/core/data/di/AndroidPlatformModule.kt new file mode 100644 index 000000000..e7af799a4 --- /dev/null +++ b/core/data/src/androidMain/kotlin/org/mifos/mobile/core/data/di/AndroidPlatformModule.kt @@ -0,0 +1,36 @@ +/* + * 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/mobile-mobile/blob/master/LICENSE.md + */ +package org.mifos.mobile.core.data.di + +import org.koin.android.ext.koin.androidContext +import org.koin.core.module.Module +import org.koin.core.qualifier.named +import org.koin.dsl.module +import org.mifos.mobile.core.common.MifosDispatchers +import org.mifos.mobile.core.data.util.ConnectivityManagerNetworkMonitor +import org.mifos.mobile.core.data.util.NetworkMonitor + +val AndroidDataModule = module { + single { + ConnectivityManagerNetworkMonitor(androidContext(), get(named(MifosDispatchers.IO.name))) + } + + single { + AndroidPlatformDependentDataModule( + context = androidContext(), + dispatcher = get(named(MifosDispatchers.IO.name)), + ) + } +} + +actual val platformModule: Module = AndroidDataModule + +actual val getPlatformDataModule: PlatformDependentDataModule + get() = org.koin.core.context.GlobalContext.get().get() diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/utils/ConnectivityManagerNetworkMonitor.kt b/core/data/src/androidMain/kotlin/org/mifos/mobile/core/data/util/ConnectivityManagerNetworkMonitor.kt similarity index 89% rename from core/data/src/main/java/org/mifos/mobile/core/data/utils/ConnectivityManagerNetworkMonitor.kt rename to core/data/src/androidMain/kotlin/org/mifos/mobile/core/data/util/ConnectivityManagerNetworkMonitor.kt index ee1aa6a23..fdb32c54a 100644 --- a/core/data/src/main/java/org/mifos/mobile/core/data/utils/ConnectivityManagerNetworkMonitor.kt +++ b/core/data/src/androidMain/kotlin/org/mifos/mobile/core/data/util/ConnectivityManagerNetworkMonitor.kt @@ -7,7 +7,7 @@ * * See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md */ -package org.mifos.mobile.core.data.utils +package org.mifos.mobile.core.data.util import android.content.Context import android.net.ConnectivityManager @@ -17,15 +17,16 @@ import android.net.NetworkCapabilities import android.net.NetworkRequest import android.net.NetworkRequest.Builder import androidx.core.content.getSystemService -import dagger.hilt.android.qualifiers.ApplicationContext +import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.callbackFlow import kotlinx.coroutines.flow.conflate -import javax.inject.Inject +import kotlinx.coroutines.flow.flowOn -class ConnectivityManagerNetworkMonitor @Inject constructor( - @ApplicationContext private val context: Context, +internal class ConnectivityManagerNetworkMonitor( + private val context: Context, + ioDispatcher: CoroutineDispatcher, ) : NetworkMonitor { override val isOnline: Flow = callbackFlow { val connectivityManager = context.getSystemService() @@ -53,12 +54,10 @@ class ConnectivityManagerNetworkMonitor @Inject constructor( channel.trySend(networks.isNotEmpty()) } } - val request = Builder() .addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) .build() connectivityManager.registerNetworkCallback(request, callback) - /** * Sends the latest connectivity status to the underlying channel. */ @@ -68,6 +67,7 @@ class ConnectivityManagerNetworkMonitor @Inject constructor( connectivityManager.unregisterNetworkCallback(callback) } } + .flowOn(ioDispatcher) .conflate() private fun ConnectivityManager.isCurrentlyConnected() = activeNetwork diff --git a/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/di/PlatformDependentDataModule.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/di/PlatformDependentDataModule.kt new file mode 100644 index 000000000..7b6642370 --- /dev/null +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/di/PlatformDependentDataModule.kt @@ -0,0 +1,21 @@ +/* + * 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/mobile-mobile/blob/master/LICENSE.md + */ +package org.mifos.mobile.core.data.di + +import org.koin.core.module.Module +import org.mifos.mobile.core.data.util.NetworkMonitor + +interface PlatformDependentDataModule { + val networkMonitor: NetworkMonitor +} + +expect val platformModule: Module + +expect val getPlatformDataModule: PlatformDependentDataModule diff --git a/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/di/RepositoryModule.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/di/RepositoryModule.kt new file mode 100644 index 000000000..d21829293 --- /dev/null +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/di/RepositoryModule.kt @@ -0,0 +1,75 @@ +/* + * 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/mobile-mobile/blob/master/LICENSE.md + */ +package org.mifos.mobile.core.data.di + +import kotlinx.serialization.json.Json +import org.koin.core.qualifier.named +import org.koin.dsl.module +import org.mifos.mobile.core.common.MifosDispatchers +import org.mifos.mobile.core.data.repository.AccountsRepository +import org.mifos.mobile.core.data.repository.BeneficiaryRepository +import org.mifos.mobile.core.data.repository.ClientChargeRepository +import org.mifos.mobile.core.data.repository.ClientRepository +import org.mifos.mobile.core.data.repository.GuarantorRepository +import org.mifos.mobile.core.data.repository.HomeRepository +import org.mifos.mobile.core.data.repository.LoanRepository +import org.mifos.mobile.core.data.repository.NotificationRepository +import org.mifos.mobile.core.data.repository.RecentTransactionRepository +import org.mifos.mobile.core.data.repository.ReviewLoanApplicationRepository +import org.mifos.mobile.core.data.repository.SavingsAccountRepository +import org.mifos.mobile.core.data.repository.ThirdPartyTransferRepository +import org.mifos.mobile.core.data.repository.TransferRepository +import org.mifos.mobile.core.data.repository.UserAuthRepository +import org.mifos.mobile.core.data.repository.UserDataRepository +import org.mifos.mobile.core.data.repository.UserDetailRepository +import org.mifos.mobile.core.data.repositoryImpl.AccountsRepositoryImp +import org.mifos.mobile.core.data.repositoryImpl.AuthenticationUserRepository +import org.mifos.mobile.core.data.repositoryImpl.BeneficiaryRepositoryImp +import org.mifos.mobile.core.data.repositoryImpl.ClientChargeRepositoryImp +import org.mifos.mobile.core.data.repositoryImpl.ClientRepositoryImp +import org.mifos.mobile.core.data.repositoryImpl.GuarantorRepositoryImp +import org.mifos.mobile.core.data.repositoryImpl.HomeRepositoryImp +import org.mifos.mobile.core.data.repositoryImpl.LoanRepositoryImp +import org.mifos.mobile.core.data.repositoryImpl.NotificationRepositoryImp +import org.mifos.mobile.core.data.repositoryImpl.RecentTransactionRepositoryImp +import org.mifos.mobile.core.data.repositoryImpl.ReviewLoanApplicationRepositoryImpl +import org.mifos.mobile.core.data.repositoryImpl.SavingsAccountRepositoryImp +import org.mifos.mobile.core.data.repositoryImpl.ThirdPartyTransferRepositoryImp +import org.mifos.mobile.core.data.repositoryImpl.TransferRepositoryImp +import org.mifos.mobile.core.data.repositoryImpl.UserAuthRepositoryImp +import org.mifos.mobile.core.data.repositoryImpl.UserDetailRepositoryImp +import org.mifos.mobile.core.data.util.NetworkMonitor + +private val ioDispatcher = named(MifosDispatchers.IO.name) + +val RepositoryModule = module { + + single { Json { ignoreUnknownKeys = true } } + + single { AccountsRepositoryImp(get(), get(ioDispatcher)) } + single { AuthenticationUserRepository(get(), get(ioDispatcher)) } + single { BeneficiaryRepositoryImp(get(), get(ioDispatcher)) } + single { ClientChargeRepositoryImp(get(), get(ioDispatcher)) } // TODO + single { ClientRepositoryImp(get(), get(), get(ioDispatcher)) } + single { GuarantorRepositoryImp(get(), get(ioDispatcher)) } + single { HomeRepositoryImp(get(), get(), get(ioDispatcher)) } + single { LoanRepositoryImp(get(), get(ioDispatcher)) } + single { NotificationRepositoryImp(get(), get(ioDispatcher)) } // TODO + single { RecentTransactionRepositoryImp(get(), get(ioDispatcher)) } + single { ReviewLoanApplicationRepositoryImpl(get(), get(ioDispatcher)) } + single { SavingsAccountRepositoryImp(get(), get(ioDispatcher)) } + single { ThirdPartyTransferRepositoryImp(get(), get(ioDispatcher)) } + single { TransferRepositoryImp(get(), get(ioDispatcher)) } + single { UserAuthRepositoryImp(get(), get(ioDispatcher)) } + single { UserDetailRepositoryImp(get(), get(ioDispatcher)) } + includes(platformModule) + single { getPlatformDataModule } + single { getPlatformDataModule.networkMonitor } +} diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/model/Charge.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/model/Charge.kt similarity index 100% rename from core/data/src/main/java/org/mifos/mobile/core/data/model/Charge.kt rename to core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/model/Charge.kt diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/model/MifosNotification.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/model/MifosNotification.kt similarity index 100% rename from core/data/src/main/java/org/mifos/mobile/core/data/model/MifosNotification.kt rename to core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/model/MifosNotification.kt diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repository/AccountsRepository.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/AccountsRepository.kt similarity index 78% rename from core/data/src/main/java/org/mifos/mobile/core/data/repository/AccountsRepository.kt rename to core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/AccountsRepository.kt index 320e06212..6924e40a3 100644 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repository/AccountsRepository.kt +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/AccountsRepository.kt @@ -11,8 +11,9 @@ package org.mifos.mobile.core.data.repository import kotlinx.coroutines.flow.Flow import org.mifos.mobile.core.model.entity.client.ClientAccounts +import org.mifospay.core.common.DataState interface AccountsRepository { - fun loadAccounts(accountType: String?): Flow + fun loadAccounts(clientId: Long?, accountType: String?): Flow> } diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repository/BeneficiaryRepository.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/BeneficiaryRepository.kt similarity index 74% rename from core/data/src/main/java/org/mifos/mobile/core/data/repository/BeneficiaryRepository.kt rename to core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/BeneficiaryRepository.kt index fcb3bc06f..b6ed4e941 100644 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repository/BeneficiaryRepository.kt +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/BeneficiaryRepository.kt @@ -10,24 +10,24 @@ package org.mifos.mobile.core.data.repository import kotlinx.coroutines.flow.Flow -import okhttp3.ResponseBody import org.mifos.mobile.core.model.entity.beneficiary.Beneficiary import org.mifos.mobile.core.model.entity.beneficiary.BeneficiaryPayload import org.mifos.mobile.core.model.entity.beneficiary.BeneficiaryUpdatePayload import org.mifos.mobile.core.model.entity.templates.beneficiary.BeneficiaryTemplate +import org.mifospay.core.common.DataState interface BeneficiaryRepository { - suspend fun beneficiaryTemplate(): Flow + fun beneficiaryTemplate(): Flow> - suspend fun createBeneficiary(beneficiaryPayload: BeneficiaryPayload?): Flow + suspend fun createBeneficiary(beneficiaryPayload: BeneficiaryPayload?): DataState suspend fun updateBeneficiary( beneficiaryId: Long?, payload: BeneficiaryUpdatePayload?, - ): Flow + ): DataState - suspend fun deleteBeneficiary(beneficiaryId: Long?): Flow + suspend fun deleteBeneficiary(beneficiaryId: Long?): DataState - suspend fun beneficiaryList(): Flow> + suspend fun beneficiaryList(): Flow>> } diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repository/ClientChargeRepository.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/ClientChargeRepository.kt similarity index 57% rename from core/data/src/main/java/org/mifos/mobile/core/data/repository/ClientChargeRepository.kt rename to core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/ClientChargeRepository.kt index 390331e74..4daf8915f 100644 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repository/ClientChargeRepository.kt +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/ClientChargeRepository.kt @@ -12,15 +12,17 @@ package org.mifos.mobile.core.data.repository import kotlinx.coroutines.flow.Flow import org.mifos.mobile.core.model.entity.Charge import org.mifos.mobile.core.model.entity.Page +import org.mifospay.core.common.DataState interface ClientChargeRepository { - fun getClientCharges(clientId: Long): Flow> - fun getLoanCharges(loanId: Long): Flow> + fun getClientCharges(clientId: Long): Flow>> - fun getSavingsCharges(savingsId: Long): Flow> + fun getLoanCharges(loanId: Long): Flow>> - fun clientLocalCharges(): Flow> + fun getSavingsCharges(savingsId: Long): Flow>> - suspend fun syncCharges(charges: Page?): Page? + fun clientLocalCharges(): Flow>> + + suspend fun syncCharges(charges: Page?): DataState?> } diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repository/ClientRepository.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/ClientRepository.kt similarity index 66% rename from core/data/src/main/java/org/mifos/mobile/core/data/repository/ClientRepository.kt rename to core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/ClientRepository.kt index d26c7e9c4..ec6b58391 100644 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repository/ClientRepository.kt +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/ClientRepository.kt @@ -13,18 +13,17 @@ import kotlinx.coroutines.flow.Flow import org.mifos.mobile.core.model.entity.Page import org.mifos.mobile.core.model.entity.User import org.mifos.mobile.core.model.entity.client.Client +import org.mifospay.core.common.DataState interface ClientRepository { - suspend fun loadClient(): Flow> + fun loadClient(): Flow>> - fun saveAuthenticationTokenForSession(user: User) + suspend fun saveAuthenticationTokenForSession(user: User): DataState - fun setClientId(clientId: Long?) - - fun clearPrefHelper() + suspend fun setClientId(clientId: Long?): DataState fun reInitializeService() - fun updateAuthenticationToken(password: String) + suspend fun updateAuthenticationToken(password: String): DataState } diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repository/GuarantorRepository.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/GuarantorRepository.kt similarity index 66% rename from core/data/src/main/java/org/mifos/mobile/core/data/repository/GuarantorRepository.kt rename to core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/GuarantorRepository.kt index 07e68bea9..114ccfb6d 100644 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repository/GuarantorRepository.kt +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/GuarantorRepository.kt @@ -10,27 +10,27 @@ package org.mifos.mobile.core.data.repository import kotlinx.coroutines.flow.Flow -import okhttp3.ResponseBody import org.mifos.mobile.core.model.entity.guarantor.GuarantorApplicationPayload import org.mifos.mobile.core.model.entity.guarantor.GuarantorPayload import org.mifos.mobile.core.model.entity.guarantor.GuarantorTemplatePayload +import org.mifospay.core.common.DataState interface GuarantorRepository { - fun getGuarantorTemplate(loanId: Long?): Flow + fun getGuarantorTemplate(loanId: Long?): Flow> - fun createGuarantor( + suspend fun createGuarantor( loanId: Long?, payload: GuarantorApplicationPayload?, - ): Flow + ): DataState - fun updateGuarantor( + suspend fun updateGuarantor( payload: GuarantorApplicationPayload?, loanId: Long?, guarantorId: Long?, - ): Flow + ): DataState - fun deleteGuarantor(loanId: Long?, guarantorId: Long?): Flow + suspend fun deleteGuarantor(loanId: Long?, guarantorId: Long?): DataState - fun getGuarantorList(loanId: Long): Flow?> + fun getGuarantorList(loanId: Long): Flow?>> } diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repository/HomeRepository.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/HomeRepository.kt similarity index 61% rename from core/data/src/main/java/org/mifos/mobile/core/data/repository/HomeRepository.kt rename to core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/HomeRepository.kt index ac71979b0..b42fc35cc 100644 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repository/HomeRepository.kt +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/HomeRepository.kt @@ -9,18 +9,19 @@ */ package org.mifos.mobile.core.data.repository +import io.ktor.client.statement.HttpResponse import kotlinx.coroutines.flow.Flow -import okhttp3.ResponseBody import org.mifos.mobile.core.model.entity.client.Client import org.mifos.mobile.core.model.entity.client.ClientAccounts +import org.mifospay.core.common.DataState interface HomeRepository { - fun clientAccounts(): Flow + fun clientAccounts(clientId: Long): Flow> - fun currentClient(): Flow + fun currentClient(clientId: Long): Flow> - fun clientImage(): Flow + fun clientImage(clientId: Long): Flow> - suspend fun unreadNotificationsCount(): Flow + fun unreadNotificationsCount(): Flow> } diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repository/LoanRepository.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/LoanRepository.kt similarity index 75% rename from core/data/src/main/java/org/mifos/mobile/core/data/repository/LoanRepository.kt rename to core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/LoanRepository.kt index 6a94e8d52..b5ad79b60 100644 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repository/LoanRepository.kt +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/LoanRepository.kt @@ -10,26 +10,27 @@ package org.mifos.mobile.core.data.repository import kotlinx.coroutines.flow.Flow -import okhttp3.ResponseBody import org.mifos.mobile.core.model.entity.accounts.loan.LoanWithAssociations import org.mifos.mobile.core.model.entity.accounts.loan.LoanWithdraw import org.mifos.mobile.core.model.entity.templates.loans.LoanTemplate +import org.mifospay.core.common.DataState interface LoanRepository { fun getLoanWithAssociations( associationType: String?, loanId: Long?, - ): Flow + ): Flow> - fun withdrawLoanAccount( + suspend fun withdrawLoanAccount( loanId: Long?, loanWithdraw: LoanWithdraw?, - ): Flow? + ): DataState - fun template(): Flow + fun template(clientId: Long?): Flow> fun getLoanTemplateByProduct( + clientId: Long?, productId: Int?, - ): Flow + ): Flow> } diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repository/NotificationRepository.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/NotificationRepository.kt similarity index 80% rename from core/data/src/main/java/org/mifos/mobile/core/data/repository/NotificationRepository.kt rename to core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/NotificationRepository.kt index 9283982ba..794ece8bf 100644 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repository/NotificationRepository.kt +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/NotificationRepository.kt @@ -11,12 +11,13 @@ package org.mifos.mobile.core.data.repository import kotlinx.coroutines.flow.Flow import org.mifos.mobile.core.model.entity.MifosNotification +import org.mifospay.core.common.DataState interface NotificationRepository { - fun loadNotifications(): Flow> + fun loadNotifications(): Flow>> - fun getUnReadNotificationCount(): Flow + fun getUnReadNotificationCount(): Flow> suspend fun saveNotification(notification: MifosNotification) diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repository/RecentTransactionRepository.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/RecentTransactionRepository.kt similarity index 81% rename from core/data/src/main/java/org/mifos/mobile/core/data/repository/RecentTransactionRepository.kt rename to core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/RecentTransactionRepository.kt index 39a1eb235..b00ba54c1 100644 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repository/RecentTransactionRepository.kt +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/RecentTransactionRepository.kt @@ -12,11 +12,13 @@ package org.mifos.mobile.core.data.repository import kotlinx.coroutines.flow.Flow import org.mifos.mobile.core.model.entity.Page import org.mifos.mobile.core.model.entity.Transaction +import org.mifospay.core.common.DataState interface RecentTransactionRepository { - suspend fun recentTransactions( + fun recentTransactions( + clientId: Long?, offset: Int?, limit: Int?, - ): Flow> + ): Flow>> } diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repository/ReviewLoanApplicationRepository.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/ReviewLoanApplicationRepository.kt similarity index 87% rename from core/data/src/main/java/org/mifos/mobile/core/data/repository/ReviewLoanApplicationRepository.kt rename to core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/ReviewLoanApplicationRepository.kt index 91279c2ad..846b0a9f4 100644 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repository/ReviewLoanApplicationRepository.kt +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/ReviewLoanApplicationRepository.kt @@ -9,10 +9,9 @@ */ package org.mifos.mobile.core.data.repository -import kotlinx.coroutines.flow.Flow -import okhttp3.ResponseBody import org.mifos.mobile.core.model.entity.payload.LoansPayload import org.mifos.mobile.core.model.enums.LoanState +import org.mifospay.core.common.DataState interface ReviewLoanApplicationRepository { @@ -20,5 +19,5 @@ interface ReviewLoanApplicationRepository { loanState: LoanState, loansPayload: LoansPayload, loanId: Long, - ): Flow + ): DataState } diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repository/SavingsAccountRepository.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/SavingsAccountRepository.kt similarity index 78% rename from core/data/src/main/java/org/mifos/mobile/core/data/repository/SavingsAccountRepository.kt rename to core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/SavingsAccountRepository.kt index 0d9872b31..04b8824d4 100644 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repository/SavingsAccountRepository.kt +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/SavingsAccountRepository.kt @@ -10,34 +10,34 @@ package org.mifos.mobile.core.data.repository import kotlinx.coroutines.flow.Flow -import okhttp3.ResponseBody import org.mifos.mobile.core.model.entity.accounts.savings.SavingsAccountApplicationPayload import org.mifos.mobile.core.model.entity.accounts.savings.SavingsAccountUpdatePayload import org.mifos.mobile.core.model.entity.accounts.savings.SavingsAccountWithdrawPayload import org.mifos.mobile.core.model.entity.accounts.savings.SavingsWithAssociations import org.mifos.mobile.core.model.entity.templates.account.AccountOptionsTemplate import org.mifos.mobile.core.model.entity.templates.savings.SavingsAccountTemplate +import org.mifospay.core.common.DataState interface SavingsAccountRepository { - suspend fun getSavingsWithAssociations( + fun getSavingsWithAssociations( accountId: Long?, associationType: String?, - ): Flow + ): Flow> - suspend fun getSavingAccountApplicationTemplate(clientId: Long?): Flow + fun getSavingAccountApplicationTemplate(clientId: Long?): Flow> - suspend fun submitSavingAccountApplication(payload: SavingsAccountApplicationPayload?): Flow + suspend fun submitSavingAccountApplication(payload: SavingsAccountApplicationPayload?): DataState suspend fun updateSavingsAccount( accountId: Long?, payload: SavingsAccountUpdatePayload?, - ): Flow + ): DataState suspend fun submitWithdrawSavingsAccount( accountId: String?, payload: SavingsAccountWithdrawPayload?, - ): Flow + ): DataState - fun accountTransferTemplate(accountId: Long?, accountType: Long?): Flow + fun accountTransferTemplate(accountId: Long?, accountType: Long?): Flow> } diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repository/ThirdPartyTransferRepository.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/ThirdPartyTransferRepository.kt similarity index 81% rename from core/data/src/main/java/org/mifos/mobile/core/data/repository/ThirdPartyTransferRepository.kt rename to core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/ThirdPartyTransferRepository.kt index 0d2f81b10..c6b35283c 100644 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repository/ThirdPartyTransferRepository.kt +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/ThirdPartyTransferRepository.kt @@ -11,8 +11,9 @@ package org.mifos.mobile.core.data.repository import kotlinx.coroutines.flow.Flow import org.mifos.mobile.core.model.entity.templates.account.AccountOptionsTemplate +import org.mifospay.core.common.DataState interface ThirdPartyTransferRepository { - suspend fun thirdPartyTransferTemplate(): Flow + fun thirdPartyTransferTemplate(): Flow> } diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repository/TransferRepository.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/TransferRepository.kt similarity index 91% rename from core/data/src/main/java/org/mifos/mobile/core/data/repository/TransferRepository.kt rename to core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/TransferRepository.kt index a5324eead..bde1ea0b0 100644 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repository/TransferRepository.kt +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/TransferRepository.kt @@ -9,9 +9,8 @@ */ package org.mifos.mobile.core.data.repository -import kotlinx.coroutines.flow.Flow -import okhttp3.ResponseBody import org.mifos.mobile.core.model.enums.TransferType +import org.mifospay.core.common.DataState interface TransferRepository { @@ -32,5 +31,5 @@ interface TransferRepository { fromAccountNumber: String?, toAccountNumber: String?, transferType: TransferType?, - ): Flow + ): DataState } diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repository/UserAuthRepository.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/UserAuthRepository.kt similarity index 80% rename from core/data/src/main/java/org/mifos/mobile/core/data/repository/UserAuthRepository.kt rename to core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/UserAuthRepository.kt index f1e1a7ac1..3617c1891 100644 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repository/UserAuthRepository.kt +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/UserAuthRepository.kt @@ -9,9 +9,8 @@ */ package org.mifos.mobile.core.data.repository -import kotlinx.coroutines.flow.Flow -import okhttp3.ResponseBody import org.mifos.mobile.core.model.entity.User +import org.mifospay.core.common.DataState interface UserAuthRepository { @@ -24,14 +23,14 @@ interface UserAuthRepository { mobileNumber: String?, password: String?, username: String?, - ): Flow + ): DataState - suspend fun login(username: String, password: String): Flow + suspend fun login(username: String, password: String): DataState - suspend fun verifyUser(authenticationToken: String?, requestId: String?): Flow + suspend fun verifyUser(authenticationToken: String?, requestId: String?): DataState suspend fun updateAccountPassword( newPassword: String, confirmPassword: String, - ): Flow + ): DataState } diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repository/UserDataRepository.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/UserDataRepository.kt similarity index 80% rename from core/data/src/main/java/org/mifos/mobile/core/data/repository/UserDataRepository.kt rename to core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/UserDataRepository.kt index 9fe5c7a68..6687199c6 100644 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repository/UserDataRepository.kt +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/UserDataRepository.kt @@ -11,12 +11,13 @@ package org.mifos.mobile.core.data.repository import kotlinx.coroutines.flow.Flow import org.mifos.mobile.core.model.UserData +import org.mifospay.core.common.DataState interface UserDataRepository { /** * Stream of [UserData] */ - val userData: Flow + val userData: Flow> - fun logOut(): Unit + suspend fun logOut(): DataState } diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repository/UserDetailRepository.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/UserDetailRepository.kt similarity index 69% rename from core/data/src/main/java/org/mifos/mobile/core/data/repository/UserDetailRepository.kt rename to core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/UserDetailRepository.kt index ccbe1e076..1011f9e8b 100644 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repository/UserDetailRepository.kt +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/UserDetailRepository.kt @@ -10,18 +10,18 @@ package org.mifos.mobile.core.data.repository import kotlinx.coroutines.flow.Flow -import okhttp3.ResponseBody import org.mifos.mobile.core.model.entity.notification.NotificationRegisterPayload import org.mifos.mobile.core.model.entity.notification.NotificationUserDetail +import org.mifospay.core.common.DataState interface UserDetailRepository { - fun registerNotification(payload: NotificationRegisterPayload?): Flow + suspend fun registerNotification(payload: NotificationRegisterPayload?): DataState - fun getUserNotificationId(id: Long): Flow + fun getUserNotificationId(id: Long): Flow> - fun updateRegisterNotification( + suspend fun updateRegisterNotification( id: Long, payload: NotificationRegisterPayload?, - ): Flow + ): DataState } diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/AccountsRepositoryImp.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/AccountsRepositoryImp.kt similarity index 57% rename from core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/AccountsRepositoryImp.kt rename to core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/AccountsRepositoryImp.kt index 9fb42bde6..c54ea7df0 100644 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/AccountsRepositoryImp.kt +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/AccountsRepositoryImp.kt @@ -9,20 +9,22 @@ */ package org.mifos.mobile.core.data.repositoryImpl +import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.flow.flowOn import org.mifos.mobile.core.data.repository.AccountsRepository import org.mifos.mobile.core.model.entity.client.ClientAccounts import org.mifos.mobile.core.network.DataManager -import javax.inject.Inject +import org.mifospay.core.common.DataState +import org.mifospay.core.common.asDataStateFlow -class AccountsRepositoryImp @Inject constructor( +class AccountsRepositoryImp( private val dataManager: DataManager, + private val ioDispatcher: CoroutineDispatcher, ) : AccountsRepository { - override fun loadAccounts(accountType: String?): Flow { - return flow { - emit(dataManager.getAccounts(accountType)) - } + override fun loadAccounts(clientId: Long?, accountType: String?): Flow> { + return dataManager.clientsApi.getAccounts(clientId!!, accountType) + .asDataStateFlow().flowOn(ioDispatcher) } } diff --git a/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/AuthenticationUserRepository.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/AuthenticationUserRepository.kt new file mode 100644 index 000000000..92b9a15f6 --- /dev/null +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/AuthenticationUserRepository.kt @@ -0,0 +1,51 @@ +/* + * 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/mobile-mobile/blob/master/LICENSE.md + */ +package org.mifos.mobile.core.data.repositoryImpl + +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.firstOrNull +import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.flow.flowOn +import kotlinx.coroutines.withContext +import org.mifos.mobile.core.data.repository.UserDataRepository +import org.mifos.mobile.core.datastore.UserPreferencesRepository +import org.mifos.mobile.core.model.UserData +import org.mifospay.core.common.DataState + +class AuthenticationUserRepository( + private val preferencesHelper: UserPreferencesRepository, + private val ioDispatcher: CoroutineDispatcher, +) : UserDataRepository { + + override val userData: Flow> = flow { + try { + val userData = UserData( + isAuthenticated = !preferencesHelper.token.value.isNullOrEmpty(), + userName = preferencesHelper.userInfo.firstOrNull()?.userName ?: "", + clientId = preferencesHelper.clientId.value ?: 0, + ) + emit(DataState.Success(userData)) + } catch (e: Exception) { + emit(DataState.Error(e, null)) + } + }.flowOn(ioDispatcher) + + override suspend fun logOut(): DataState { + return try { + withContext(ioDispatcher) { + preferencesHelper.logOut() + } + DataState.Success("User logged out Successfully") + } catch (e: Exception) { + DataState.Error(e, null) + } + } +} diff --git a/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/BeneficiaryRepositoryImp.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/BeneficiaryRepositoryImp.kt new file mode 100644 index 000000000..af590c0e2 --- /dev/null +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/BeneficiaryRepositoryImp.kt @@ -0,0 +1,75 @@ +/* + * 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/mobile-mobile/blob/master/LICENSE.md + */ +package org.mifos.mobile.core.data.repositoryImpl + +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flowOn +import kotlinx.coroutines.withContext +import org.mifos.mobile.core.data.repository.BeneficiaryRepository +import org.mifos.mobile.core.model.entity.beneficiary.Beneficiary +import org.mifos.mobile.core.model.entity.beneficiary.BeneficiaryPayload +import org.mifos.mobile.core.model.entity.beneficiary.BeneficiaryUpdatePayload +import org.mifos.mobile.core.model.entity.templates.beneficiary.BeneficiaryTemplate +import org.mifos.mobile.core.network.DataManager +import org.mifospay.core.common.DataState +import org.mifospay.core.common.asDataStateFlow + +class BeneficiaryRepositoryImp( + private val dataManager: DataManager, + private val ioDispatcher: CoroutineDispatcher, +) : BeneficiaryRepository { + + override fun beneficiaryTemplate(): Flow> { + return dataManager.beneficiaryApi.beneficiaryTemplate() + .asDataStateFlow().flowOn(ioDispatcher) + } + + override suspend fun createBeneficiary(beneficiaryPayload: BeneficiaryPayload?): DataState { + return try { + withContext(ioDispatcher) { + dataManager.beneficiaryApi.createBeneficiary(beneficiaryPayload) + } + DataState.Success("Created successfully") + } catch (e: Exception) { + DataState.Error(e, null) + } + } + + override suspend fun updateBeneficiary( + beneficiaryId: Long?, + payload: BeneficiaryUpdatePayload?, + ): DataState { + return try { + withContext(ioDispatcher) { + dataManager.beneficiaryApi.updateBeneficiary(beneficiaryId!!, payload) + } + DataState.Success("Updated successfully") + } catch (e: Exception) { + DataState.Error(e, null) + } + } + + override suspend fun deleteBeneficiary(beneficiaryId: Long?): DataState { + return try { + withContext(ioDispatcher) { + dataManager.beneficiaryApi.deleteBeneficiary(beneficiaryId!!) + } + DataState.Success("Deleted successfully") + } catch (e: Exception) { + DataState.Error(e, null) + } + } + + override suspend fun beneficiaryList(): Flow>> { + return dataManager.beneficiaryApi.beneficiaryList() + .asDataStateFlow().flowOn(ioDispatcher) + } +} diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/ClientChargeRepositoryImp.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/ClientChargeRepositoryImp.kt similarity index 66% rename from core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/ClientChargeRepositoryImp.kt rename to core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/ClientChargeRepositoryImp.kt index 5639356d8..614d1e47b 100644 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/ClientChargeRepositoryImp.kt +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/ClientChargeRepositoryImp.kt @@ -11,12 +11,11 @@ package org.mifos.mobile.core.data.repositoryImpl import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.map import kotlinx.coroutines.withContext -import org.mifos.mobile.core.common.network.Dispatcher -import org.mifos.mobile.core.common.network.MifosDispatchers +import org.mifos.mobile.core.common.Dispatcher +import org.mifos.mobile.core.common.MifosDispatchers import org.mifos.mobile.core.data.model.toCharge import org.mifos.mobile.core.data.model.toChargeEntity import org.mifos.mobile.core.data.repository.ClientChargeRepository @@ -24,31 +23,29 @@ import org.mifos.mobile.core.database.dao.ChargeDao import org.mifos.mobile.core.model.entity.Charge import org.mifos.mobile.core.model.entity.Page import org.mifos.mobile.core.network.DataManager -import javax.inject.Inject +import org.mifospay.core.common.DataState +import org.mifospay.core.common.asDataStateFlow -class ClientChargeRepositoryImp @Inject constructor( +class ClientChargeRepositoryImp( private val dataManager: DataManager, private val chargeDao: ChargeDao, @Dispatcher(MifosDispatchers.IO) private val ioDispatcher: CoroutineDispatcher, ) : ClientChargeRepository { - override fun getClientCharges(clientId: Long): Flow> { - return flow { - emit(dataManager.getClientCharges(clientId)) - } + override fun getClientCharges(clientId: Long): Flow>> { + return dataManager.clientChargeApi.getClientChargeList(clientId) + .asDataStateFlow().flowOn(ioDispatcher) } - override fun getLoanCharges(loanId: Long): Flow> { - return flow { - emit(dataManager.getLoanCharges(loanId)) - } + override fun getLoanCharges(loanId: Long): Flow>> { + return dataManager.clientChargeApi.getLoanAccountChargeList(loanId) + .asDataStateFlow().flowOn(ioDispatcher) } - override fun getSavingsCharges(savingsId: Long): Flow> { - return flow { - emit(dataManager.getSavingsCharges(savingsId)) - } + override fun getSavingsCharges(savingsId: Long): Flow>> { + return dataManager.clientChargeApi.getSavingsAccountChargeList(savingsId) + .asDataStateFlow().flowOn(ioDispatcher) } override fun clientLocalCharges(): Flow> { diff --git a/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/ClientRepositoryImp.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/ClientRepositoryImp.kt new file mode 100644 index 000000000..d2e5dc9e5 --- /dev/null +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/ClientRepositoryImp.kt @@ -0,0 +1,100 @@ +/* + * 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/mobile-mobile/blob/master/LICENSE.md + */ +package org.mifos.mobile.core.data.repositoryImpl + +import io.ktor.client.HttpClient +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.firstOrNull +import kotlinx.coroutines.flow.flowOn +import kotlinx.coroutines.withContext +import okio.ByteString.Companion.encodeUtf8 +import org.mifos.mobile.core.common.Constants +import org.mifos.mobile.core.data.repository.ClientRepository +import org.mifos.mobile.core.datastore.UserPreferencesRepository +import org.mifos.mobile.core.model.entity.Page +import org.mifos.mobile.core.model.entity.User +import org.mifos.mobile.core.model.entity.client.Client +import org.mifos.mobile.core.network.DataManager +import org.mifos.mobile.core.network.KtorfitClient +import org.mifos.mobile.core.network.utils.BaseURL +import org.mifos.mobile.core.network.utils.KtorInterceptorRe +import org.mifospay.core.common.DataState +import org.mifospay.core.common.asDataStateFlow + +class ClientRepositoryImp( + private val dataManager: DataManager, + private val preferencesHelper: UserPreferencesRepository, + private val ioDispatcher: CoroutineDispatcher, +) : ClientRepository { + + override fun loadClient(): Flow>> { + return dataManager.clientsApi.clients() + .asDataStateFlow().flowOn(ioDispatcher) + } + + /** + * Save the authentication token from the server and the user ID. + * The authentication token would be used for accessing the authenticated + * APIs. + * + * @param user - The user that is to be saved. + */ + override suspend fun saveAuthenticationTokenForSession(user: User): DataState { + return try { + val authToken = Constants.BASIC + user.base64EncodedAuthenticationKey + preferencesHelper.updateToken(authToken) + reInitializeService() + DataState.Success(Unit) + } catch (e: Exception) { + DataState.Error(e) + } + } + + override suspend fun setClientId(clientId: Long?): DataState { + return try { + withContext(ioDispatcher) { + preferencesHelper.updateClientId(clientId) + } + DataState.Success(Unit) + } catch (e: Exception) { + DataState.Error(e, null) + } + } + + override fun reInitializeService() { + val client = HttpClient { + install(KtorInterceptorRe) { + repository = preferencesHelper + } + } + KtorfitClient.builder() + .baseURL(BaseURL().url) + .httpClient(client) + .build() + } + + override suspend fun updateAuthenticationToken(password: String): DataState { + return try { + withContext(ioDispatcher) { + val username = preferencesHelper.userInfo.firstOrNull()?.userName + val authenticationToken = "Basic " + "$username:$password".encodeToBase64() + preferencesHelper.updateToken(authenticationToken) + } + reInitializeService() + DataState.Success(Unit) + } catch (e: Exception) { + DataState.Error(e, null) + } + } + private fun String.encodeToBase64(): String { + return this.encodeUtf8().base64() + } +} diff --git a/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/GuarantorRepositoryImp.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/GuarantorRepositoryImp.kt new file mode 100644 index 000000000..b5dea1995 --- /dev/null +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/GuarantorRepositoryImp.kt @@ -0,0 +1,78 @@ +/* + * 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/mobile-mobile/blob/master/LICENSE.md + */ +package org.mifos.mobile.core.data.repositoryImpl + +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flowOn +import kotlinx.coroutines.withContext +import org.mifos.mobile.core.data.repository.GuarantorRepository +import org.mifos.mobile.core.model.entity.guarantor.GuarantorApplicationPayload +import org.mifos.mobile.core.model.entity.guarantor.GuarantorPayload +import org.mifos.mobile.core.model.entity.guarantor.GuarantorTemplatePayload +import org.mifos.mobile.core.network.DataManager +import org.mifospay.core.common.DataState +import org.mifospay.core.common.asDataStateFlow + +class GuarantorRepositoryImp( + private val dataManager: DataManager, + private val ioDispatcher: CoroutineDispatcher, +) : GuarantorRepository { + + override fun getGuarantorTemplate(loanId: Long?): Flow> { + return dataManager.guarantorApi.getGuarantorTemplate(loanId!!) + .asDataStateFlow().flowOn(ioDispatcher) + } + + override suspend fun createGuarantor( + loanId: Long?, + payload: GuarantorApplicationPayload?, + ): DataState { + return try { + withContext(ioDispatcher) { + dataManager.guarantorApi.createGuarantor(loanId!!, payload) + } + DataState.Success("Created successfully") + } catch (e: Exception) { + DataState.Error(e, null) + } + } + + override suspend fun updateGuarantor( + payload: GuarantorApplicationPayload?, + loanId: Long?, + guarantorId: Long?, + ): DataState { + return try { + withContext(ioDispatcher) { + dataManager.guarantorApi.updateGuarantor(payload, loanId!!, guarantorId!!) + } + DataState.Success("Created successfully") + } catch (e: Exception) { + DataState.Error(e, null) + } + } + + override suspend fun deleteGuarantor(loanId: Long?, guarantorId: Long?): DataState { + return try { + withContext(ioDispatcher) { + dataManager.guarantorApi.deleteGuarantor(loanId!!, guarantorId!!) + } + DataState.Success("Created successfully") + } catch (e: Exception) { + DataState.Error(e, null) + } + } + + override fun getGuarantorList(loanId: Long): Flow?>> { + return dataManager.guarantorApi.getGuarantorList(loanId) + .asDataStateFlow().flowOn(ioDispatcher) + } +} diff --git a/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/HomeRepositoryImp.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/HomeRepositoryImp.kt new file mode 100644 index 000000000..4b498228a --- /dev/null +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/HomeRepositoryImp.kt @@ -0,0 +1,48 @@ +/* + * 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/mobile-mobile/blob/master/LICENSE.md + */ +package org.mifos.mobile.core.data.repositoryImpl + +import io.ktor.client.statement.HttpResponse +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flowOn +import org.mifos.mobile.core.data.repository.HomeRepository +import org.mifos.mobile.core.data.repository.NotificationRepository +import org.mifos.mobile.core.model.entity.client.Client +import org.mifos.mobile.core.model.entity.client.ClientAccounts +import org.mifos.mobile.core.network.DataManager +import org.mifospay.core.common.DataState +import org.mifospay.core.common.asDataStateFlow + +class HomeRepositoryImp( + private val dataManager: DataManager, + private val notificationRepository: NotificationRepository, + private val ioDispatcher: CoroutineDispatcher, +) : HomeRepository { + + override fun clientAccounts(clientId: Long): Flow> { + return dataManager.clientsApi.getClientAccounts(clientId) + .asDataStateFlow().flowOn(ioDispatcher) + } + + override fun currentClient(clientId: Long): Flow> { + return dataManager.clientsApi.getClientForId(clientId) + .asDataStateFlow().flowOn(ioDispatcher) + } + + override fun clientImage(clientId: Long): Flow> { + return dataManager.clientsApi.getClientImage(clientId) + .asDataStateFlow().flowOn(ioDispatcher) + } + + override fun unreadNotificationsCount(): Flow> { + return notificationRepository.getUnReadNotificationCount().flowOn(ioDispatcher) + } +} diff --git a/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/LoanRepositoryImp.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/LoanRepositoryImp.kt new file mode 100644 index 000000000..c81c0ea83 --- /dev/null +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/LoanRepositoryImp.kt @@ -0,0 +1,60 @@ +/* + * 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/mobile-mobile/blob/master/LICENSE.md + */ +package org.mifos.mobile.core.data.repositoryImpl + +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flowOn +import kotlinx.coroutines.withContext +import org.mifos.mobile.core.data.repository.LoanRepository +import org.mifos.mobile.core.model.entity.accounts.loan.LoanWithAssociations +import org.mifos.mobile.core.model.entity.accounts.loan.LoanWithdraw +import org.mifos.mobile.core.model.entity.templates.loans.LoanTemplate +import org.mifos.mobile.core.network.DataManager +import org.mifospay.core.common.DataState +import org.mifospay.core.common.asDataStateFlow + +class LoanRepositoryImp( + private val dataManager: DataManager, + private val ioDispatcher: CoroutineDispatcher, +) : LoanRepository { + + override fun getLoanWithAssociations( + associationType: String?, + loanId: Long?, + ): Flow> { + return dataManager.loanAccountsListApi.getLoanWithAssociations(loanId!!, associationType) + .asDataStateFlow().flowOn(ioDispatcher) + } + + override suspend fun withdrawLoanAccount( + loanId: Long?, + loanWithdraw: LoanWithdraw?, + ): DataState { + return try { + withContext(ioDispatcher) { + dataManager.loanAccountsListApi.withdrawLoanAccount(loanId!!, loanWithdraw) + } + DataState.Success("withdraw successful") + } catch (e: Exception) { + DataState.Error(e, null) + } + } + + override fun template(clientId: Long?): Flow> { + return dataManager.loanAccountsListApi.getLoanTemplate(clientId = clientId) + .asDataStateFlow().flowOn(ioDispatcher) + } + + override fun getLoanTemplateByProduct(clientId: Long?, productId: Int?): Flow> { + return dataManager.loanAccountsListApi.getLoanTemplateByProduct(clientId, productId) + .asDataStateFlow().flowOn(ioDispatcher) + } +} diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/NotificationRepositoryImp.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/NotificationRepositoryImp.kt similarity index 91% rename from core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/NotificationRepositoryImp.kt rename to core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/NotificationRepositoryImp.kt index 694c2731b..5eea6b93a 100644 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/NotificationRepositoryImp.kt +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/NotificationRepositoryImp.kt @@ -14,16 +14,15 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.map import kotlinx.coroutines.withContext -import org.mifos.mobile.core.common.network.Dispatcher -import org.mifos.mobile.core.common.network.MifosDispatchers +import org.mifos.mobile.core.common.Dispatcher +import org.mifos.mobile.core.common.MifosDispatchers import org.mifos.mobile.core.data.model.toEntity import org.mifos.mobile.core.data.model.toModel import org.mifos.mobile.core.data.repository.NotificationRepository import org.mifos.mobile.core.database.dao.MifosNotificationDao import org.mifos.mobile.core.model.entity.MifosNotification -import javax.inject.Inject -class NotificationRepositoryImp @Inject constructor( +class NotificationRepositoryImp( private val notificationDao: MifosNotificationDao, @Dispatcher(MifosDispatchers.IO) private val ioDispatcher: CoroutineDispatcher, diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/RecentTransactionRepositoryImp.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/RecentTransactionRepositoryImp.kt similarity index 57% rename from core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/RecentTransactionRepositoryImp.kt rename to core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/RecentTransactionRepositoryImp.kt index 6fa5dccdd..5bd9662ba 100644 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/RecentTransactionRepositoryImp.kt +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/RecentTransactionRepositoryImp.kt @@ -9,26 +9,29 @@ */ package org.mifos.mobile.core.data.repositoryImpl +import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.flow.flowOn import org.mifos.mobile.core.data.repository.RecentTransactionRepository import org.mifos.mobile.core.model.entity.Page import org.mifos.mobile.core.model.entity.Transaction import org.mifos.mobile.core.network.DataManager -import javax.inject.Inject +import org.mifospay.core.common.DataState +import org.mifospay.core.common.asDataStateFlow -class RecentTransactionRepositoryImp @Inject constructor( +class RecentTransactionRepositoryImp( private val dataManager: DataManager, + private val ioDispatcher: CoroutineDispatcher, ) : RecentTransactionRepository { - - override suspend fun recentTransactions( + override fun recentTransactions( + clientId: Long?, offset: Int?, limit: Int?, - ): Flow> { - return flow { - if (offset != null && limit != null) { - emit(dataManager.getRecentTransactions(offset = offset, limit = limit)) - } - } + ): Flow>> { + return dataManager.recentTransactionsApi.getRecentTransactionsList( + clientId!!, + offset, + limit, + ).asDataStateFlow().flowOn(ioDispatcher) } } diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/ReviewLoanApplicationRepositoryImpl.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/ReviewLoanApplicationRepositoryImpl.kt similarity index 56% rename from core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/ReviewLoanApplicationRepositoryImpl.kt rename to core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/ReviewLoanApplicationRepositoryImpl.kt index be06aa042..d49144c60 100644 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/ReviewLoanApplicationRepositoryImpl.kt +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/ReviewLoanApplicationRepositoryImpl.kt @@ -9,32 +9,36 @@ */ package org.mifos.mobile.core.data.repositoryImpl -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flow -import okhttp3.ResponseBody +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.withContext import org.mifos.mobile.core.data.repository.ReviewLoanApplicationRepository import org.mifos.mobile.core.model.entity.payload.LoansPayload import org.mifos.mobile.core.model.enums.LoanState import org.mifos.mobile.core.network.DataManager -import javax.inject.Inject +import org.mifospay.core.common.DataState -class ReviewLoanApplicationRepositoryImpl @Inject constructor( +class ReviewLoanApplicationRepositoryImpl( private val dataManager: DataManager, + private val ioDispatcher: CoroutineDispatcher, ) : ReviewLoanApplicationRepository { override suspend fun submitLoan( loanState: LoanState, loansPayload: LoansPayload, loanId: Long, - ): Flow { - return flow { - emit( + ): DataState { + return try { + withContext(ioDispatcher) { if (loanState == LoanState.CREATE) { - dataManager.createLoansAccount(loansPayload) + dataManager.loanAccountsListApi.createLoansAccount(loansPayload) + DataState.Success("Created successfully") } else { - dataManager.updateLoanAccount(loanId, loansPayload) - }, - ) + dataManager.loanAccountsListApi.updateLoanAccount(loanId, loansPayload) + DataState.Success("Updated successfully") + } + } + } catch (e: Exception) { + DataState.Error(e, null) } } } diff --git a/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/SavingsAccountRepositoryImp.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/SavingsAccountRepositoryImp.kt new file mode 100644 index 000000000..8f5e5c4be --- /dev/null +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/SavingsAccountRepositoryImp.kt @@ -0,0 +1,98 @@ +/* + * 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/mobile-mobile/blob/master/LICENSE.md + */ +package org.mifos.mobile.core.data.repositoryImpl + +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flowOn +import kotlinx.coroutines.withContext +import org.mifos.mobile.core.data.repository.SavingsAccountRepository +import org.mifos.mobile.core.model.entity.accounts.savings.SavingsAccountApplicationPayload +import org.mifos.mobile.core.model.entity.accounts.savings.SavingsAccountUpdatePayload +import org.mifos.mobile.core.model.entity.accounts.savings.SavingsAccountWithdrawPayload +import org.mifos.mobile.core.model.entity.accounts.savings.SavingsWithAssociations +import org.mifos.mobile.core.model.entity.templates.account.AccountOptionsTemplate +import org.mifos.mobile.core.model.entity.templates.savings.SavingsAccountTemplate +import org.mifos.mobile.core.network.DataManager +import org.mifospay.core.common.DataState +import org.mifospay.core.common.asDataStateFlow + +class SavingsAccountRepositoryImp( + private val dataManager: DataManager, + private val ioDispatcher: CoroutineDispatcher, +) : SavingsAccountRepository { + + override fun getSavingsWithAssociations( + accountId: Long?, + associationType: String?, + ): Flow> { + return dataManager.savingAccountsListApi.getSavingsWithAssociations( + accountId!!, + associationType, + ) + .asDataStateFlow().flowOn(ioDispatcher) + } + + override fun getSavingAccountApplicationTemplate( + clientId: Long?, + ): Flow> { + return dataManager.savingAccountsListApi.getSavingsAccountApplicationTemplate(clientId) + .asDataStateFlow().flowOn(ioDispatcher) + } + + override suspend fun submitSavingAccountApplication( + payload: SavingsAccountApplicationPayload?, + ): DataState { + return try { + withContext(ioDispatcher) { + dataManager.savingAccountsListApi.submitSavingAccountApplication(payload) + } + DataState.Success("Submitted successfully") + } catch (e: Exception) { + DataState.Error(e, null) + } + } + + override suspend fun updateSavingsAccount( + accountId: Long?, + payload: SavingsAccountUpdatePayload?, + ): DataState { + return try { + withContext(ioDispatcher) { + dataManager.savingAccountsListApi.updateSavingsAccountUpdate(accountId!!, payload) + } + DataState.Success("Updated successfully") + } catch (e: Exception) { + DataState.Error(e, null) + } + } + + override suspend fun submitWithdrawSavingsAccount( + accountId: String?, + payload: SavingsAccountWithdrawPayload?, + ): DataState { + return try { + withContext(ioDispatcher) { + dataManager.savingAccountsListApi.submitWithdrawSavingsAccount(accountId!!, payload) + } + DataState.Success("Submitted successfully") + } catch (e: Exception) { + DataState.Error(e, null) + } + } + + override fun accountTransferTemplate( + accountId: Long?, + accountType: Long?, + ): Flow> { + return dataManager.savingAccountsListApi.accountTransferTemplate(accountId!!, accountType) + .asDataStateFlow().flowOn(ioDispatcher) + } +} diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/ThirdPartyTransferRepositoryImp.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/ThirdPartyTransferRepositoryImp.kt similarity index 59% rename from core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/ThirdPartyTransferRepositoryImp.kt rename to core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/ThirdPartyTransferRepositoryImp.kt index 71012eb76..66d5f10fa 100644 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/ThirdPartyTransferRepositoryImp.kt +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/ThirdPartyTransferRepositoryImp.kt @@ -9,20 +9,21 @@ */ package org.mifos.mobile.core.data.repositoryImpl +import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.flow.flowOn import org.mifos.mobile.core.data.repository.ThirdPartyTransferRepository import org.mifos.mobile.core.model.entity.templates.account.AccountOptionsTemplate import org.mifos.mobile.core.network.DataManager -import javax.inject.Inject +import org.mifospay.core.common.DataState +import org.mifospay.core.common.asDataStateFlow -class ThirdPartyTransferRepositoryImp @Inject constructor( +class ThirdPartyTransferRepositoryImp( private val dataManager: DataManager, + private val ioDispatcher: CoroutineDispatcher, ) : ThirdPartyTransferRepository { - - override suspend fun thirdPartyTransferTemplate(): Flow { - return flow { - emit(dataManager.thirdPartyTransferTemplate()) - } + override fun thirdPartyTransferTemplate(): Flow> { + return dataManager.thirdPartyTransferApi.accountTransferTemplate() + .asDataStateFlow().flowOn(ioDispatcher) } } diff --git a/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/TransferRepositoryImp.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/TransferRepositoryImp.kt new file mode 100644 index 000000000..8bcbc35c0 --- /dev/null +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/TransferRepositoryImp.kt @@ -0,0 +1,71 @@ +/* + * 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/mobile-mobile/blob/master/LICENSE.md + */ +package org.mifos.mobile.core.data.repositoryImpl + +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.withContext +import org.mifos.mobile.core.data.repository.TransferRepository +import org.mifos.mobile.core.model.entity.payload.TransferPayload +import org.mifos.mobile.core.model.enums.TransferType +import org.mifos.mobile.core.network.DataManager +import org.mifospay.core.common.DataState + +class TransferRepositoryImp( + private val dataManager: DataManager, + private val ioDispatcher: CoroutineDispatcher, +) : TransferRepository { + override suspend fun makeTransfer( + fromOfficeId: Int?, + fromClientId: Long?, + fromAccountType: Int?, + fromAccountId: Int?, + toOfficeId: Int?, + toClientId: Long?, + toAccountType: Int?, + toAccountId: Int?, + transferDate: String?, + transferAmount: Double?, + transferDescription: String?, + dateFormat: String, + locale: String, + fromAccountNumber: String?, + toAccountNumber: String?, + transferType: TransferType?, + ): DataState { + val transferPayload = TransferPayload( + fromOfficeId = fromOfficeId, + fromClientId = fromClientId, + fromAccountType = fromAccountType, + fromAccountId = fromAccountId, + toOfficeId = toOfficeId, + toClientId = toClientId, + toAccountType = toAccountType, + toAccountId = toAccountId, + transferDate = transferDate, + transferAmount = transferAmount, + transferDescription = transferDescription, + dateFormat = dateFormat, + locale = locale, + fromAccountNumber = fromAccountNumber, + toAccountNumber = toAccountNumber, + ) + return try { + withContext(ioDispatcher) { + when (transferType) { + TransferType.SELF -> dataManager.savingAccountsListApi.makeTransfer(transferPayload) + else -> dataManager.thirdPartyTransferApi.makeTransfer(transferPayload) + } + } + DataState.Success("Submitted successfully") + } catch (e: Exception) { + DataState.Error(e, null) + } + } +} diff --git a/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/UserAuthRepositoryImp.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/UserAuthRepositoryImp.kt new file mode 100644 index 000000000..e4b3036ea --- /dev/null +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/UserAuthRepositoryImp.kt @@ -0,0 +1,108 @@ +/* + * 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/mobile-mobile/blob/master/LICENSE.md + */ +package org.mifos.mobile.core.data.repositoryImpl + +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.withContext +import org.mifos.mobile.core.data.repository.UserAuthRepository +import org.mifos.mobile.core.model.entity.UpdatePasswordPayload +import org.mifos.mobile.core.model.entity.User +import org.mifos.mobile.core.model.entity.payload.LoginPayload +import org.mifos.mobile.core.model.entity.register.RegisterPayload +import org.mifos.mobile.core.model.entity.register.UserVerify +import org.mifos.mobile.core.network.DataManager +import org.mifospay.core.common.DataState + +class UserAuthRepositoryImp( + private val dataManager: DataManager, + private val ioDispatcher: CoroutineDispatcher, +) : UserAuthRepository { + + override suspend fun registerUser( + accountNumber: String?, + authenticationMode: String?, + email: String?, + firstName: String?, + lastName: String?, + mobileNumber: String?, + password: String?, + username: String?, + ): DataState { + val registerPayload = RegisterPayload( + accountNumber = accountNumber, + authenticationMode = authenticationMode, + email = email, + firstName = firstName, + lastName = lastName, + mobileNumber = mobileNumber, + password = password, + username = username, + ) + return try { + withContext(ioDispatcher) { + dataManager.registrationApi.registerUser(registerPayload) + DataState.Success("User registered Successfully") + } + } catch (e: Exception) { + DataState.Error(e, null) + } + } + + override suspend fun login(username: String, password: String): DataState { + val loginPayload = LoginPayload( + username = username, + password = password, + ) + return try { + withContext(ioDispatcher) { + val user = dataManager.authenticationApi.authenticate(loginPayload) + DataState.Success(user) + } + } catch (e: Exception) { + DataState.Error(e, null) + } + } + + override suspend fun verifyUser( + authenticationToken: String?, + requestId: String?, + ): DataState { + val userVerify = UserVerify( + authenticationToken = authenticationToken, + requestId = requestId, + ) + return try { + withContext(ioDispatcher) { + dataManager.registrationApi.verifyUser(userVerify) + } + DataState.Success("User Verified Successfully") + } catch (e: Exception) { + DataState.Error(e, null) + } + } + + override suspend fun updateAccountPassword( + newPassword: String, + confirmPassword: String, + ): DataState { + val payload = UpdatePasswordPayload( + password = newPassword, + repeatPassword = confirmPassword, + ) + return try { + withContext(ioDispatcher) { + dataManager.userDetailsApi.updateAccountPassword(payload) + } + DataState.Success("Password Updated Successfully") + } catch (e: Exception) { + DataState.Error(e, null) + } + } +} diff --git a/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/UserDetailRepositoryImp.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/UserDetailRepositoryImp.kt new file mode 100644 index 000000000..de3ffc7eb --- /dev/null +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/UserDetailRepositoryImp.kt @@ -0,0 +1,57 @@ +/* + * 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/mobile-mobile/blob/master/LICENSE.md + */ +package org.mifos.mobile.core.data.repositoryImpl + +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flowOn +import kotlinx.coroutines.withContext +import org.mifos.mobile.core.data.repository.UserDetailRepository +import org.mifos.mobile.core.model.entity.notification.NotificationRegisterPayload +import org.mifos.mobile.core.model.entity.notification.NotificationUserDetail +import org.mifos.mobile.core.network.DataManager +import org.mifospay.core.common.DataState +import org.mifospay.core.common.asDataStateFlow + +class UserDetailRepositoryImp( + private val dataManager: DataManager, + private val ioDispatcher: CoroutineDispatcher, +) : UserDetailRepository { + + override suspend fun registerNotification(payload: NotificationRegisterPayload?): DataState { + return try { + withContext(ioDispatcher) { + dataManager.notificationApi.registerNotification(payload) + } + DataState.Success("Notification Registered Successfully") + } catch (e: Exception) { + DataState.Error(e, null) + } + } + + override fun getUserNotificationId(id: Long): Flow> { + return dataManager.notificationApi.getUserNotificationId(id) + .asDataStateFlow().flowOn(ioDispatcher) + } + + override suspend fun updateRegisterNotification( + id: Long, + payload: NotificationRegisterPayload?, + ): DataState { + return try { + withContext(ioDispatcher) { + dataManager.notificationApi.updateRegisterNotification(id, payload) + } + DataState.Success("Notification Updated Successfully") + } catch (e: Exception) { + DataState.Error(e, null) + } + } +} diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/utils/NetworkMonitor.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/util/NetworkMonitor.kt similarity index 85% rename from core/data/src/main/java/org/mifos/mobile/core/data/utils/NetworkMonitor.kt rename to core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/util/NetworkMonitor.kt index 9f2326c9c..08f6723c8 100644 --- a/core/data/src/main/java/org/mifos/mobile/core/data/utils/NetworkMonitor.kt +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/util/NetworkMonitor.kt @@ -1,5 +1,5 @@ /* - * Copyright 2024 Mifos Initiative + * 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 @@ -7,7 +7,7 @@ * * See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md */ -package org.mifos.mobile.core.data.utils +package org.mifos.mobile.core.data.util import kotlinx.coroutines.flow.Flow diff --git a/core/data/src/desktopMain/kotlin/org/mifos/mobile/core/data/JsPlatformDependentDataModule.kt b/core/data/src/desktopMain/kotlin/org/mifos/mobile/core/data/JsPlatformDependentDataModule.kt new file mode 100644 index 000000000..bc7aea8e0 --- /dev/null +++ b/core/data/src/desktopMain/kotlin/org/mifos/mobile/core/data/JsPlatformDependentDataModule.kt @@ -0,0 +1,23 @@ +/* + * 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/mobile-mobile/blob/master/LICENSE.md + */ +package org.mifospay.core.data + +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flowOf +import org.mifos.mobile.core.data.di.PlatformDependentDataModule +import org.mifos.mobile.core.data.util.NetworkMonitor + +class JsPlatformDependentDataModule : PlatformDependentDataModule { + override val networkMonitor: NetworkMonitor by lazy { + object : NetworkMonitor { + override val isOnline: Flow = flowOf(true) + } + } +} diff --git a/core/data/src/desktopMain/kotlin/org/mifos/mobile/core/data/di/PlatformDependentDataModule.desktop.kt b/core/data/src/desktopMain/kotlin/org/mifos/mobile/core/data/di/PlatformDependentDataModule.desktop.kt new file mode 100644 index 000000000..1970d8c94 --- /dev/null +++ b/core/data/src/desktopMain/kotlin/org/mifos/mobile/core/data/di/PlatformDependentDataModule.desktop.kt @@ -0,0 +1,22 @@ +/* + * 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/mobile-mobile/blob/master/LICENSE.md + */ +package org.mifos.mobile.core.data.di + +import org.koin.core.module.Module +import org.koin.dsl.module +import org.mifospay.core.data.JsPlatformDependentDataModule + +actual val getPlatformDataModule: PlatformDependentDataModule + get() = JsPlatformDependentDataModule() + +actual val platformModule: Module + get() = module { + single { getPlatformDataModule } + } diff --git a/core/data/src/jsMain/kotlin/org/mifos/mobile/core/data/JsPlatformDependentDataModule.kt b/core/data/src/jsMain/kotlin/org/mifos/mobile/core/data/JsPlatformDependentDataModule.kt new file mode 100644 index 000000000..bc7aea8e0 --- /dev/null +++ b/core/data/src/jsMain/kotlin/org/mifos/mobile/core/data/JsPlatformDependentDataModule.kt @@ -0,0 +1,23 @@ +/* + * 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/mobile-mobile/blob/master/LICENSE.md + */ +package org.mifospay.core.data + +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flowOf +import org.mifos.mobile.core.data.di.PlatformDependentDataModule +import org.mifos.mobile.core.data.util.NetworkMonitor + +class JsPlatformDependentDataModule : PlatformDependentDataModule { + override val networkMonitor: NetworkMonitor by lazy { + object : NetworkMonitor { + override val isOnline: Flow = flowOf(true) + } + } +} diff --git a/core/data/src/jsMain/kotlin/org/mifos/mobile/core/data/di/PlatformDependentDataModule.js.kt b/core/data/src/jsMain/kotlin/org/mifos/mobile/core/data/di/PlatformDependentDataModule.js.kt new file mode 100644 index 000000000..1970d8c94 --- /dev/null +++ b/core/data/src/jsMain/kotlin/org/mifos/mobile/core/data/di/PlatformDependentDataModule.js.kt @@ -0,0 +1,22 @@ +/* + * 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/mobile-mobile/blob/master/LICENSE.md + */ +package org.mifos.mobile.core.data.di + +import org.koin.core.module.Module +import org.koin.dsl.module +import org.mifospay.core.data.JsPlatformDependentDataModule + +actual val getPlatformDataModule: PlatformDependentDataModule + get() = JsPlatformDependentDataModule() + +actual val platformModule: Module + get() = module { + single { getPlatformDataModule } + } diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/di/RepositoryModule.kt b/core/data/src/main/java/org/mifos/mobile/core/data/di/RepositoryModule.kt deleted file mode 100644 index e8f92feb5..000000000 --- a/core/data/src/main/java/org/mifos/mobile/core/data/di/RepositoryModule.kt +++ /dev/null @@ -1,133 +0,0 @@ -/* - * 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/mobile-mobile/blob/master/LICENSE.md - */ -package org.mifos.mobile.core.data.di - -import dagger.Binds -import dagger.Module -import dagger.hilt.InstallIn -import dagger.hilt.components.SingletonComponent -import org.mifos.mobile.core.data.repository.AccountsRepository -import org.mifos.mobile.core.data.repository.BeneficiaryRepository -import org.mifos.mobile.core.data.repository.ClientChargeRepository -import org.mifos.mobile.core.data.repository.ClientRepository -import org.mifos.mobile.core.data.repository.GuarantorRepository -import org.mifos.mobile.core.data.repository.HomeRepository -import org.mifos.mobile.core.data.repository.LoanRepository -import org.mifos.mobile.core.data.repository.NotificationRepository -import org.mifos.mobile.core.data.repository.RecentTransactionRepository -import org.mifos.mobile.core.data.repository.ReviewLoanApplicationRepository -import org.mifos.mobile.core.data.repository.SavingsAccountRepository -import org.mifos.mobile.core.data.repository.ThirdPartyTransferRepository -import org.mifos.mobile.core.data.repository.TransferRepository -import org.mifos.mobile.core.data.repository.UserAuthRepository -import org.mifos.mobile.core.data.repository.UserDataRepository -import org.mifos.mobile.core.data.repository.UserDetailRepository -import org.mifos.mobile.core.data.repositoryImpl.AccountsRepositoryImp -import org.mifos.mobile.core.data.repositoryImpl.AuthenticationUserRepository -import org.mifos.mobile.core.data.repositoryImpl.BeneficiaryRepositoryImp -import org.mifos.mobile.core.data.repositoryImpl.ClientChargeRepositoryImp -import org.mifos.mobile.core.data.repositoryImpl.ClientRepositoryImp -import org.mifos.mobile.core.data.repositoryImpl.GuarantorRepositoryImp -import org.mifos.mobile.core.data.repositoryImpl.HomeRepositoryImp -import org.mifos.mobile.core.data.repositoryImpl.LoanRepositoryImp -import org.mifos.mobile.core.data.repositoryImpl.NotificationRepositoryImp -import org.mifos.mobile.core.data.repositoryImpl.RecentTransactionRepositoryImp -import org.mifos.mobile.core.data.repositoryImpl.ReviewLoanApplicationRepositoryImpl -import org.mifos.mobile.core.data.repositoryImpl.SavingsAccountRepositoryImp -import org.mifos.mobile.core.data.repositoryImpl.ThirdPartyTransferRepositoryImp -import org.mifos.mobile.core.data.repositoryImpl.TransferRepositoryImp -import org.mifos.mobile.core.data.repositoryImpl.UserAuthRepositoryImp -import org.mifos.mobile.core.data.repositoryImpl.UserDetailRepositoryImp -import org.mifos.mobile.core.data.utils.ConnectivityManagerNetworkMonitor -import org.mifos.mobile.core.data.utils.NetworkMonitor - -@Module -@InstallIn(SingletonComponent::class) -abstract class RepositoryModule { - - @Binds - internal abstract fun bindsUserDataRepository( - authenticationUserRepository: AuthenticationUserRepository, - ): UserDataRepository - - @Binds - internal abstract fun bindsNetworkMonitor( - networkMonitor: ConnectivityManagerNetworkMonitor, - ): NetworkMonitor - - @Binds - internal abstract fun providesUserAuthRepository( - repository: UserAuthRepositoryImp, - ): UserAuthRepository - - @Binds - internal abstract fun providesSavingsAccountRepository( - repository: SavingsAccountRepositoryImp, - ): SavingsAccountRepository - - @Binds - internal abstract fun providesLoanRepository(repository: LoanRepositoryImp): LoanRepository - - @Binds - internal abstract fun providesNotificationRepository( - repository: NotificationRepositoryImp, - ): NotificationRepository - - @Binds - internal abstract fun providesClientRepository(repository: ClientRepositoryImp): ClientRepository - - @Binds - internal abstract fun providesRecentTransactionRepository( - repository: RecentTransactionRepositoryImp, - ): RecentTransactionRepository - - @Binds - internal abstract fun provideAccountsRepository( - repository: AccountsRepositoryImp, - ): AccountsRepository - - @Binds - internal abstract fun providesGuarantorRepository( - repository: GuarantorRepositoryImp, - ): GuarantorRepository - - @Binds - internal abstract fun providesBeneficiaryRepository( - repository: BeneficiaryRepositoryImp, - ): BeneficiaryRepository - - @Binds - internal abstract fun providesTransferRepository( - repository: TransferRepositoryImp, - ): TransferRepository - - @Binds - internal abstract fun providesThirdPartyTransferRepository( - repository: ThirdPartyTransferRepositoryImp, - ): ThirdPartyTransferRepository - - @Binds - internal abstract fun providesClientChargeRepository( - repository: ClientChargeRepositoryImp, - ): ClientChargeRepository - - @Binds - internal abstract fun providesHomeRepository(repository: HomeRepositoryImp): HomeRepository - - @Binds - internal abstract fun providesUserDetailRepository( - repository: UserDetailRepositoryImp, - ): UserDetailRepository - - @Binds - internal abstract fun providesReviewLoanApplicationRepository( - repository: ReviewLoanApplicationRepositoryImpl, - ): ReviewLoanApplicationRepository -} diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/AuthenticationUserRepository.kt b/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/AuthenticationUserRepository.kt deleted file mode 100644 index 739ab6b1d..000000000 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/AuthenticationUserRepository.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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/mobile-mobile/blob/master/LICENSE.md - */ -package org.mifos.mobile.core.data.repositoryImpl - -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flow -import org.mifos.mobile.core.data.repository.UserDataRepository -import org.mifos.mobile.core.datastore.PreferencesHelper -import org.mifos.mobile.core.model.UserData -import javax.inject.Inject - -class AuthenticationUserRepository @Inject constructor( - private val preferencesHelper: PreferencesHelper, -) : UserDataRepository { - - override val userData: Flow = flow { - emit( - UserData( - isAuthenticated = !preferencesHelper.token.isNullOrEmpty(), - userName = preferencesHelper.userName ?: "", - clientId = preferencesHelper.clientId ?: 0, - ), - ) - } - - override fun logOut() { - preferencesHelper.clear() - } -} diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/BeneficiaryRepositoryImp.kt b/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/BeneficiaryRepositoryImp.kt deleted file mode 100644 index c76e79cfb..000000000 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/BeneficiaryRepositoryImp.kt +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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/mobile-mobile/blob/master/LICENSE.md - */ -package org.mifos.mobile.core.data.repositoryImpl - -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flow -import okhttp3.ResponseBody -import org.mifos.mobile.core.data.repository.BeneficiaryRepository -import org.mifos.mobile.core.model.entity.beneficiary.Beneficiary -import org.mifos.mobile.core.model.entity.beneficiary.BeneficiaryPayload -import org.mifos.mobile.core.model.entity.beneficiary.BeneficiaryUpdatePayload -import org.mifos.mobile.core.model.entity.templates.beneficiary.BeneficiaryTemplate -import org.mifos.mobile.core.network.DataManager -import javax.inject.Inject - -class BeneficiaryRepositoryImp @Inject constructor( - private val dataManager: DataManager, -) : BeneficiaryRepository { - - override suspend fun beneficiaryTemplate(): Flow { - return flow { - emit(dataManager.beneficiaryTemplate()) - } - } - - override suspend fun createBeneficiary(beneficiaryPayload: BeneficiaryPayload?): Flow { - return flow { - emit(dataManager.createBeneficiary(beneficiaryPayload)) - } - } - - override suspend fun updateBeneficiary( - beneficiaryId: Long?, - payload: BeneficiaryUpdatePayload?, - ): Flow { - return flow { - emit(dataManager.updateBeneficiary(beneficiaryId, payload)) - } - } - - override suspend fun deleteBeneficiary(beneficiaryId: Long?): Flow { - return flow { - emit(dataManager.deleteBeneficiary(beneficiaryId)) - } - } - - override suspend fun beneficiaryList(): Flow> { - return flow { - emit(dataManager.beneficiaryList()) - } - } -} diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/ClientRepositoryImp.kt b/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/ClientRepositoryImp.kt deleted file mode 100644 index 22eb11e66..000000000 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/ClientRepositoryImp.kt +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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/mobile-mobile/blob/master/LICENSE.md - */ -package org.mifos.mobile.core.data.repositoryImpl - -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flow -import okhttp3.Credentials -import org.mifos.mobile.core.data.repository.ClientRepository -import org.mifos.mobile.core.datastore.PreferencesHelper -import org.mifos.mobile.core.model.entity.Page -import org.mifos.mobile.core.model.entity.User -import org.mifos.mobile.core.model.entity.client.Client -import org.mifos.mobile.core.network.DataManager -import org.mifos.mobile.core.network.SelfServiceOkHttpClient -import retrofit2.Retrofit -import javax.inject.Inject - -class ClientRepositoryImp @Inject constructor( - private val dataManager: DataManager, - private val preferencesHelper: PreferencesHelper, - private var retrofit: Retrofit, -) : ClientRepository { - - override suspend fun loadClient(): Flow> { - return flow { - emit(dataManager.clients()) - } - } - - /** - * Save the authentication token from the server and the user ID. - * The authentication token would be used for accessing the authenticated - * APIs. - * - * @param user - The user that is to be saved. - */ - override fun saveAuthenticationTokenForSession(user: User) { - val authToken = - org.mifos.mobile.core.common.Constants.BASIC + user.base64EncodedAuthenticationKey - preferencesHelper.userName = user.username - preferencesHelper.userId = user.userId - preferencesHelper.saveToken(authToken) - reInitializeService() - } - - override fun setClientId(clientId: Long?) { - preferencesHelper.clientId = clientId - dataManager.clientId = clientId - } - - override fun clearPrefHelper() { - preferencesHelper.clear() - } - - override fun reInitializeService() { - retrofit.newBuilder().client( - SelfServiceOkHttpClient( - preferencesHelper, - ).mifosOkHttpClient, - ) - } - - override fun updateAuthenticationToken(password: String) { - val authenticationToken = Credentials.basic(preferencesHelper.userName!!, password) - preferencesHelper.saveToken(authenticationToken) - reInitializeService() - } -} diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/GuarantorRepositoryImp.kt b/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/GuarantorRepositoryImp.kt deleted file mode 100644 index 4f5d65765..000000000 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/GuarantorRepositoryImp.kt +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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/mobile-mobile/blob/master/LICENSE.md - */ -package org.mifos.mobile.core.data.repositoryImpl - -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flow -import okhttp3.ResponseBody -import org.mifos.mobile.core.data.repository.GuarantorRepository -import org.mifos.mobile.core.model.entity.guarantor.GuarantorApplicationPayload -import org.mifos.mobile.core.model.entity.guarantor.GuarantorPayload -import org.mifos.mobile.core.model.entity.guarantor.GuarantorTemplatePayload -import org.mifos.mobile.core.network.DataManager -import javax.inject.Inject - -class GuarantorRepositoryImp @Inject constructor( - private val dataManager: DataManager, -) : GuarantorRepository { - - override fun getGuarantorTemplate(loanId: Long?): Flow { - return flow { - emit(dataManager.getGuarantorTemplate(loanId)) - } - } - - override fun createGuarantor( - loanId: Long?, - payload: GuarantorApplicationPayload?, - ): Flow { - return flow { - emit(dataManager.createGuarantor(loanId, payload)) - } - } - - override fun updateGuarantor( - payload: GuarantorApplicationPayload?, - loanId: Long?, - guarantorId: Long?, - ): Flow { - return flow { - emit(dataManager.updateGuarantor(payload, loanId, guarantorId)) - } - } - - override fun deleteGuarantor(loanId: Long?, guarantorId: Long?): Flow { - return flow { - emit(dataManager.deleteGuarantor(loanId, guarantorId)) - } - } - - override fun getGuarantorList(loanId: Long): Flow?> { - return flow { - emit(dataManager.getGuarantorList(loanId)) - } - } -} diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/HomeRepositoryImp.kt b/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/HomeRepositoryImp.kt deleted file mode 100644 index 1fac1b4fe..000000000 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/HomeRepositoryImp.kt +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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/mobile-mobile/blob/master/LICENSE.md - */ -package org.mifos.mobile.core.data.repositoryImpl - -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flow -import okhttp3.ResponseBody -import org.mifos.mobile.core.data.repository.HomeRepository -import org.mifos.mobile.core.data.repository.NotificationRepository -import org.mifos.mobile.core.model.entity.client.Client -import org.mifos.mobile.core.model.entity.client.ClientAccounts -import org.mifos.mobile.core.network.DataManager -import javax.inject.Inject - -class HomeRepositoryImp @Inject constructor( - private val dataManager: DataManager, - private val notificationRepository: NotificationRepository, -) : HomeRepository { - - override fun clientAccounts(): Flow { - return flow { - emit(dataManager.clientAccounts()) - } - } - - override fun currentClient(): Flow { - return flow { - emit(dataManager.currentClient()) - } - } - - override fun clientImage(): Flow { - return flow { - emit(dataManager.clientImage()) - } - } - - override suspend fun unreadNotificationsCount(): Flow { - return notificationRepository.getUnReadNotificationCount() - } -} diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/LoanRepositoryImp.kt b/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/LoanRepositoryImp.kt deleted file mode 100644 index 2cb4a584b..000000000 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/LoanRepositoryImp.kt +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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/mobile-mobile/blob/master/LICENSE.md - */ -package org.mifos.mobile.core.data.repositoryImpl - -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flow -import okhttp3.ResponseBody -import org.mifos.mobile.core.data.repository.LoanRepository -import org.mifos.mobile.core.model.entity.accounts.loan.LoanWithAssociations -import org.mifos.mobile.core.model.entity.accounts.loan.LoanWithdraw -import org.mifos.mobile.core.model.entity.templates.loans.LoanTemplate -import org.mifos.mobile.core.network.DataManager -import javax.inject.Inject - -class LoanRepositoryImp @Inject constructor( - private val dataManager: DataManager, -) : LoanRepository { - - override fun getLoanWithAssociations( - associationType: String?, - loanId: Long?, - ): Flow { - return flow { - emit(dataManager.getLoanWithAssociations(associationType, loanId)) - } - } - - override fun withdrawLoanAccount( - loanId: Long?, - loanWithdraw: LoanWithdraw?, - ): Flow? { - return flow { - emit(dataManager.withdrawLoanAccount(loanId, loanWithdraw)) - } - } - - override fun template(): Flow { - return flow { - emit(dataManager.loanTemplate()) - } - } - - override fun getLoanTemplateByProduct(productId: Int?): Flow { - return flow { - emit(dataManager.getLoanTemplateByProduct(productId)) - } - } -} diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/SavingsAccountRepositoryImp.kt b/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/SavingsAccountRepositoryImp.kt deleted file mode 100644 index e02331a7e..000000000 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/SavingsAccountRepositoryImp.kt +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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/mobile-mobile/blob/master/LICENSE.md - */ -package org.mifos.mobile.core.data.repositoryImpl - -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flow -import okhttp3.ResponseBody -import org.mifos.mobile.core.data.repository.SavingsAccountRepository -import org.mifos.mobile.core.model.entity.accounts.savings.SavingsAccountApplicationPayload -import org.mifos.mobile.core.model.entity.accounts.savings.SavingsAccountUpdatePayload -import org.mifos.mobile.core.model.entity.accounts.savings.SavingsAccountWithdrawPayload -import org.mifos.mobile.core.model.entity.accounts.savings.SavingsWithAssociations -import org.mifos.mobile.core.model.entity.templates.account.AccountOptionsTemplate -import org.mifos.mobile.core.model.entity.templates.savings.SavingsAccountTemplate -import org.mifos.mobile.core.network.DataManager -import javax.inject.Inject - -class SavingsAccountRepositoryImp @Inject constructor( - private val dataManager: DataManager, -) : SavingsAccountRepository { - - override suspend fun getSavingsWithAssociations( - accountId: Long?, - associationType: String?, - ): Flow { - return flow { - emit(dataManager.getSavingsWithAssociations(accountId, associationType)) - } - } - - override suspend fun getSavingAccountApplicationTemplate( - clientId: Long?, - ): Flow { - return flow { - emit(dataManager.getSavingAccountApplicationTemplate(clientId)) - } - } - - override suspend fun submitSavingAccountApplication( - payload: SavingsAccountApplicationPayload?, - ): Flow { - return flow { - emit(dataManager.submitSavingAccountApplication(payload)) - } - } - - override suspend fun updateSavingsAccount( - accountId: Long?, - payload: SavingsAccountUpdatePayload?, - ): Flow { - return flow { - emit(dataManager.updateSavingsAccount(accountId, payload)) - } - } - - override suspend fun submitWithdrawSavingsAccount( - accountId: String?, - payload: SavingsAccountWithdrawPayload?, - ): Flow { - return flow { - emit(dataManager.submitWithdrawSavingsAccount(accountId, payload)) - } - } - - override fun accountTransferTemplate( - accountId: Long?, - accountType: Long?, - ): Flow { - return flow { - emit( - dataManager.accountTransferTemplate( - accountId = accountType, - accountType = accountType, - ), - ) - } - } -} diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/TransferRepositoryImp.kt b/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/TransferRepositoryImp.kt deleted file mode 100644 index 61d4495b5..000000000 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/TransferRepositoryImp.kt +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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/mobile-mobile/blob/master/LICENSE.md - */ -package org.mifos.mobile.core.data.repositoryImpl - -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flow -import okhttp3.ResponseBody -import org.mifos.mobile.core.data.repository.TransferRepository -import org.mifos.mobile.core.model.entity.payload.TransferPayload -import org.mifos.mobile.core.model.enums.TransferType -import org.mifos.mobile.core.network.DataManager -import javax.inject.Inject - -class TransferRepositoryImp @Inject constructor( - private val dataManager: DataManager, -) : TransferRepository { - override suspend fun makeTransfer( - fromOfficeId: Int?, - fromClientId: Long?, - fromAccountType: Int?, - fromAccountId: Int?, - toOfficeId: Int?, - toClientId: Long?, - toAccountType: Int?, - toAccountId: Int?, - transferDate: String?, - transferAmount: Double?, - transferDescription: String?, - dateFormat: String, - locale: String, - fromAccountNumber: String?, - toAccountNumber: String?, - transferType: TransferType?, - ): Flow { - val transferPayload = TransferPayload().apply { - this.fromOfficeId = fromOfficeId - this.fromClientId = fromClientId - this.fromAccountType = fromAccountType - this.fromAccountId = fromAccountId - this.toOfficeId = toOfficeId - this.toClientId = toClientId - this.toAccountType = toAccountType - this.toAccountId = toAccountId - this.transferDate = transferDate - this.transferAmount = transferAmount - this.transferDescription = transferDescription - this.dateFormat = dateFormat - this.locale = locale - this.fromAccountNumber = fromAccountNumber - this.toAccountNumber = toAccountNumber - } - return flow { - emit( - when (transferType) { - TransferType.SELF -> dataManager.makeTransfer(transferPayload) - else -> dataManager.makeThirdPartyTransfer(transferPayload) - }, - ) - } - } -} diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/UserAuthRepositoryImp.kt b/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/UserAuthRepositoryImp.kt deleted file mode 100644 index eb03ad7bd..000000000 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/UserAuthRepositoryImp.kt +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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/mobile-mobile/blob/master/LICENSE.md - */ -package org.mifos.mobile.core.data.repositoryImpl - -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flow -import okhttp3.ResponseBody -import org.mifos.mobile.core.data.repository.UserAuthRepository -import org.mifos.mobile.core.model.entity.UpdatePasswordPayload -import org.mifos.mobile.core.model.entity.User -import org.mifos.mobile.core.model.entity.payload.LoginPayload -import org.mifos.mobile.core.model.entity.register.RegisterPayload -import org.mifos.mobile.core.model.entity.register.UserVerify -import org.mifos.mobile.core.network.DataManager -import javax.inject.Inject - -class UserAuthRepositoryImp @Inject constructor( - private val dataManager: DataManager, -) : UserAuthRepository { - - override suspend fun registerUser( - accountNumber: String?, - authenticationMode: String?, - email: String?, - firstName: String?, - lastName: String?, - mobileNumber: String?, - password: String?, - username: String?, - ): Flow { - val registerPayload = RegisterPayload().apply { - this.accountNumber = accountNumber - this.authenticationMode = authenticationMode - this.email = email - this.firstName = firstName - this.lastName = lastName - this.mobileNumber = mobileNumber - this.password = password - this.username = username - } - return flow { - emit(dataManager.registerUser(registerPayload)) - } - } - - override suspend fun login(username: String, password: String): Flow { - val loginPayload = LoginPayload( - username = username, - password = password, - ) - - return flow { - emit(dataManager.login(loginPayload)) - } - } - - override suspend fun verifyUser( - authenticationToken: String?, - requestId: String?, - ): Flow { - val userVerify = UserVerify().apply { - this.authenticationToken = authenticationToken - this.requestId = requestId - } - return flow { - emit(dataManager.verifyUser(userVerify)) - } - } - - override suspend fun updateAccountPassword( - newPassword: String, - confirmPassword: String, - ): Flow { - val payload = UpdatePasswordPayload().apply { - this.password = newPassword - this.repeatPassword = confirmPassword - } - - return flow { - emit(dataManager.updateAccountPassword(payload)) - } - } -} diff --git a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/UserDetailRepositoryImp.kt b/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/UserDetailRepositoryImp.kt deleted file mode 100644 index 33f2a7a04..000000000 --- a/core/data/src/main/java/org/mifos/mobile/core/data/repositoryImpl/UserDetailRepositoryImp.kt +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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/mobile-mobile/blob/master/LICENSE.md - */ -package org.mifos.mobile.core.data.repositoryImpl - -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flow -import okhttp3.ResponseBody -import org.mifos.mobile.core.data.repository.UserDetailRepository -import org.mifos.mobile.core.model.entity.notification.NotificationRegisterPayload -import org.mifos.mobile.core.model.entity.notification.NotificationUserDetail -import org.mifos.mobile.core.network.DataManager -import javax.inject.Inject - -class UserDetailRepositoryImp @Inject constructor( - private val dataManager: DataManager, -) : UserDetailRepository { - - override fun registerNotification(payload: NotificationRegisterPayload?): Flow { - return flow { - emit(dataManager.registerNotification(payload)) - } - } - - override fun getUserNotificationId(id: Long): Flow { - return flow { - emit(dataManager.getUserNotificationId(id)) - } - } - - override fun updateRegisterNotification( - id: Long, - payload: NotificationRegisterPayload?, - ): Flow { - return flow { - emit(dataManager.updateRegisterNotification(id, payload)) - } - } -} diff --git a/core/data/src/nativeMain/kotlin/org/mifos/mobile/core/data/NativePlatformDependentDataModule.kt b/core/data/src/nativeMain/kotlin/org/mifos/mobile/core/data/NativePlatformDependentDataModule.kt new file mode 100644 index 000000000..bd1453513 --- /dev/null +++ b/core/data/src/nativeMain/kotlin/org/mifos/mobile/core/data/NativePlatformDependentDataModule.kt @@ -0,0 +1,23 @@ +/* + * 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/mobile-mobile/blob/master/LICENSE.md + */ +package org.mifospay.core.data + +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flowOf +import org.mifos.mobile.core.data.di.PlatformDependentDataModule +import org.mifos.mobile.core.data.util.NetworkMonitor + +class NativePlatformDependentDataModule : PlatformDependentDataModule { + override val networkMonitor: NetworkMonitor by lazy { + object : NetworkMonitor { + override val isOnline: Flow = flowOf(true) + } + } +} diff --git a/core/data/src/nativeMain/kotlin/org/mifos/mobile/core/data/di/PlatformDependentDataModule.native.kt b/core/data/src/nativeMain/kotlin/org/mifos/mobile/core/data/di/PlatformDependentDataModule.native.kt new file mode 100644 index 000000000..4c6d4d71a --- /dev/null +++ b/core/data/src/nativeMain/kotlin/org/mifos/mobile/core/data/di/PlatformDependentDataModule.native.kt @@ -0,0 +1,22 @@ +/* + * 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/mobile-mobile/blob/master/LICENSE.md + */ +package org.mifos.mobile.core.data.di + +import org.koin.core.module.Module +import org.koin.dsl.module +import org.mifospay.core.data.NativePlatformDependentDataModule + +actual val getPlatformDataModule: PlatformDependentDataModule + get() = NativePlatformDependentDataModule() + +actual val platformModule: Module + get() = module { + single { getPlatformDataModule } + } diff --git a/core/data/src/wasmJsMain/kotlin/org/mifos/mobile/core/data/JsPlatformDependentDataModule.kt b/core/data/src/wasmJsMain/kotlin/org/mifos/mobile/core/data/JsPlatformDependentDataModule.kt new file mode 100644 index 000000000..bc7aea8e0 --- /dev/null +++ b/core/data/src/wasmJsMain/kotlin/org/mifos/mobile/core/data/JsPlatformDependentDataModule.kt @@ -0,0 +1,23 @@ +/* + * 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/mobile-mobile/blob/master/LICENSE.md + */ +package org.mifospay.core.data + +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flowOf +import org.mifos.mobile.core.data.di.PlatformDependentDataModule +import org.mifos.mobile.core.data.util.NetworkMonitor + +class JsPlatformDependentDataModule : PlatformDependentDataModule { + override val networkMonitor: NetworkMonitor by lazy { + object : NetworkMonitor { + override val isOnline: Flow = flowOf(true) + } + } +} diff --git a/core/data/src/wasmJsMain/kotlin/org/mifos/mobile/core/data/di/PlatformDependentDataModule.wasmJs.kt b/core/data/src/wasmJsMain/kotlin/org/mifos/mobile/core/data/di/PlatformDependentDataModule.wasmJs.kt new file mode 100644 index 000000000..1970d8c94 --- /dev/null +++ b/core/data/src/wasmJsMain/kotlin/org/mifos/mobile/core/data/di/PlatformDependentDataModule.wasmJs.kt @@ -0,0 +1,22 @@ +/* + * 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/mobile-mobile/blob/master/LICENSE.md + */ +package org.mifos.mobile.core.data.di + +import org.koin.core.module.Module +import org.koin.dsl.module +import org.mifospay.core.data.JsPlatformDependentDataModule + +actual val getPlatformDataModule: PlatformDependentDataModule + get() = JsPlatformDependentDataModule() + +actual val platformModule: Module + get() = module { + single { getPlatformDataModule } + } diff --git a/core/datastore/src/commonMain/kotlin/org/mifos/mobile/core/datastore/UserPreferencesDataSource.kt b/core/datastore/src/commonMain/kotlin/org/mifos/mobile/core/datastore/UserPreferencesDataSource.kt index 12cd51e1f..435afcb4f 100644 --- a/core/datastore/src/commonMain/kotlin/org/mifos/mobile/core/datastore/UserPreferencesDataSource.kt +++ b/core/datastore/src/commonMain/kotlin/org/mifos/mobile/core/datastore/UserPreferencesDataSource.kt @@ -93,6 +93,18 @@ class UserPreferencesDataSource( ) } } + suspend fun updateClientId(clientId: Long) { + withContext(dispatcher) { + settings.putUserPreference( + UserData.DEFAULT.copy( + clientId = clientId, + ), + ) + _userInfo.value = UserData.DEFAULT.copy( + clientId = clientId, + ) + } + } suspend fun updateTheme(theme: AppTheme) { withContext(dispatcher) { diff --git a/core/datastore/src/commonMain/kotlin/org/mifos/mobile/core/datastore/UserPreferencesRepository.kt b/core/datastore/src/commonMain/kotlin/org/mifos/mobile/core/datastore/UserPreferencesRepository.kt index 8ffb4ee89..dcb5819a4 100644 --- a/core/datastore/src/commonMain/kotlin/org/mifos/mobile/core/datastore/UserPreferencesRepository.kt +++ b/core/datastore/src/commonMain/kotlin/org/mifos/mobile/core/datastore/UserPreferencesRepository.kt @@ -39,5 +39,7 @@ interface UserPreferencesRepository { suspend fun updateProfileImage(image: String): DataState + suspend fun updateClientId(clientId: Long?): DataState + suspend fun logOut(): Unit } diff --git a/core/datastore/src/commonMain/kotlin/org/mifos/mobile/core/datastore/UserPreferencesRepositoryImpl.kt b/core/datastore/src/commonMain/kotlin/org/mifos/mobile/core/datastore/UserPreferencesRepositoryImpl.kt index accc4750c..14b931460 100644 --- a/core/datastore/src/commonMain/kotlin/org/mifos/mobile/core/datastore/UserPreferencesRepositoryImpl.kt +++ b/core/datastore/src/commonMain/kotlin/org/mifos/mobile/core/datastore/UserPreferencesRepositoryImpl.kt @@ -101,6 +101,15 @@ class UserPreferencesRepositoryImpl( } } + override suspend fun updateClientId(clientId: Long?): DataState { + return try { + val result = preferenceManager.updateClientId(clientId!!) + DataState.Success(result) + } catch (e: Exception) { + DataState.Error(e) + } + } + override suspend fun logOut() { preferenceManager.clearInfo() } diff --git a/core/model/src/commonMain/kotlin/org/mifos/mobile/core/model/entity/UpdatePasswordPayload.kt b/core/model/src/commonMain/kotlin/org/mifos/mobile/core/model/entity/UpdatePasswordPayload.kt index 003a585ec..2088c8540 100644 --- a/core/model/src/commonMain/kotlin/org/mifos/mobile/core/model/entity/UpdatePasswordPayload.kt +++ b/core/model/src/commonMain/kotlin/org/mifos/mobile/core/model/entity/UpdatePasswordPayload.kt @@ -12,9 +12,7 @@ package org.mifos.mobile.core.model.entity /* * Created by saksham on 13/July/2018 */ -class UpdatePasswordPayload { - - val password: String? = null - - val repeatPassword: String? = null -} +data class UpdatePasswordPayload( + val password: String? = null, + val repeatPassword: String? = null, +) diff --git a/core/network/src/commonMain/kotlin/org/mifos/mobile/core/network/DataManager.kt b/core/network/src/commonMain/kotlin/org/mifos/mobile/core/network/DataManager.kt index 6470cd419..4eff251dd 100644 --- a/core/network/src/commonMain/kotlin/org/mifos/mobile/core/network/DataManager.kt +++ b/core/network/src/commonMain/kotlin/org/mifos/mobile/core/network/DataManager.kt @@ -13,27 +13,27 @@ class DataManager( private val ktorfitClient: KtorfitClient, ) { - internal val authenticationApi by lazy { ktorfitClient.authenticationApi } + val authenticationApi by lazy { ktorfitClient.authenticationApi } - internal val beneficiaryApi by lazy { ktorfitClient.beneficiaryApi } + val beneficiaryApi by lazy { ktorfitClient.beneficiaryApi } - internal val clientsApi by lazy { ktorfitClient.clientsApi } + val clientsApi by lazy { ktorfitClient.clientsApi } - internal val loanAccountsListApi by lazy { ktorfitClient.loanAccountsListApi } + val loanAccountsListApi by lazy { ktorfitClient.loanAccountsListApi } - internal val savingAccountsListApi by lazy { ktorfitClient.savingAccountsListApi } + val savingAccountsListApi by lazy { ktorfitClient.savingAccountsListApi } - internal val recentTransactionsApi by lazy { ktorfitClient.recentTransactionsApi } + val recentTransactionsApi by lazy { ktorfitClient.recentTransactionsApi } - internal val clientChargeApi by lazy { ktorfitClient.clientChargeApi } + val clientChargeApi by lazy { ktorfitClient.clientChargeApi } - internal val thirdPartyTransferApi by lazy { ktorfitClient.thirdPartyTransferApi } + val thirdPartyTransferApi by lazy { ktorfitClient.thirdPartyTransferApi } - internal val registrationApi by lazy { ktorfitClient.registrationApi } + val registrationApi by lazy { ktorfitClient.registrationApi } - internal val notificationApi by lazy { ktorfitClient.notificationApi } + val notificationApi by lazy { ktorfitClient.notificationApi } - internal val userDetailsApi by lazy { ktorfitClient.userDetailsApi } + val userDetailsApi by lazy { ktorfitClient.userDetailsApi } - internal val guarantorApi by lazy { ktorfitClient.guarantorApi } + val guarantorApi by lazy { ktorfitClient.guarantorApi } } From 24d62efb10ea876dc38f7c7ce12d0b99c914d8bc Mon Sep 17 00:00:00 2001 From: Nagarjuna0033 Date: Fri, 17 Jan 2025 16:06:09 +0530 Subject: [PATCH 2/3] fix: repositoryImpl --- .../mobile/core/data/di/RepositoryModule.kt | 4 +- .../mifos/mobile/core/data/mapper/Charge.kt | 135 ++++++++++++++++++ .../{model => mapper}/MifosNotification.kt | 19 ++- .../mifos/mobile/core/data/model/Charge.kt | 95 ------------ .../core/data/repository/ClientRepository.kt | 9 -- .../ClientChargeRepositoryImp.kt | 31 ++-- .../repositoryImpl/ClientRepositoryImp.kt | 69 --------- .../NotificationRepositoryImp.kt | 48 +++---- .../datastore/UserPreferencesDataSource.kt | 38 +++-- .../datastore/UserPreferencesRepository.kt | 2 +- .../UserPreferencesRepositoryImpl.kt | 4 +- 11 files changed, 212 insertions(+), 242 deletions(-) create mode 100644 core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/mapper/Charge.kt rename core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/{model => mapper}/MifosNotification.kt (58%) delete mode 100644 core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/model/Charge.kt diff --git a/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/di/RepositoryModule.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/di/RepositoryModule.kt index d21829293..f56eaca0a 100644 --- a/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/di/RepositoryModule.kt +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/di/RepositoryModule.kt @@ -57,11 +57,11 @@ val RepositoryModule = module { single { AuthenticationUserRepository(get(), get(ioDispatcher)) } single { BeneficiaryRepositoryImp(get(), get(ioDispatcher)) } single { ClientChargeRepositoryImp(get(), get(ioDispatcher)) } // TODO - single { ClientRepositoryImp(get(), get(), get(ioDispatcher)) } + single { ClientRepositoryImp(get(), get(ioDispatcher)) } single { GuarantorRepositoryImp(get(), get(ioDispatcher)) } single { HomeRepositoryImp(get(), get(), get(ioDispatcher)) } single { LoanRepositoryImp(get(), get(ioDispatcher)) } - single { NotificationRepositoryImp(get(), get(ioDispatcher)) } // TODO + single { NotificationRepositoryImp(get(ioDispatcher)) } // TODO single { RecentTransactionRepositoryImp(get(), get(ioDispatcher)) } single { ReviewLoanApplicationRepositoryImpl(get(), get(ioDispatcher)) } single { SavingsAccountRepositoryImp(get(), get(ioDispatcher)) } diff --git a/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/mapper/Charge.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/mapper/Charge.kt new file mode 100644 index 000000000..afd659e22 --- /dev/null +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/mapper/Charge.kt @@ -0,0 +1,135 @@ +/* + * 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/mobile-mobile/blob/master/LICENSE.md + */ +package org.mifos.mobile.core.data.mapper + +import org.mifos.mobile.core.model.entity.Charge +import org.mifos.mobile.core.model.entity.ChargeCalculationType +import org.mifos.mobile.core.model.entity.ChargeTimeType +import org.mifos.mobile.core.model.entity.Currency + +// fun ChargeEntity.toCharge(): Charge { +// return Charge( +// clientId = clientId, +// chargeId = chargeId, +// name = name, +// dueDate = dueDate, +// chargeTimeType = ChargeTimeType( +// id = chargeTimeType?.id ?: 0, +// code = chargeTimeType?.code, +// value = chargeTimeType?.value, +// ), +// chargeCalculationType = ChargeCalculationType( +// id = chargeCalculationType?.id ?: 0, +// code = chargeCalculationType?.code, +// value = chargeCalculationType?.value, +// ), +// currency = Currency( +// code = currency?.code, +// name = currency?.name, +// decimalPlaces = currency?.decimalPlaces ?: 0, +// displaySymbol = currency?.displaySymbol, +// nameCode = currency?.nameCode, +// displayLabel = currency?.displayLabel, +// ), +// amount = amount, +// amountPaid = amountPaid, +// amountWaived = amountWaived, +// amountWrittenOff = amountWrittenOff, +// amountOutstanding = amountOutstanding, +// penalty = penalty, +// isActive = isActive, +// isChargePaid = isChargePaid, +// isChargeWaived = isChargeWaived, +// paid = paid, +// waived = waived, +// ) +// } +// +// fun Charge.toChargeEntity(): ChargeEntity { +// return ChargeEntity( +// clientId = clientId, +// chargeId = chargeId, +// name = name, +// dueDate = dueDate, +// chargeTimeType = ChargeTimeTypeEntity( +// id = chargeTimeType?.id ?: 0, +// code = chargeTimeType?.code, +// value = chargeTimeType?.value, +// ), +// chargeCalculationType = ChargeCalculationTypeEntity( +// id = chargeCalculationType?.id ?: 0, +// code = chargeCalculationType?.code, +// value = chargeCalculationType?.value, +// ), +// currency = CurrencyEntity( +// code = currency?.code, +// name = currency?.name, +// decimalPlaces = currency?.decimalPlaces ?: 0, +// displaySymbol = currency?.displaySymbol, +// nameCode = currency?.nameCode, +// displayLabel = currency?.displayLabel, +// ), +// amount = amount, +// amountPaid = amountPaid, +// amountWaived = amountWaived, +// amountWrittenOff = amountWrittenOff, +// amountOutstanding = amountOutstanding, +// penalty = penalty, +// isActive = isActive, +// isChargePaid = isChargePaid, +// isChargeWaived = isChargeWaived, +// paid = paid, +// waived = waived, +// ) +// } + +fun Charge.toModel(): Charge { + return Charge( + clientId = clientId, + chargeId = chargeId, + name = name, + dueDate = dueDate, + chargeTimeType = chargeTimeType?.let { + ChargeTimeType( + id = it.id, + code = it.code, + value = it.value, + ) + }, + chargeCalculationType = chargeCalculationType?.let { + ChargeCalculationType( + id = it.id, + code = it.code, + value = it.value, + ) + }, + currency = currency?.let { + Currency( + code = it.code, + name = it.name, + decimalPlaces = it.decimalPlaces, + displaySymbol = it.displaySymbol, + nameCode = it.nameCode, + displayLabel = it.displayLabel, + ) + }, + amount = amount, + amountPaid = amountPaid, + amountWaived = amountWaived, + amountWrittenOff = amountWrittenOff, + amountOutstanding = amountOutstanding, + penalty = penalty, + isActive = isActive, + isChargePaid = isChargePaid, + isChargeWaived = isChargeWaived, + paid = paid, + waived = waived, + ) +} diff --git a/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/model/MifosNotification.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/mapper/MifosNotification.kt similarity index 58% rename from core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/model/MifosNotification.kt rename to core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/mapper/MifosNotification.kt index b63849ae7..64f9f5ac8 100644 --- a/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/model/MifosNotification.kt +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/mapper/MifosNotification.kt @@ -7,20 +7,19 @@ * * See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md */ -package org.mifos.mobile.core.data.model +package org.mifos.mobile.core.data.mapper -import org.mifos.mobile.core.database.entity.MifosNotificationEntity import org.mifos.mobile.core.model.entity.MifosNotification -fun MifosNotification.toEntity(): MifosNotificationEntity { - return MifosNotificationEntity( - timeStamp = timeStamp, - msg = msg, - read = read, - ) -} +// fun MifosNotification.toEntity(): MifosNotificationEntity { +// return MifosNotificationEntity( +// timeStamp = timeStamp, +// msg = msg, +// read = read, +// ) +// } -fun MifosNotificationEntity.toModel(): MifosNotification { +fun MifosNotification.toModel(): MifosNotification { return MifosNotification( timeStamp = timeStamp, msg = msg, diff --git a/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/model/Charge.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/model/Charge.kt deleted file mode 100644 index 1a3fbdae8..000000000 --- a/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/model/Charge.kt +++ /dev/null @@ -1,95 +0,0 @@ -/* - * 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/mobile-mobile/blob/master/LICENSE.md - */ -package org.mifos.mobile.core.data.model - -import org.mifos.mobile.core.database.entity.ChargeCalculationTypeEntity -import org.mifos.mobile.core.database.entity.ChargeEntity -import org.mifos.mobile.core.database.entity.ChargeTimeTypeEntity -import org.mifos.mobile.core.database.entity.CurrencyEntity -import org.mifos.mobile.core.model.entity.Charge -import org.mifos.mobile.core.model.entity.ChargeCalculationType -import org.mifos.mobile.core.model.entity.ChargeTimeType -import org.mifos.mobile.core.model.entity.Currency - -fun ChargeEntity.toCharge(): Charge { - return Charge( - clientId = clientId, - chargeId = chargeId, - name = name, - dueDate = dueDate, - chargeTimeType = ChargeTimeType( - id = chargeTimeType?.id ?: 0, - code = chargeTimeType?.code, - value = chargeTimeType?.value, - ), - chargeCalculationType = ChargeCalculationType( - id = chargeCalculationType?.id ?: 0, - code = chargeCalculationType?.code, - value = chargeCalculationType?.value, - ), - currency = Currency( - code = currency?.code, - name = currency?.name, - decimalPlaces = currency?.decimalPlaces ?: 0, - displaySymbol = currency?.displaySymbol, - nameCode = currency?.nameCode, - displayLabel = currency?.displayLabel, - ), - amount = amount, - amountPaid = amountPaid, - amountWaived = amountWaived, - amountWrittenOff = amountWrittenOff, - amountOutstanding = amountOutstanding, - penalty = penalty, - isActive = isActive, - isChargePaid = isChargePaid, - isChargeWaived = isChargeWaived, - paid = paid, - waived = waived, - ) -} - -fun Charge.toChargeEntity(): ChargeEntity { - return ChargeEntity( - clientId = clientId, - chargeId = chargeId, - name = name, - dueDate = dueDate, - chargeTimeType = ChargeTimeTypeEntity( - id = chargeTimeType?.id ?: 0, - code = chargeTimeType?.code, - value = chargeTimeType?.value, - ), - chargeCalculationType = ChargeCalculationTypeEntity( - id = chargeCalculationType?.id ?: 0, - code = chargeCalculationType?.code, - value = chargeCalculationType?.value, - ), - currency = CurrencyEntity( - code = currency?.code, - name = currency?.name, - decimalPlaces = currency?.decimalPlaces ?: 0, - displaySymbol = currency?.displaySymbol, - nameCode = currency?.nameCode, - displayLabel = currency?.displayLabel, - ), - amount = amount, - amountPaid = amountPaid, - amountWaived = amountWaived, - amountWrittenOff = amountWrittenOff, - amountOutstanding = amountOutstanding, - penalty = penalty, - isActive = isActive, - isChargePaid = isChargePaid, - isChargeWaived = isChargeWaived, - paid = paid, - waived = waived, - ) -} diff --git a/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/ClientRepository.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/ClientRepository.kt index ec6b58391..19ba13ec9 100644 --- a/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/ClientRepository.kt +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repository/ClientRepository.kt @@ -11,19 +11,10 @@ package org.mifos.mobile.core.data.repository import kotlinx.coroutines.flow.Flow import org.mifos.mobile.core.model.entity.Page -import org.mifos.mobile.core.model.entity.User import org.mifos.mobile.core.model.entity.client.Client import org.mifospay.core.common.DataState interface ClientRepository { fun loadClient(): Flow>> - - suspend fun saveAuthenticationTokenForSession(user: User): DataState - - suspend fun setClientId(clientId: Long?): DataState - - fun reInitializeService() - - suspend fun updateAuthenticationToken(password: String): DataState } diff --git a/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/ClientChargeRepositoryImp.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/ClientChargeRepositoryImp.kt index 614d1e47b..2676a0841 100644 --- a/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/ClientChargeRepositoryImp.kt +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/ClientChargeRepositoryImp.kt @@ -11,15 +11,12 @@ package org.mifos.mobile.core.data.repositoryImpl import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.flowOn -import kotlinx.coroutines.flow.map import kotlinx.coroutines.withContext import org.mifos.mobile.core.common.Dispatcher import org.mifos.mobile.core.common.MifosDispatchers -import org.mifos.mobile.core.data.model.toCharge -import org.mifos.mobile.core.data.model.toChargeEntity import org.mifos.mobile.core.data.repository.ClientChargeRepository -import org.mifos.mobile.core.database.dao.ChargeDao import org.mifos.mobile.core.model.entity.Charge import org.mifos.mobile.core.model.entity.Page import org.mifos.mobile.core.network.DataManager @@ -28,7 +25,7 @@ import org.mifospay.core.common.asDataStateFlow class ClientChargeRepositoryImp( private val dataManager: DataManager, - private val chargeDao: ChargeDao, +// private val chargeDao: ChargeDao, @Dispatcher(MifosDispatchers.IO) private val ioDispatcher: CoroutineDispatcher, ) : ClientChargeRepository { @@ -48,19 +45,23 @@ class ClientChargeRepositoryImp( .asDataStateFlow().flowOn(ioDispatcher) } - override fun clientLocalCharges(): Flow> { - return chargeDao.getAllLocalCharges().map { chargeList -> - Page(chargeList.size, chargeList.map { it.toCharge() }) - }.flowOn(ioDispatcher) + override fun clientLocalCharges(): Flow>> { +// return chargeDao.getAllLocalCharges().map { chargeList -> +// Page(chargeList.size, chargeList.map { it.toCharge() }) +// }.flowOn(ioDispatcher) + return flowOf(DataState.Success(Page(0, emptyList()))) + .flowOn(ioDispatcher) } - override suspend fun syncCharges(charges: Page?): Page? { + override suspend fun syncCharges(charges: Page?): DataState?> { return withContext(ioDispatcher) { - charges?.pageItems?.let { - chargeDao.syncCharges(it.map { it.toChargeEntity() }) - } - - charges?.copy(pageItems = charges.pageItems) +// charges?.pageItems?.let { +// chargeDao.syncCharges(it.map { it.toChargeEntity() }) +// } +// +// charges?.copy(pageItems = charges.pageItems) + val result = charges?.copy(pageItems = charges.pageItems) ?: Page(0, emptyList()) + DataState.Success(result) } } } diff --git a/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/ClientRepositoryImp.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/ClientRepositoryImp.kt index d2e5dc9e5..b3461f467 100644 --- a/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/ClientRepositoryImp.kt +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/ClientRepositoryImp.kt @@ -9,29 +9,18 @@ */ package org.mifos.mobile.core.data.repositoryImpl -import io.ktor.client.HttpClient import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.firstOrNull import kotlinx.coroutines.flow.flowOn -import kotlinx.coroutines.withContext -import okio.ByteString.Companion.encodeUtf8 -import org.mifos.mobile.core.common.Constants import org.mifos.mobile.core.data.repository.ClientRepository -import org.mifos.mobile.core.datastore.UserPreferencesRepository import org.mifos.mobile.core.model.entity.Page -import org.mifos.mobile.core.model.entity.User import org.mifos.mobile.core.model.entity.client.Client import org.mifos.mobile.core.network.DataManager -import org.mifos.mobile.core.network.KtorfitClient -import org.mifos.mobile.core.network.utils.BaseURL -import org.mifos.mobile.core.network.utils.KtorInterceptorRe import org.mifospay.core.common.DataState import org.mifospay.core.common.asDataStateFlow class ClientRepositoryImp( private val dataManager: DataManager, - private val preferencesHelper: UserPreferencesRepository, private val ioDispatcher: CoroutineDispatcher, ) : ClientRepository { @@ -39,62 +28,4 @@ class ClientRepositoryImp( return dataManager.clientsApi.clients() .asDataStateFlow().flowOn(ioDispatcher) } - - /** - * Save the authentication token from the server and the user ID. - * The authentication token would be used for accessing the authenticated - * APIs. - * - * @param user - The user that is to be saved. - */ - override suspend fun saveAuthenticationTokenForSession(user: User): DataState { - return try { - val authToken = Constants.BASIC + user.base64EncodedAuthenticationKey - preferencesHelper.updateToken(authToken) - reInitializeService() - DataState.Success(Unit) - } catch (e: Exception) { - DataState.Error(e) - } - } - - override suspend fun setClientId(clientId: Long?): DataState { - return try { - withContext(ioDispatcher) { - preferencesHelper.updateClientId(clientId) - } - DataState.Success(Unit) - } catch (e: Exception) { - DataState.Error(e, null) - } - } - - override fun reInitializeService() { - val client = HttpClient { - install(KtorInterceptorRe) { - repository = preferencesHelper - } - } - KtorfitClient.builder() - .baseURL(BaseURL().url) - .httpClient(client) - .build() - } - - override suspend fun updateAuthenticationToken(password: String): DataState { - return try { - withContext(ioDispatcher) { - val username = preferencesHelper.userInfo.firstOrNull()?.userName - val authenticationToken = "Basic " + "$username:$password".encodeToBase64() - preferencesHelper.updateToken(authenticationToken) - } - reInitializeService() - DataState.Success(Unit) - } catch (e: Exception) { - DataState.Error(e, null) - } - } - private fun String.encodeToBase64(): String { - return this.encodeUtf8().base64() - } } diff --git a/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/NotificationRepositoryImp.kt b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/NotificationRepositoryImp.kt index 5eea6b93a..e37bb36c3 100644 --- a/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/NotificationRepositoryImp.kt +++ b/core/data/src/commonMain/kotlin/org/mifos/mobile/core/data/repositoryImpl/NotificationRepositoryImp.kt @@ -11,50 +11,48 @@ package org.mifos.mobile.core.data.repositoryImpl import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.flowOn -import kotlinx.coroutines.flow.map -import kotlinx.coroutines.withContext -import org.mifos.mobile.core.common.Dispatcher -import org.mifos.mobile.core.common.MifosDispatchers -import org.mifos.mobile.core.data.model.toEntity -import org.mifos.mobile.core.data.model.toModel import org.mifos.mobile.core.data.repository.NotificationRepository -import org.mifos.mobile.core.database.dao.MifosNotificationDao import org.mifos.mobile.core.model.entity.MifosNotification +import org.mifospay.core.common.DataState class NotificationRepositoryImp( - private val notificationDao: MifosNotificationDao, - @Dispatcher(MifosDispatchers.IO) +// private val notificationDao: MifosNotificationDao, private val ioDispatcher: CoroutineDispatcher, ) : NotificationRepository { - override fun loadNotifications(): Flow> { - return notificationDao.getNotifications() - .map { it.map { it.toModel() } } + override fun loadNotifications(): Flow>> { +// return notificationDao.getNotifications() +// .map { it.map { it.toModel() } } +// .flowOn(ioDispatcher) + return flowOf(DataState.Success(emptyList())) .flowOn(ioDispatcher) } - override fun getUnReadNotificationCount(): Flow { - return notificationDao.getUnreadNotificationsCount().flowOn(ioDispatcher) + override fun getUnReadNotificationCount(): Flow> { +// return notificationDao.getUnreadNotificationsCount().flowOn(ioDispatcher) + return flowOf(DataState.Success(0)) + .flowOn(ioDispatcher) } override suspend fun saveNotification(notification: MifosNotification) { - withContext(ioDispatcher) { - notificationDao.saveNotification(notification.toEntity()) - } +// withContext(ioDispatcher) { +// notificationDao.saveNotification(notification.toEntity()) +// } } override suspend fun deleteOldNotifications() { - return withContext(ioDispatcher) { - val thirtyDaysInMillis = 2592000000L - val cutoffTime = System.currentTimeMillis() - thirtyDaysInMillis - notificationDao.deleteOldNotifications(cutoffTime) - } +// return withContext(ioDispatcher) { +// val thirtyDaysInMillis = 2592000000L +// val cutoffTime = System.currentTimeMillis() - thirtyDaysInMillis +// notificationDao.deleteOldNotifications(cutoffTime) +// } } override suspend fun updateReadStatus(notification: MifosNotification, isRead: Boolean) { - withContext(ioDispatcher) { - notificationDao.updateReadStatus(notification.timeStamp, isRead) - } +// withContext(ioDispatcher) { +// notificationDao.updateReadStatus(notification.timeStamp, isRead) +// } } } diff --git a/core/datastore/src/commonMain/kotlin/org/mifos/mobile/core/datastore/UserPreferencesDataSource.kt b/core/datastore/src/commonMain/kotlin/org/mifos/mobile/core/datastore/UserPreferencesDataSource.kt index 435afcb4f..5d211c34b 100644 --- a/core/datastore/src/commonMain/kotlin/org/mifos/mobile/core/datastore/UserPreferencesDataSource.kt +++ b/core/datastore/src/commonMain/kotlin/org/mifos/mobile/core/datastore/UserPreferencesDataSource.kt @@ -21,6 +21,7 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.map import kotlinx.coroutines.withContext import kotlinx.serialization.ExperimentalSerializationApi +import okio.ByteString.Companion.encodeUtf8 import org.mifos.mobile.core.datastore.model.AppSettings import org.mifos.mobile.core.datastore.model.AppTheme import org.mifos.mobile.core.datastore.model.UserData @@ -81,28 +82,33 @@ class UserPreferencesDataSource( } } - suspend fun updateToken(token: String) { + suspend fun updateToken(password: String) { + val username = _userInfo.value.userName + val authenticationToken = "Basic " + "$username:$password".encodeToBase64() withContext(dispatcher) { - settings.putUserPreference( - UserData.DEFAULT.copy( - base64EncodedAuthenticationKey = token, - ), - ) - _userInfo.value = UserData.DEFAULT.copy( - base64EncodedAuthenticationKey = token, + val updatedClient = userInfo.value.copy( + userId = _userInfo.value.userId, + userName = _userInfo.value.userName, + clientId = userInfo.value.clientId, + isAuthenticated = _userInfo.value.isAuthenticated, + base64EncodedAuthenticationKey = authenticationToken, ) + settings.putUserPreference(updatedClient) + _userInfo.value = updatedClient } } + suspend fun updateClientId(clientId: Long) { withContext(dispatcher) { - settings.putUserPreference( - UserData.DEFAULT.copy( - clientId = clientId, - ), - ) - _userInfo.value = UserData.DEFAULT.copy( + val updatedClient = userInfo.value.copy( + userId = _userInfo.value.userId, + userName = _userInfo.value.userName, clientId = clientId, + isAuthenticated = _userInfo.value.isAuthenticated, + base64EncodedAuthenticationKey = _userInfo.value.base64EncodedAuthenticationKey, ) + settings.putUserPreference(updatedClient) + _userInfo.value = updatedClient } } @@ -138,6 +144,10 @@ class UserPreferencesDataSource( } } +private fun String.encodeToBase64(): String { + return this.encodeUtf8().base64() +} + @OptIn(ExperimentalSerializationApi::class) private fun Settings.putUserPreference(user: UserData) { encodeValue( diff --git a/core/datastore/src/commonMain/kotlin/org/mifos/mobile/core/datastore/UserPreferencesRepository.kt b/core/datastore/src/commonMain/kotlin/org/mifos/mobile/core/datastore/UserPreferencesRepository.kt index dcb5819a4..5e1ba564e 100644 --- a/core/datastore/src/commonMain/kotlin/org/mifos/mobile/core/datastore/UserPreferencesRepository.kt +++ b/core/datastore/src/commonMain/kotlin/org/mifos/mobile/core/datastore/UserPreferencesRepository.kt @@ -29,7 +29,7 @@ interface UserPreferencesRepository { val profileImage: String? - suspend fun updateToken(token: String): DataState + suspend fun updateToken(password: String): DataState suspend fun updateTheme(theme: AppTheme): DataState diff --git a/core/datastore/src/commonMain/kotlin/org/mifos/mobile/core/datastore/UserPreferencesRepositoryImpl.kt b/core/datastore/src/commonMain/kotlin/org/mifos/mobile/core/datastore/UserPreferencesRepositoryImpl.kt index 14b931460..42756439b 100644 --- a/core/datastore/src/commonMain/kotlin/org/mifos/mobile/core/datastore/UserPreferencesRepositoryImpl.kt +++ b/core/datastore/src/commonMain/kotlin/org/mifos/mobile/core/datastore/UserPreferencesRepositoryImpl.kt @@ -56,9 +56,9 @@ class UserPreferencesRepositoryImpl( override val profileImage: String? get() = preferenceManager.getProfileImage() - override suspend fun updateToken(token: String): DataState { + override suspend fun updateToken(password: String): DataState { return try { - val result = preferenceManager.updateToken(token) + val result = preferenceManager.updateToken(password) DataState.Success(result) } catch (e: Exception) { DataState.Error(e) From 2b17f80825d01625ac930c9276c214fef8182cda Mon Sep 17 00:00:00 2001 From: Nagarjuna0033 Date: Fri, 17 Jan 2025 21:48:08 +0530 Subject: [PATCH 3/3] resolved merge conflicts --- .../demoDebugRuntimeClasspath.txt | 54 ++++++++++++------- .../demoReleaseRuntimeClasspath.txt | 7 +-- .../prodDebugRuntimeClasspath.txt | 5 -- .../prodReleaseRuntimeClasspath.txt | 7 --- 4 files changed, 36 insertions(+), 37 deletions(-) diff --git a/androidApp/dependencies/demoDebugRuntimeClasspath.txt b/androidApp/dependencies/demoDebugRuntimeClasspath.txt index 48fd55259..41616e6ab 100644 --- a/androidApp/dependencies/demoDebugRuntimeClasspath.txt +++ b/androidApp/dependencies/demoDebugRuntimeClasspath.txt @@ -129,8 +129,6 @@ androidx.versionedparcelable:versionedparcelable:1.1.1 androidx.viewpager:viewpager:1.0.0 androidx.window.extensions.core:core:1.0.0 androidx.window:window:1.2.0 -app.cash.turbine:turbine-jvm:1.1.0 -app.cash.turbine:turbine:1.1.0 co.touchlab:kermit-android-debug:2.0.4 co.touchlab:kermit-core-android-debug:2.0.4 co.touchlab:kermit-core:2.0.4 @@ -236,24 +234,40 @@ io.insert-koin:koin-core-jvm:4.0.1-RC1 io.insert-koin:koin-core-viewmodel-jvm:4.0.1-RC1 io.insert-koin:koin-core-viewmodel:4.0.1-RC1 io.insert-koin:koin-core:4.0.1-RC1 -io.ktor:ktor-client-core-jvm:3.0.1 -io.ktor:ktor-client-core:3.0.1 -io.ktor:ktor-events-jvm:3.0.1 -io.ktor:ktor-events:3.0.1 -io.ktor:ktor-http-jvm:3.0.1 -io.ktor:ktor-http:3.0.1 -io.ktor:ktor-io-jvm:3.0.1 -io.ktor:ktor-io:3.0.1 -io.ktor:ktor-serialization-jvm:3.0.1 -io.ktor:ktor-serialization:3.0.1 -io.ktor:ktor-sse-jvm:3.0.1 -io.ktor:ktor-sse:3.0.1 -io.ktor:ktor-utils-jvm:3.0.1 -io.ktor:ktor-utils:3.0.1 -io.ktor:ktor-websocket-serialization-jvm:3.0.1 -io.ktor:ktor-websocket-serialization:3.0.1 -io.ktor:ktor-websockets-jvm:3.0.1 -io.ktor:ktor-websockets:3.0.1 +io.ktor:ktor-client-auth-jvm:3.0.3 +io.ktor:ktor-client-auth:3.0.3 +io.ktor:ktor-client-content-negotiation-jvm:3.0.3 +io.ktor:ktor-client-content-negotiation:3.0.3 +io.ktor:ktor-client-core-jvm:3.0.3 +io.ktor:ktor-client-core:3.0.3 +io.ktor:ktor-client-json-jvm:3.0.3 +io.ktor:ktor-client-json:3.0.3 +io.ktor:ktor-client-logging-jvm:3.0.3 +io.ktor:ktor-client-logging:3.0.3 +io.ktor:ktor-client-okhttp-jvm:3.0.3 +io.ktor:ktor-client-okhttp:3.0.3 +io.ktor:ktor-client-serialization-jvm:3.0.3 +io.ktor:ktor-client-serialization:3.0.3 +io.ktor:ktor-events-jvm:3.0.3 +io.ktor:ktor-events:3.0.3 +io.ktor:ktor-http-jvm:3.0.3 +io.ktor:ktor-http:3.0.3 +io.ktor:ktor-io-jvm:3.0.3 +io.ktor:ktor-io:3.0.3 +io.ktor:ktor-serialization-jvm:3.0.3 +io.ktor:ktor-serialization-kotlinx-json-jvm:3.0.3 +io.ktor:ktor-serialization-kotlinx-json:3.0.3 +io.ktor:ktor-serialization-kotlinx-jvm:3.0.3 +io.ktor:ktor-serialization-kotlinx:3.0.3 +io.ktor:ktor-serialization:3.0.3 +io.ktor:ktor-sse-jvm:3.0.3 +io.ktor:ktor-sse:3.0.3 +io.ktor:ktor-utils-jvm:3.0.3 +io.ktor:ktor-utils:3.0.3 +io.ktor:ktor-websocket-serialization-jvm:3.0.3 +io.ktor:ktor-websocket-serialization:3.0.3 +io.ktor:ktor-websockets-jvm:3.0.3 +io.ktor:ktor-websockets:3.0.3 io.michaelrocks:libphonenumber-android:8.13.35 jakarta.inject:jakarta.inject-api:2.0.1 javax.inject:javax.inject:1 diff --git a/androidApp/dependencies/demoReleaseRuntimeClasspath.txt b/androidApp/dependencies/demoReleaseRuntimeClasspath.txt index 0e527bafe..57023a754 100644 --- a/androidApp/dependencies/demoReleaseRuntimeClasspath.txt +++ b/androidApp/dependencies/demoReleaseRuntimeClasspath.txt @@ -124,8 +124,6 @@ androidx.versionedparcelable:versionedparcelable:1.1.1 androidx.viewpager:viewpager:1.0.0 androidx.window.extensions.core:core:1.0.0 androidx.window:window:1.2.0 -app.cash.turbine:turbine-jvm:1.1.0 -app.cash.turbine:turbine:1.1.0 co.touchlab:kermit-android:2.0.4 co.touchlab:kermit-core-android:2.0.4 co.touchlab:kermit-core:2.0.4 @@ -196,14 +194,14 @@ com.squareup.okio:okio-jvm:3.9.1 com.squareup.okio:okio:3.9.1 com.squareup.retrofit2:converter-gson:2.11.0 com.squareup.retrofit2:retrofit:2.11.0 -dev.chrisbanes.material3:material3-window-size-class-multiplatform-android:0.5.0 -dev.chrisbanes.material3:material3-window-size-class-multiplatform:0.5.0 de.jensklingenberg.ktorfit:ktorfit-annotations-android:2.2.0 de.jensklingenberg.ktorfit:ktorfit-annotations:2.2.0 de.jensklingenberg.ktorfit:ktorfit-lib-android:2.2.0 de.jensklingenberg.ktorfit:ktorfit-lib-light-android:2.2.0 de.jensklingenberg.ktorfit:ktorfit-lib-light:2.2.0 de.jensklingenberg.ktorfit:ktorfit-lib:2.2.0 +dev.chrisbanes.material3:material3-window-size-class-multiplatform-android:0.5.0 +dev.chrisbanes.material3:material3-window-size-class-multiplatform:0.5.0 dev.chrisbanes.snapper:snapper:0.2.2 io.coil-kt.coil3:coil-android:3.0.4 io.coil-kt.coil3:coil-compose-core-android:3.0.4 @@ -304,7 +302,6 @@ org.jetbrains.compose.ui:ui-util:1.7.0-rc01 org.jetbrains.compose.ui:ui:1.7.0-rc01 org.jetbrains.kotlin:kotlin-android-extensions-runtime:2.1.0 org.jetbrains.kotlin:kotlin-parcelize-runtime:2.1.0 -org.jetbrains.kotlin:kotlin-stdlib-common:2.1.0 org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.23 org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22 org.jetbrains.kotlin:kotlin-stdlib:2.1.0 diff --git a/androidApp/dependencies/prodDebugRuntimeClasspath.txt b/androidApp/dependencies/prodDebugRuntimeClasspath.txt index 3b88adf6b..41616e6ab 100644 --- a/androidApp/dependencies/prodDebugRuntimeClasspath.txt +++ b/androidApp/dependencies/prodDebugRuntimeClasspath.txt @@ -129,8 +129,6 @@ androidx.versionedparcelable:versionedparcelable:1.1.1 androidx.viewpager:viewpager:1.0.0 androidx.window.extensions.core:core:1.0.0 androidx.window:window:1.2.0 -app.cash.turbine:turbine-jvm:1.1.0 -app.cash.turbine:turbine:1.1.0 co.touchlab:kermit-android-debug:2.0.4 co.touchlab:kermit-core-android-debug:2.0.4 co.touchlab:kermit-core:2.0.4 @@ -273,8 +271,6 @@ io.ktor:ktor-websockets:3.0.3 io.michaelrocks:libphonenumber-android:8.13.35 jakarta.inject:jakarta.inject-api:2.0.1 javax.inject:javax.inject:1 -net.bytebuddy:byte-buddy-agent:1.14.8 -net.bytebuddy:byte-buddy:1.14.8 org.checkerframework:checker-qual:3.12.0 org.jetbrains.androidx.core:core-bundle-android-debug:1.0.1 org.jetbrains.androidx.core:core-bundle:1.0.1 @@ -311,7 +307,6 @@ org.jetbrains.compose.ui:ui-util:1.7.0-rc01 org.jetbrains.compose.ui:ui:1.7.0-rc01 org.jetbrains.kotlin:kotlin-android-extensions-runtime:2.1.0 org.jetbrains.kotlin:kotlin-parcelize-runtime:2.1.0 -org.jetbrains.kotlin:kotlin-stdlib-common:2.1.0 org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.23 org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22 org.jetbrains.kotlin:kotlin-stdlib:2.1.0 diff --git a/androidApp/dependencies/prodReleaseRuntimeClasspath.txt b/androidApp/dependencies/prodReleaseRuntimeClasspath.txt index bdd40d9c1..57023a754 100644 --- a/androidApp/dependencies/prodReleaseRuntimeClasspath.txt +++ b/androidApp/dependencies/prodReleaseRuntimeClasspath.txt @@ -124,8 +124,6 @@ androidx.versionedparcelable:versionedparcelable:1.1.1 androidx.viewpager:viewpager:1.0.0 androidx.window.extensions.core:core:1.0.0 androidx.window:window:1.2.0 -app.cash.turbine:turbine-jvm:1.1.0 -app.cash.turbine:turbine:1.1.0 co.touchlab:kermit-android:2.0.4 co.touchlab:kermit-core-android:2.0.4 co.touchlab:kermit-core:2.0.4 @@ -268,8 +266,6 @@ io.ktor:ktor-websockets:3.0.3 io.michaelrocks:libphonenumber-android:8.13.35 jakarta.inject:jakarta.inject-api:2.0.1 javax.inject:javax.inject:1 -net.bytebuddy:byte-buddy-agent:1.14.8 -net.bytebuddy:byte-buddy:1.14.8 org.checkerframework:checker-qual:3.12.0 org.jetbrains.androidx.core:core-bundle-android:1.0.1 org.jetbrains.androidx.core:core-bundle:1.0.1 @@ -306,7 +302,6 @@ org.jetbrains.compose.ui:ui-util:1.7.0-rc01 org.jetbrains.compose.ui:ui:1.7.0-rc01 org.jetbrains.kotlin:kotlin-android-extensions-runtime:2.1.0 org.jetbrains.kotlin:kotlin-parcelize-runtime:2.1.0 -org.jetbrains.kotlin:kotlin-stdlib-common:2.1.0 org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.23 org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22 org.jetbrains.kotlin:kotlin-stdlib:2.1.0 @@ -320,8 +315,6 @@ org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.10.1 org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1 org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.10.1 org.jetbrains.kotlinx:kotlinx-coroutines-slf4j:1.10.1 -org.jetbrains.kotlinx:kotlinx-coroutines-test-jvm:1.10.1 -org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1 org.jetbrains.kotlinx:kotlinx-datetime-jvm:0.6.1 org.jetbrains.kotlinx:kotlinx-datetime:0.6.1 org.jetbrains.kotlinx:kotlinx-io-bytestring-jvm:0.5.4