Skip to content

Commit 069fbc5

Browse files
committed
Feat: [:core:network] - Migrated to KMP
1 parent cb3975c commit 069fbc5

Some content is hidden

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

42 files changed

+799
-698
lines changed

androidApp/dependencies/demoDebugRuntimeClasspath.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,9 @@ com.google.j2objc:j2objc-annotations:1.3
175175
com.google.maps.android:maps-compose:4.4.1
176176
com.google.maps.android:maps-ktx:5.0.0
177177
com.google.zxing:core:3.5.3
178-
com.squareup.okhttp3:logging-interceptor:4.12.0
179178
com.squareup.okhttp3:okhttp:4.12.0
180179
com.squareup.okio:okio-jvm:3.6.0
181180
com.squareup.okio:okio:3.6.0
182-
com.squareup.retrofit2:adapter-rxjava2:2.11.0
183181
com.squareup.retrofit2:converter-gson:2.11.0
184182
com.squareup.retrofit2:retrofit:2.11.0
185183
dev.chrisbanes.snapper:snapper:0.2.2
@@ -198,7 +196,6 @@ io.insert-koin:koin-core-viewmodel-jvm:4.0.1-RC1
198196
io.insert-koin:koin-core-viewmodel:4.0.1-RC1
199197
io.insert-koin:koin-core:4.0.1-RC1
200198
io.michaelrocks:libphonenumber-android:8.13.35
201-
io.reactivex.rxjava2:rxjava:2.2.21
202199
jakarta.inject:jakarta.inject-api:2.0.1
203200
javax.inject:javax.inject:1
204201
net.bytebuddy:byte-buddy-agent:1.14.8
@@ -235,7 +232,7 @@ org.jetbrains.compose.ui:ui:1.7.0-rc01
235232
org.jetbrains.kotlin:kotlin-android-extensions-runtime:2.1.0
236233
org.jetbrains.kotlin:kotlin-parcelize-runtime:2.1.0
237234
org.jetbrains.kotlin:kotlin-stdlib-common:2.1.0
238-
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.1.0
235+
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.23
239236
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.10
240237
org.jetbrains.kotlin:kotlin-stdlib:2.1.0
241238
org.jetbrains.kotlinx:atomicfu-jvm:0.23.2
@@ -258,4 +255,3 @@ org.jetbrains:annotations:23.0.0
258255
org.jspecify:jspecify:1.0.0
259256
org.mockito:mockito-core:5.6.0
260257
org.objenesis:objenesis:3.3
261-
org.reactivestreams:reactive-streams:1.0.4

androidApp/dependencies/demoReleaseRuntimeClasspath.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,9 @@ com.google.j2objc:j2objc-annotations:1.3
170170
com.google.maps.android:maps-compose:4.4.1
171171
com.google.maps.android:maps-ktx:5.0.0
172172
com.google.zxing:core:3.5.3
173-
com.squareup.okhttp3:logging-interceptor:4.12.0
174173
com.squareup.okhttp3:okhttp:4.12.0
175174
com.squareup.okio:okio-jvm:3.6.0
176175
com.squareup.okio:okio:3.6.0
177-
com.squareup.retrofit2:adapter-rxjava2:2.11.0
178176
com.squareup.retrofit2:converter-gson:2.11.0
179177
com.squareup.retrofit2:retrofit:2.11.0
180178
dev.chrisbanes.snapper:snapper:0.2.2
@@ -193,7 +191,6 @@ io.insert-koin:koin-core-viewmodel-jvm:4.0.1-RC1
193191
io.insert-koin:koin-core-viewmodel:4.0.1-RC1
194192
io.insert-koin:koin-core:4.0.1-RC1
195193
io.michaelrocks:libphonenumber-android:8.13.35
196-
io.reactivex.rxjava2:rxjava:2.2.21
197194
jakarta.inject:jakarta.inject-api:2.0.1
198195
javax.inject:javax.inject:1
199196
net.bytebuddy:byte-buddy-agent:1.14.8
@@ -230,7 +227,7 @@ org.jetbrains.compose.ui:ui:1.7.0-rc01
230227
org.jetbrains.kotlin:kotlin-android-extensions-runtime:2.1.0
231228
org.jetbrains.kotlin:kotlin-parcelize-runtime:2.1.0
232229
org.jetbrains.kotlin:kotlin-stdlib-common:2.1.0
233-
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.1.0
230+
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.23
234231
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.10
235232
org.jetbrains.kotlin:kotlin-stdlib:2.1.0
236233
org.jetbrains.kotlinx:atomicfu-jvm:0.23.2
@@ -253,4 +250,3 @@ org.jetbrains:annotations:23.0.0
253250
org.jspecify:jspecify:1.0.0
254251
org.mockito:mockito-core:5.6.0
255252
org.objenesis:objenesis:3.3
256-
org.reactivestreams:reactive-streams:1.0.4

