NTP-7179 | Narayan | Integrated check balance use case in different VMs (#14061)
This commit is contained in:
committed by
GitHub
parent
91321a53e8
commit
90ec8fa8a6
@@ -25,17 +25,12 @@ import com.navi.pay.common.model.view.NaviPayScreenType
|
||||
import com.navi.pay.common.setup.NaviPayRouter.getDirectionFromCtaUrl
|
||||
import com.navi.pay.common.usecase.CheckAccountBalanceUseCase
|
||||
import com.navi.pay.common.usecase.NaviPayConfigUseCase
|
||||
import com.navi.pay.common.usecase.UpiRequestIdUseCase
|
||||
import com.navi.pay.common.utils.NaviPayCommonUtils.getHelpCtaData
|
||||
import com.navi.pay.common.utils.getMetricInfo
|
||||
import com.navi.pay.common.viewmodel.NaviPayBaseVM
|
||||
import com.navi.pay.destinations.LinkedAccountDetailScreenDestination
|
||||
import com.navi.pay.destinations.LinkedAccountsScreenDestination
|
||||
import com.navi.pay.destinations.TransactionHistoryDetailScreenV2Destination
|
||||
import com.navi.pay.management.common.model.view.LinkedAccountBalanceScreenSource
|
||||
import com.navi.pay.npcicl.CredDataProvider
|
||||
import com.navi.pay.npcicl.NpciRepository
|
||||
import com.navi.pay.npcicl.NpciResult
|
||||
import com.navi.pay.onboarding.account.common.model.view.LinkedAccountBalanceBottomSheetStateHolder
|
||||
import com.navi.pay.onboarding.account.detail.model.view.LinkedAccountEntity
|
||||
import com.navi.pay.onboarding.account.linked.model.network.CheckBalanceResponse
|
||||
@@ -62,11 +57,8 @@ import kotlinx.coroutines.launch
|
||||
class LinkedAccountBalanceViewModel
|
||||
@Inject
|
||||
constructor(
|
||||
private val npciRepository: NpciRepository,
|
||||
private val credDataProvider: CredDataProvider,
|
||||
private val resourceProvider: ResourceProvider,
|
||||
private val naviCacheRepository: NaviCacheRepository,
|
||||
private val upiRequestIdUseCase: UpiRequestIdUseCase,
|
||||
private val naviPayConfigUseCase: NaviPayConfigUseCase,
|
||||
savedStateHandle: SavedStateHandle,
|
||||
private val coroutineDispatcherProvider: CoroutineDispatcherProvider,
|
||||
@@ -233,37 +225,26 @@ constructor(
|
||||
updateRetryButtonLoaderState(showRetryButtonLoader = true)
|
||||
}
|
||||
|
||||
val upiRequestId = upiRequestIdUseCase.execute()
|
||||
|
||||
val npciCredData =
|
||||
credDataProvider.balanceCheckCred(
|
||||
accountEntity = linkedAccountEntity,
|
||||
upiRequestId = upiRequestId
|
||||
)
|
||||
naviPayAnalytics.onNpciScreenOpen(source = source)
|
||||
val npciResult =
|
||||
npciRepository.fetchCredentials(
|
||||
npciCredData = npciCredData,
|
||||
metricInfo = getMetricInfo(screenName = screenName, isNae = { false })
|
||||
)
|
||||
|
||||
when (npciResult) {
|
||||
is NpciResult.Error -> {
|
||||
checkAccountBalanceUseCase.generateCheckAccountBalanceCred(
|
||||
linkedAccountEntity = linkedAccountEntity,
|
||||
screenName = screenName,
|
||||
onNpciResultError = { isUserAborted ->
|
||||
updateRetryButtonLoaderState(showRetryButtonLoader = false)
|
||||
updateRefreshLoaderState(showRefreshLoader = false)
|
||||
if (!npciResult.isUserAborted) {
|
||||
if (isUserAborted) {
|
||||
notifyError()
|
||||
}
|
||||
}
|
||||
is NpciResult.Success -> {
|
||||
},
|
||||
onNpciResultSuccess = { credBlock, upiRequestId ->
|
||||
onCheckBalanceCLCallback(
|
||||
credBlock = npciResult.data,
|
||||
credBlock = credBlock,
|
||||
upiRequestId = upiRequestId,
|
||||
linkedAccountEntity = linkedAccountEntity
|
||||
)
|
||||
}
|
||||
else -> Unit
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.navi.pay.common.repository.SharedPreferenceRepository
|
||||
import com.navi.pay.common.settingscreen.model.QrDetails
|
||||
import com.navi.pay.common.setup.NaviPayCustomerStatusHandler
|
||||
import com.navi.pay.common.setup.model.NaviPayCustomerStatus
|
||||
import com.navi.pay.common.usecase.CheckAccountBalanceUseCase
|
||||
import com.navi.pay.common.usecase.CheckUpiNumberAvailabilityUseCase
|
||||
import com.navi.pay.common.usecase.DisableUpiLiteUseCase
|
||||
import com.navi.pay.common.usecase.LinkedAccountsUseCase
|
||||
@@ -155,6 +156,7 @@ constructor(
|
||||
private val checkUpiNumberAvailabilityUseCase: CheckUpiNumberAvailabilityUseCase,
|
||||
private val refreshUpiNumbersUseCase: RefreshUpiNumbersUseCase,
|
||||
private val upiLiteExperimentationUseCase: UpiLiteExperimentationUseCase,
|
||||
private val checkAccountBalanceUseCase: CheckAccountBalanceUseCase,
|
||||
naviPayActivityDataProvider: NaviPayActivityDataProvider,
|
||||
savedStateHandle: SavedStateHandle,
|
||||
upiNumbersHelper: UpiNumbersHelper,
|
||||
@@ -1003,40 +1005,27 @@ constructor(
|
||||
return@launch
|
||||
}
|
||||
|
||||
val upiRequestId = upiRequestIdUseCase.execute()
|
||||
|
||||
if (upiRequestId.isEmpty()) {
|
||||
updateShowLoaderState(showLoader = false)
|
||||
notifyError(getGenericErrorConfig())
|
||||
return@launch
|
||||
}
|
||||
|
||||
val npciCredData =
|
||||
credDataProvider.balanceCheckCred(
|
||||
accountEntity = linkedAccountEntity!!,
|
||||
upiRequestId = upiRequestId
|
||||
)
|
||||
val npciResult =
|
||||
npciRepository.fetchCredentials(
|
||||
npciCredData = npciCredData,
|
||||
metricInfo = getMetricInfo(screenName = screenName, isNae = { false })
|
||||
)
|
||||
when (npciResult) {
|
||||
is NpciResult.Error -> {
|
||||
checkAccountBalanceUseCase.generateCheckAccountBalanceCred(
|
||||
linkedAccountEntity = linkedAccountEntity!!,
|
||||
screenName = screenName,
|
||||
onNpciResultError = { isUserAborted ->
|
||||
updateShowLoaderState(showLoader = false)
|
||||
if (!npciResult.isUserAborted) {
|
||||
if (!isUserAborted) {
|
||||
notifyError()
|
||||
}
|
||||
}
|
||||
is NpciResult.Success -> {
|
||||
},
|
||||
onNpciResultSuccess = { credBlock, upiRequestId ->
|
||||
navigateToNextScreen(
|
||||
credBlock = npciResult.data,
|
||||
credBlock = credBlock,
|
||||
upiRequestId = upiRequestId,
|
||||
selectedBankAccount = linkedAccountEntity!!
|
||||
)
|
||||
},
|
||||
onUpiRequestIdFailure = {
|
||||
updateShowLoaderState(showLoader = false)
|
||||
notifyError(getGenericErrorConfig())
|
||||
}
|
||||
else -> Unit
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,9 @@ import com.navi.pay.common.model.view.NaviPaySessionHelper
|
||||
import com.navi.pay.common.setup.NaviPayCustomerStatusHandler
|
||||
import com.navi.pay.common.setup.model.NaviPayCustomerStatus
|
||||
import com.navi.pay.common.usecase.AccountListCheckBalanceUseCase
|
||||
import com.navi.pay.common.usecase.CheckAccountBalanceUseCase
|
||||
import com.navi.pay.common.usecase.LinkedAccountsUseCase
|
||||
import com.navi.pay.common.usecase.RefreshUpiNumbersUseCase
|
||||
import com.navi.pay.common.usecase.UpiRequestIdUseCase
|
||||
import com.navi.pay.common.utils.DeviceInfoProvider
|
||||
import com.navi.pay.common.utils.NaviPayCommonUtils
|
||||
import com.navi.pay.common.utils.getLinkedAccountScreenSourceFromBundleConverter
|
||||
@@ -45,9 +45,6 @@ import com.navi.pay.management.common.sendmoney.model.view.UpiTransactionType
|
||||
import com.navi.pay.management.upinumber.list.model.network.CheckUpiNumberAvailabilityRequest
|
||||
import com.navi.pay.management.upinumber.list.model.network.CreateNewUpiNumberRequest
|
||||
import com.navi.pay.management.upinumber.list.repository.UpiNumberRepository
|
||||
import com.navi.pay.npcicl.CredDataProvider
|
||||
import com.navi.pay.npcicl.NpciRepository
|
||||
import com.navi.pay.npcicl.NpciResult
|
||||
import com.navi.pay.onboarding.account.add.model.view.AccountType
|
||||
import com.navi.pay.onboarding.account.detail.model.view.LinkedAccountEntity
|
||||
import com.navi.pay.onboarding.account.linked.model.view.LinkedAccountClickedAction
|
||||
@@ -100,19 +97,17 @@ class LinkedAccountsViewModel
|
||||
constructor(
|
||||
private val linkedAccountsUseCase: LinkedAccountsUseCase,
|
||||
private val deviceInfoProvider: DeviceInfoProvider,
|
||||
private val credDataProvider: CredDataProvider,
|
||||
private val npciRepository: NpciRepository,
|
||||
private val upiNumberRepository: UpiNumberRepository,
|
||||
private val naviPayNetworkConnectivity: NaviPayNetworkConnectivity,
|
||||
private val naviPaySessionHelper: NaviPaySessionHelper,
|
||||
private val naviCacheRepository: NaviCacheRepository,
|
||||
private val upiRequestIdUseCase: UpiRequestIdUseCase,
|
||||
val naviPayCustomerStatusHandler: NaviPayCustomerStatusHandler,
|
||||
private val dataStoreHelper: DataStoreHelper,
|
||||
private val resourceProvider: ResourceProvider,
|
||||
private val naviPayActivityDataProvider: NaviPayActivityDataProvider,
|
||||
private val refreshUpiNumbersUseCase: RefreshUpiNumbersUseCase,
|
||||
val accountListCheckBalanceUseCase: AccountListCheckBalanceUseCase,
|
||||
private val checkAccountBalanceUseCase: CheckAccountBalanceUseCase,
|
||||
savedStateHandle: SavedStateHandle
|
||||
) : NaviPayBaseVM() {
|
||||
|
||||
@@ -719,36 +714,25 @@ constructor(
|
||||
updateShowButtonLoaderState(showButtonLoader = true)
|
||||
}
|
||||
|
||||
val upiRequestId = upiRequestIdUseCase.execute()
|
||||
|
||||
val npciCredData =
|
||||
credDataProvider.balanceCheckCred(
|
||||
accountEntity = linkedAccountEntity,
|
||||
upiRequestId = upiRequestId
|
||||
)
|
||||
|
||||
val npciResult =
|
||||
npciRepository.fetchCredentials(
|
||||
npciCredData = npciCredData,
|
||||
metricInfo = getMetricInfo(screenName = screenName, isNae = { false })
|
||||
)
|
||||
when (npciResult) {
|
||||
is NpciResult.Error -> {
|
||||
checkAccountBalanceUseCase.generateCheckAccountBalanceCred(
|
||||
linkedAccountEntity = linkedAccountEntity,
|
||||
screenName = screenName,
|
||||
onNpciResultError = { isUserAborted ->
|
||||
updateShowButtonLoaderState(showButtonLoader = false)
|
||||
updateAccountId(accountId = "")
|
||||
if (!npciResult.isUserAborted) {
|
||||
if (!isUserAborted) {
|
||||
notifyError()
|
||||
}
|
||||
}
|
||||
is NpciResult.Success -> {
|
||||
},
|
||||
onNpciResultSuccess = { credBlock, upiRequestId ->
|
||||
navigateToNextScreen(
|
||||
credBlock = npciResult.data,
|
||||
credBlock = credBlock,
|
||||
upiRequestId = upiRequestId,
|
||||
selectedBankAccount = linkedAccountEntity
|
||||
)
|
||||
}
|
||||
else -> Unit
|
||||
}
|
||||
)
|
||||
|
||||
updateBottomSheetUIState(showBottomSheet = false)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user