Skip to content

Commit

Permalink
migrate [core.model] to KMP
Browse files Browse the repository at this point in the history
applied spotless and detekt

rename
  • Loading branch information
itsPronay committed Jan 14, 2025
1 parent 18ad115 commit a31fe52
Show file tree
Hide file tree
Showing 268 changed files with 1,141 additions and 916 deletions.
7 changes: 5 additions & 2 deletions core/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
plugins {
alias(libs.plugins.mifos.android.library)
alias(libs.plugins.mifos.kmp.library)
id(libs.plugins.kotlin.parcelize.get().pluginId)
id("kotlinx-serialization")

alias(libs.plugins.mifos.android.hilt)
alias(libs.plugins.mifos.android.library.jacoco)
alias(libs.plugins.secrets)
Expand All @@ -27,7 +30,7 @@ secrets {
}

dependencies {
implementation(projects.core.model)
// implementation(projects.core.model)
testImplementation(libs.kotlinx.coroutines.test)
testImplementation(libs.turbine)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.common.utils

expect annotation class Parcelize()

expect interface Parcelable

expect annotation class IgnoredOnParcel()

expect interface Parceler<P> {
fun create(parcel: Parcel): P

fun P.write(parcel: Parcel, flags: Int)
}

expect annotation class TypeParceler<T, P : Parceler<in T>>()

expect class Parcel {
fun readByte(): Byte
fun readInt(): Int

fun readFloat(): Float
fun readDouble(): Double
fun readString(): String?

fun writeByte(value: Byte)
fun writeInt(value: Int)

fun writeFloat(value: Float)

fun writeDouble(value: Double)
fun writeString(value: String?)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.model

import com.google.gson.annotations.SerializedName
package com.mifos.core.common.utils

@Serializable
data class ServerConfig(
val protocol: String,
@SerializedName("end_point")
@SerialName("end_point")
val endPoint: String,
@SerializedName("api_path")
@SerialName("api_path")
val apiPath: String,
val port: String,
val tenant: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2025 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.common.utils

actual interface Parcelable
actual annotation class IgnoredOnParcel
actual annotation class Parcelize
actual interface Parceler<P> {
actual fun create(parcel: Parcel): P
actual fun P.write(parcel: Parcel, flags: Int)
}

actual annotation class TypeParceler<T, P : Parceler<in T>>

actual class Parcel {
actual fun readString(): String? = null
actual fun readByte(): Byte = 1

actual fun readInt(): Int = 1

actual fun readFloat(): Float = 1f

actual fun readDouble(): Double = 1.0

actual fun writeByte(value: Byte) {
}

actual fun writeInt(value: Int) {
}

actual fun writeFloat(value: Float) {
}

actual fun writeDouble(value: Double) {
}

actual fun writeString(value: String?) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2025 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.common.utils

actual interface Parcelable
actual annotation class IgnoredOnParcel
actual annotation class Parcelize
actual interface Parceler<P> {
actual fun create(parcel: Parcel): P
actual fun P.write(parcel: Parcel, flags: Int)
}

actual annotation class TypeParceler<T, P : Parceler<in T>>

actual class Parcel {
actual fun readString(): String? = null
actual fun readByte(): Byte = 1

actual fun readInt(): Int = 1

actual fun readFloat(): Float = 1f

actual fun readDouble(): Double = 1.0

actual fun writeByte(value: Byte) {
}

actual fun writeInt(value: Int) {
}

actual fun writeFloat(value: Float) {
}

actual fun writeDouble(value: Double) {
}

actual fun writeString(value: String?) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
package com.mifos.core.common.utils

import com.google.gson.Gson
import com.mifos.core.model.ServerConfig
import core.mifos.core.model.ServerConfig

fun String.asServerConfig(): ServerConfig {
fun String.asServerConfig(): core.mifos.core.model.ServerConfig {
val jsonString = this.replace("'", "\"")
return Gson().fromJson(jsonString, ServerConfig::class.java)
return Gson().fromJson(jsonString, core.mifos.core.model.ServerConfig::class.java)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2025 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.common.utils

import android.os.Parcel
import android.os.Parcelable
import kotlinx.parcelize.IgnoredOnParcel
import kotlinx.parcelize.Parceler
import kotlinx.parcelize.Parcelize
import kotlinx.parcelize.TypeParceler

actual typealias Parcelize = Parcelize

actual typealias Parcelable = Parcelable

actual typealias IgnoredOnParcel = IgnoredOnParcel

actual typealias Parceler<P> = Parceler<P>

actual typealias TypeParceler<T, P> = TypeParceler<T, P>

actual typealias Parcel = Parcel
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2025 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.common.utils

actual interface Parcelable
actual annotation class IgnoredOnParcel
actual annotation class Parcelize
actual interface Parceler<P> {
actual fun create(parcel: Parcel): P
actual fun P.write(parcel: Parcel, flags: Int)
}

actual annotation class TypeParceler<T, P : Parceler<in T>>

actual class Parcel {
actual fun readString(): String? = null
actual fun readByte(): Byte = 1

actual fun readInt(): Int = 1

actual fun readFloat(): Float = 1f

actual fun readDouble(): Double = 1.0

actual fun writeByte(value: Byte) {
}

actual fun writeInt(value: Int) {
}

actual fun writeFloat(value: Float) {
}

actual fun writeDouble(value: Double) {
}

actual fun writeString(value: String?) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2025 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.common.utils

actual interface Parcelable
actual annotation class IgnoredOnParcel
actual annotation class Parcelize
actual interface Parceler<P> {
actual fun create(parcel: Parcel): P
actual fun P.write(parcel: Parcel, flags: Int)
}

actual annotation class TypeParceler<T, P : Parceler<in T>>

actual class Parcel {
actual fun readString(): String? = null
actual fun readByte(): Byte = 1

actual fun readInt(): Int = 1

actual fun readFloat(): Float = 1f

actual fun readDouble(): Double = 1.0

actual fun writeByte(value: Byte) {
}

actual fun writeInt(value: Int) {
}

actual fun writeFloat(value: Float) {
}

actual fun writeDouble(value: Double) {
}

actual fun writeString(value: String?) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
package com.mifos.core.data.repository

import com.mifos.core.objects.checkerinboxtask.CheckerTask
import com.mifos.core.objects.checkerinboxtask.RescheduleLoansTask
import kotlinx.coroutines.flow.Flow

/**
Expand All @@ -19,7 +18,7 @@ import kotlinx.coroutines.flow.Flow

interface CheckerInboxTasksRepository {

suspend fun getRescheduleLoansTaskList(): Flow<List<RescheduleLoansTask>>
suspend fun getRescheduleLoansTaskList(): Flow<List<com.mifos.core.model.objects.checkerinboxtask.RescheduleLoansTask>>

suspend fun getCheckerTaskList(
actionName: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import com.mifos.core.entity.accounts.loan.Loans
import com.mifos.core.entity.client.Client
import com.mifos.core.entity.client.ClientPayload
import com.mifos.core.network.model.LoansPayload
import com.mifos.core.payloads.GroupLoanPayload
import com.mifos.core.model.objects.payloads.GroupLoanPayload
import rx.Observable

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ package com.mifos.core.data.repository

import com.mifos.core.entity.accounts.loan.Loans
import com.mifos.core.objects.template.loan.GroupLoanTemplate
import com.mifos.core.payloads.GroupLoanPayload
import com.mifos.core.model.objects.payloads.GroupLoanPayload
import rx.Observable

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
package com.mifos.core.data.repository

import com.mifos.core.network.GenericResponse
import com.mifos.core.objects.account.loan.LoanApproval
import rx.Observable

/**
* Created by Aditya Gupta on 10/08/23.
*/
interface LoanAccountApprovalRepository {

fun approveLoan(loanId: Int, loanApproval: LoanApproval?): Observable<GenericResponse>
fun approveLoan(loanId: Int, loanApproval: com.mifos.core.model.objects.account.loan.LoanApproval?): Observable<GenericResponse>
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ package com.mifos.core.data.repository
import com.mifos.core.entity.accounts.loan.Loans
import com.mifos.core.entity.templates.loans.LoanTemplate
import com.mifos.core.network.model.LoansPayload
import com.mifos.core.objects.organisations.LoanProducts
import rx.Observable

/**
* Created by Aditya Gupta on 08/08/23.
*/
interface LoanAccountRepository {

suspend fun allLoans(): Observable<List<LoanProducts>>
suspend fun allLoans(): Observable<List<com.mifos.core.model.objects.organisations.LoanProducts>>

suspend fun getLoansAccountTemplate(clientId: Int, productId: Int): Observable<LoanTemplate>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ package com.mifos.core.data.repository

import com.mifos.core.entity.accounts.loan.LoanRepaymentRequest
import com.mifos.core.entity.templates.loans.LoanRepaymentTemplate
import com.mifos.core.objects.account.loan.LoanRepaymentResponse
import rx.Observable

/**
Expand All @@ -24,7 +23,7 @@ interface LoanRepaymentRepository {
fun submitPayment(
loanId: Int,
request: LoanRepaymentRequest,
): Observable<LoanRepaymentResponse>
): Observable<com.mifos.core.model.objects.account.loan.LoanRepaymentResponse>

fun getDatabaseLoanRepaymentByLoanId(loanId: Int): Observable<LoanRepaymentRequest>
}
Loading

0 comments on commit a31fe52

Please sign in to comment.