androidApp/dependencies/prodDebugRuntimeClasspath.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,9 @@ com.google.j2objc:j2objc-annotations:1.3
175175
com.google.maps.android:maps-compose:4.4.1
176176
com.google.maps.android:maps-ktx:5.0.0
177177
com.google.zxing:core:3.5.3
178-
com.squareup.okhttp3:logging-interceptor:4.12.0
179178
com.squareup.okhttp3:okhttp:4.12.0
180179
com.squareup.okio:okio-jvm:3.6.0
181180
com.squareup.okio:okio:3.6.0
182-
com.squareup.retrofit2:adapter-rxjava2:2.11.0
183181
com.squareup.retrofit2:converter-gson:2.11.0
184182
com.squareup.retrofit2:retrofit:2.11.0
185183
dev.chrisbanes.snapper:snapper:0.2.2
@@ -198,7 +196,6 @@ io.insert-koin:koin-core-viewmodel-jvm:4.0.1-RC1
198196
io.insert-koin:koin-core-viewmodel:4.0.1-RC1
199197
io.insert-koin:koin-core:4.0.1-RC1
200198
io.michaelrocks:libphonenumber-android:8.13.35
201-
io.reactivex.rxjava2:rxjava:2.2.21
202199
jakarta.inject:jakarta.inject-api:2.0.1
203200
javax.inject:javax.inject:1
204201
net.bytebuddy:byte-buddy-agent:1.14.8
@@ -235,7 +232,7 @@ org.jetbrains.compose.ui:ui:1.7.0-rc01
235232
org.jetbrains.kotlin:kotlin-android-extensions-runtime:2.1.0
236233
org.jetbrains.kotlin:kotlin-parcelize-runtime:2.1.0
237234
org.jetbrains.kotlin:kotlin-stdlib-common:2.1.0
238-
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.1.0
235+
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.23
239236
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.10
240237
org.jetbrains.kotlin:kotlin-stdlib:2.1.0
241238
org.jetbrains.kotlinx:atomicfu-jvm:0.23.2
@@ -258,4 +255,3 @@ org.jetbrains:annotations:23.0.0
258255
org.jspecify:jspecify:1.0.0
259256
org.mockito:mockito-core:5.6.0
260257
org.objenesis:objenesis:3.3
261-
org.reactivestreams:reactive-streams:1.0.4

androidApp/dependencies/prodReleaseRuntimeClasspath.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,9 @@ com.google.j2objc:j2objc-annotations:1.3
170170
com.google.maps.android:maps-compose:4.4.1
171171
com.google.maps.android:maps-ktx:5.0.0
172172
com.google.zxing:core:3.5.3
173-
com.squareup.okhttp3:logging-interceptor:4.12.0
174173
com.squareup.okhttp3:okhttp:4.12.0
175174
com.squareup.okio:okio-jvm:3.6.0
176175
com.squareup.okio:okio:3.6.0
177-
com.squareup.retrofit2:adapter-rxjava2:2.11.0
178176
com.squareup.retrofit2:converter-gson:2.11.0
179177
com.squareup.retrofit2:retrofit:2.11.0
180178
dev.chrisbanes.snapper:snapper:0.2.2
@@ -193,7 +191,6 @@ io.insert-koin:koin-core-viewmodel-jvm:4.0.1-RC1
193191
io.insert-koin:koin-core-viewmodel:4.0.1-RC1
194192
io.insert-koin:koin-core:4.0.1-RC1
195193
io.michaelrocks:libphonenumber-android:8.13.35
196-
io.reactivex.rxjava2:rxjava:2.2.21
197194
jakarta.inject:jakarta.inject-api:2.0.1
198195
javax.inject:javax.inject:1
199196
net.bytebuddy:byte-buddy-agent:1.14.8
@@ -230,7 +227,7 @@ org.jetbrains.compose.ui:ui:1.7.0-rc01
230227
org.jetbrains.kotlin:kotlin-android-extensions-runtime:2.1.0
231228
org.jetbrains.kotlin:kotlin-parcelize-runtime:2.1.0
232229
org.jetbrains.kotlin:kotlin-stdlib-common:2.1.0
233-
org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.1.0
230+
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.9.23
234231
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.10
235232
org.jetbrains.kotlin:kotlin-stdlib:2.1.0
236233
org.jetbrains.kotlinx:atomicfu-jvm:0.23.2
@@ -253,4 +250,3 @@ org.jetbrains:annotations:23.0.0
253250
org.jspecify:jspecify:1.0.0
254251
org.mockito:mockito-core:5.6.0
255252
org.objenesis:objenesis:3.3
256-
org.reactivestreams:reactive-streams:1.0.4

