Skip to content

Commit

Permalink
Feat: Migrated Send Money Module to KMP (#1808)
Browse files Browse the repository at this point in the history
  • Loading branch information
niyajali authored Nov 1, 2024
1 parent 2a5f1bf commit 8a27c14
Show file tree
Hide file tree
Showing 20 changed files with 749 additions and 530 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,15 @@ package org.mifospay.core.common.utils
* This just checks if the string contains the "@" symbol.
*/
fun String.isValidEmail(): Boolean = contains("@")

fun maskString(input: String, maskChar: Char = '*'): String {
if (input.length <= 3) return input

val visibleCount = 3
val maskLength = input.length - visibleCount

return buildString {
append(maskChar.toString().repeat(maskLength))
append(input.takeLast(visibleCount))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ import kotlinx.coroutines.flow.Flow
import org.mifospay.core.common.DataState
import org.mifospay.core.model.savingsaccount.Transaction
import org.mifospay.core.model.savingsaccount.TransferDetail
import org.mifospay.core.model.search.AccountResult

interface AccountRepository {
fun getTransaction(accountId: Long, transactionId: Long): Flow<DataState<Transaction>>

fun getAccountTransfer(transferId: Long): Flow<DataState<TransferDetail>>

fun searchAccounts(query: String): Flow<DataState<List<AccountResult>>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package org.mifospay.core.data.repositoryImp

import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
import org.mifospay.core.common.DataState
Expand All @@ -19,6 +20,7 @@ import org.mifospay.core.data.mapper.toModel
import org.mifospay.core.data.repository.AccountRepository
import org.mifospay.core.model.savingsaccount.Transaction
import org.mifospay.core.model.savingsaccount.TransferDetail
import org.mifospay.core.model.search.AccountResult
import org.mifospay.core.network.FineractApiManager

class AccountRepositoryImpl(
Expand All @@ -41,4 +43,11 @@ class AccountRepositoryImpl(
.getAccountTransfer(transferId.toInt())
.asDataStateFlow().flowOn(ioDispatcher)
}

override fun searchAccounts(query: String): Flow<DataState<List<AccountResult>>> {
return apiManager.accountTransfersApi
.searchAccounts(query, "savings")
.catch { DataState.Error(it, null) }
.asDataStateFlow().flowOn(ioDispatcher)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import androidx.compose.material.icons.outlined.Home
import androidx.compose.material.icons.outlined.Info
import androidx.compose.material.icons.outlined.Lock
import androidx.compose.material.icons.outlined.Notifications
import androidx.compose.material.icons.outlined.QrCodeScanner
import androidx.compose.material.icons.outlined.Settings
import androidx.compose.material.icons.outlined.Share
import androidx.compose.material.icons.outlined.Visibility
Expand Down Expand Up @@ -123,4 +124,5 @@ object MifosIcons {
val Person = Icons.Filled.Person
val Badge = Icons.Filled.Badge
val DataInfo = Icons.Filled.Description
val Scan = Icons.Outlined.QrCodeScanner
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* 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-wallet/blob/master/LICENSE.md
*/
package org.mifospay.core.model.search

import kotlinx.serialization.Serializable
import org.mifospay.core.common.Parcelable
import org.mifospay.core.common.Parcelize

@Serializable
@Parcelize
data class AccountResult(
val entityId: Long,
val entityAccountNo: String,
val entityExternalId: String?,
val entityName: String,
val entityType: String,
val parentId: Long,
val parentName: String,
val parentType: String,
val subEntityType: String,
) : Parcelable
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ package org.mifospay.core.network.services

import de.jensklingenberg.ktorfit.http.GET
import de.jensklingenberg.ktorfit.http.Path
import de.jensklingenberg.ktorfit.http.Query
import kotlinx.coroutines.flow.Flow
import org.mifospay.core.model.savingsaccount.TransactionsEntity
import org.mifospay.core.model.savingsaccount.TransferDetail
import org.mifospay.core.model.search.AccountResult
import org.mifospay.core.network.utils.ApiEndPoints

interface AccountTransfersService {
Expand All @@ -26,4 +28,10 @@ interface AccountTransfersService {

@GET(ApiEndPoints.ACCOUNT_TRANSFER + "/{transferId}")
fun getAccountTransfer(@Path("transferId") transferId: Int): Flow<TransferDetail>

@GET(ApiEndPoints.SEARCH)
fun searchAccounts(
@Query("query") query: String,
@Query("resource") resource: String,
): Flow<List<AccountResult>>
}
22 changes: 13 additions & 9 deletions feature/send-money/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,22 @@
* See https://github.com/openMF/mobile-wallet/blob/master/LICENSE.md
*/
plugins {
alias(libs.plugins.mifospay.android.feature)
alias(libs.plugins.mifospay.android.library.compose)
alias(libs.plugins.mifospay.cmp.feature)
alias(libs.plugins.kotlin.parcelize)
}

android {
namespace = "org.mifospay.feature.send.money"
}

dependencies {
// we need it for country picker library
implementation(projects.libs.countryCodePicker)

// Google Bar code scanner
implementation(libs.google.play.services.code.scanner)
}
kotlin {
sourceSets {
commonMain.dependencies {
implementation(compose.ui)
implementation(compose.foundation)
implementation(compose.material3)
implementation(compose.components.resources)
implementation(compose.components.uiToolingPreview)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<string name="feature_send_money_insufficient_balance">Insufficient balance</string>
<string name="feature_send_money_error_fetching_balance">Error fetching balance</string>
<string name="feature_send_money_not_allowed">Self Account transfer is not allowed</string>
<string name="feature_send_money_send">Send</string>
<string name="feature_send_money_send">Send Money</string>
<string name="feature_send_money_select_transfer_method">Select transfer method</string>
<string name="feature_send_money_vpa">VPA</string>
<string name="feature_send_money_mobile">Mobile number</string>
Expand Down
Loading

0 comments on commit 8a27c14

Please sign in to comment.