core/data/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ android {
3131

3232
dependencies {
3333
api(projects.core.common)
34-
api(projects.core.model)
35-
api(projects.core.network)
34+
// api(projects.core.model)
35+
// api(projects.core.network)
3636
api(projects.core.database)
3737
api(projects.core.datastore)
3838

core/datastore/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ android {
2424

2525
dependencies {
2626
implementation(projects.core.common)
27-
implementation(projects.core.model)
27+
// implementation(projects.core.model)
2828

2929

3030
}

core/network/build.gradle.kts

Lines changed: 60 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,77 @@
77
*
88
* See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md
99
*/
10+
1011
plugins {
11-
alias(libs.plugins.mifos.android.library)
12-
alias(libs.plugins.mifos.android.hilt)
12+
alias(libs.plugins.mifos.kmp.library)
13+
alias(libs.plugins.ktorfit)
1314
id("kotlinx-serialization")
15+
id("com.google.devtools.ksp")
1416
}
1517

1618
android {
1719
namespace = "org.mifos.mobile.core.network"
1820
defaultConfig {
1921
consumerProguardFiles("consumer-rules.pro")
2022
}
23+
testOptions {
24+
unitTests {
25+
isReturnDefaultValues = true
26+
isIncludeAndroidResources = true
27+
}
28+
}
2129
}
2230

23-
dependencies {
24-
api(projects.core.common)
25-
api(projects.core.model)
26-
api(projects.core.datastore)
31+
kotlin {
32+
sourceSets {
33+
commonMain.dependencies {
34+
// api(projects.core.common)
35+
implementation(projects.core.model)
36+
// implementation(projects.core.datastore)
37+
implementation(libs.kotlinx.serialization.json)
38+
implementation(libs.ktor.client.core)
39+
implementation(libs.ktor.client.json)
40+
implementation(libs.ktor.client.logging)
41+
implementation(libs.ktor.client.serialization)
42+
implementation(libs.ktor.client.content.negotiation)
43+
implementation(libs.ktor.client.auth)
44+
implementation(libs.ktor.serialization.kotlinx.json)
45+
implementation(libs.ktorfit.lib)
46+
implementation(libs.squareup.okio)
47+
// TODO remove this dependency from here after common module successfully migrated to
48+
// KMP
49+
api(libs.kermit.logging)
50+
}
51+
androidMain.dependencies {
52+
implementation(libs.ktor.client.okhttp)
53+
implementation(libs.koin.android)
54+
}
2755

28-
//Square dependencies
29-
implementation(libs.squareup.retrofit2) {
30-
// exclude Retrofit’s OkHttp peer-dependency module and define your own module import
31-
exclude(module = "okhttp")
32-
}
33-
implementation(libs.squareup.retrofit.adapter.rxjava)
34-
implementation(libs.squareup.retrofit.converter.gson)
35-
implementation(libs.squareup.logging.interceptor)
36-
implementation(libs.squareup.okhttp)
56+
nativeMain.dependencies {
57+
implementation(libs.ktor.client.darwin)
58+
}
3759

38-
implementation(libs.jetbrains.kotlin.jdk7)
60+
val desktopMain by getting {
61+
dependencies {
62+
implementation(libs.ktor.client.okhttp)
63+
}
64+
}
65+
jsMain.dependencies {
66+
implementation(libs.ktor.client.js)
67+
}
68+
wasmJsMain.dependencies {
69+
implementation(libs.ktor.client.js)
70+
}
71+
}
72+
}
3973

40-
testImplementation(libs.junit)
41-
testImplementation(libs.mockito.core)
42-
implementation(libs.mockito.core)
43-
}
74+
dependencies {
75+
add("kspCommonMainMetadata", libs.ktorfit.ksp)
76+
add("kspAndroid", libs.ktorfit.ksp)
77+
add("kspJs", libs.ktorfit.ksp)
78+
add("kspWasmJs", libs.ktorfit.ksp)
79+
add("kspDesktop", libs.ktorfit.ksp)
80+
add("kspIosX64", libs.ktorfit.ksp)
81+
add("kspIosArm64", libs.ktorfit.ksp)
82+
add("kspIosSimulatorArm64", libs.ktorfit.ksp)
83+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright 2025 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md
9+
*/
10+
package org.mifos.mobile.core.network
11+
12+
import io.ktor.client.HttpClient
13+
import io.ktor.client.engine.okhttp.OkHttp
14+
import io.ktor.client.plugins.HttpTimeout
15+
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
16+
import io.ktor.client.plugins.logging.DEFAULT
17+
import io.ktor.client.plugins.logging.LogLevel
18+
import io.ktor.client.plugins.logging.Logger
19+
import io.ktor.client.plugins.logging.Logging
20+
import io.ktor.serialization.kotlinx.json.json
21+
import kotlinx.serialization.json.Json
22+
import co.touchlab.kermit.Logger.Companion as KermitLogger
23+
24+
actual val ktorHttpClient: HttpClient
25+
get() = HttpClient(OkHttp) {
26+
install(HttpTimeout) {
27+
socketTimeoutMillis = 60_000
28+
requestTimeoutMillis = 60_000
29+
}
30+
31+
install(Logging) {
32+
logger = Logger.DEFAULT
33+
level = LogLevel.ALL
34+
logger = object : Logger {
35+
override fun log(message: String) {
36+
KermitLogger.d(tag = "KtorClient", messageString = message)
37+
}
38+
}
39+
}
40+
41+
install(ContentNegotiation) {
42+
json(
43+
Json {
44+
prettyPrint = true
45+
isLenient = true
46+
ignoreUnknownKeys = true
47+
explicitNulls = false
48+
},
49+
)
50+
}
51+
}

core/network/src/main/java/org/mifos/mobile/core/network/BaseApiManager.kt renamed to core/network/src/commonMain/kotlin/org/mifos/mobile/core/network/BaseApiManager.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ import org.mifos.mobile.core.network.services.RegistrationService
2121
import org.mifos.mobile.core.network.services.SavingAccountsListService
2222
import org.mifos.mobile.core.network.services.ThirdPartyTransferService
2323
import org.mifos.mobile.core.network.services.UserDetailsService
24-
import javax.inject.Inject
2524

26-
class BaseApiManager @Inject constructor(
25+
class BaseApiManager(
2726
private val authenticationService: AuthenticationService,
2827
private val clientsService: ClientService,
2928
private val savingAccountsListService: SavingAccountsListService,
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2024 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/mobile-mobile/blob/master/LICENSE.md
9+
*/
10+
package org.mifos.mobile.core.network
11+
12+
class DataManager(
13+
private val ktorfitClient: KtorfitClient,
14+
) {
15+
16+
internal val authenticationApi by lazy { ktorfitClient.authenticationApi }
17+
18+
internal val beneficiaryApi by lazy { ktorfitClient.beneficiaryApi }
19+
20+
internal val clientsApi by lazy { ktorfitClient.clientsApi }
21+
22+
internal val loanAccountsListApi by lazy { ktorfitClient.loanAccountsListApi }
23+
24+
internal val savingAccountsListApi by lazy { ktorfitClient.savingAccountsListApi }
25+
26+
internal val recentTransactionsApi by lazy { ktorfitClient.recentTransactionsApi }
27+
28+
internal val clientChargeApi by lazy { ktorfitClient.clientChargeApi }
29+
30+
internal val thirdPartyTransferApi by lazy { ktorfitClient.thirdPartyTransferApi }
31+
32+
internal val registrationApi by lazy { ktorfitClient.registrationApi }
33+
34+
internal val notificationApi by lazy { ktorfitClient.notificationApi }
35+
36+
internal val userDetailsApi by lazy { ktorfitClient.userDetailsApi }
37+
38+
internal val guarantorApi by lazy { ktorfitClient.guarantorApi }
39+
}

0 commit comments

Comments
 (0)