NTP-39209 | Narayan | NPCI Result data class simplification (#15059)
This commit is contained in:
committed by
GitHub
parent
3b17d3a4ff
commit
8e39c2dbe2
@@ -556,7 +556,7 @@ constructor(
|
||||
}
|
||||
|
||||
private suspend fun onPauseUnpauseMandateCLCallback(
|
||||
npciResult: NpciResult<String>,
|
||||
npciResult: NpciResult,
|
||||
upiRequestId: String,
|
||||
requestType: PauseUnpauseMandateRequestType,
|
||||
shouldAutoInitCL: Boolean,
|
||||
@@ -907,7 +907,7 @@ constructor(
|
||||
}
|
||||
|
||||
private suspend fun onRevokeMandateCLCallback(
|
||||
npciResult: NpciResult<String>,
|
||||
npciResult: NpciResult,
|
||||
upiRequestId: String,
|
||||
shouldAutoInitCL: Boolean,
|
||||
) {
|
||||
|
||||
@@ -525,7 +525,7 @@ constructor(
|
||||
}
|
||||
|
||||
private suspend fun onCreateMandateCLCallback(
|
||||
npciResult: NpciResult<String>,
|
||||
npciResult: NpciResult,
|
||||
upiRequestId: String,
|
||||
selectedBankAccount: LinkedAccountEntity,
|
||||
) {
|
||||
@@ -732,7 +732,7 @@ constructor(
|
||||
}
|
||||
|
||||
private suspend fun onApproveMandateCLCallback(
|
||||
npciResult: NpciResult<String>,
|
||||
npciResult: NpciResult,
|
||||
selectedBankAccount: LinkedAccountEntity,
|
||||
mandateEntity: MandateEntity,
|
||||
) {
|
||||
|
||||
@@ -25,7 +25,7 @@ class CredParser(private val credTypes: List<String>) {
|
||||
const val CRED_SUBTYPE_AADHAAR = "AADHAAR"
|
||||
}
|
||||
|
||||
fun parseResult(resultData: Bundle?): NpciResult<String> {
|
||||
fun parseResult(resultData: Bundle?): NpciResult {
|
||||
val genericErrorMessage = "Something went wrong from NPCI"
|
||||
return if (resultData == null) {
|
||||
NpciResult.Error(genericErrorMessage)
|
||||
|
||||
@@ -142,12 +142,12 @@ enum class OtpResponseType {
|
||||
TRIGGERED_AADHAAR_OTP_RESPONSE,
|
||||
}
|
||||
|
||||
sealed class NpciResult<out T> {
|
||||
data class Success<out T>(val data: T) : NpciResult<T>()
|
||||
sealed class NpciResult {
|
||||
data class Success(val data: String) : NpciResult()
|
||||
|
||||
data object SendOtp : NpciResult<Nothing>()
|
||||
data object SendOtp : NpciResult()
|
||||
|
||||
data class Error(val message: String) : NpciResult<Nothing>() {
|
||||
data class Error(val message: String) : NpciResult() {
|
||||
val isUserAborted
|
||||
get() = message == ERROR_USER_ABORTED
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ constructor(
|
||||
*/
|
||||
private suspend fun getToken(
|
||||
metricInfo: MetricInfo<RepoResult<NpciTokenResponse>>
|
||||
): NpciResult<String> {
|
||||
): NpciResult {
|
||||
val isTokenValid = npciSessionHandler.isTokenValid()
|
||||
naviPayAnalytics.onGetTokenCalled(isTokenValid = isTokenValid)
|
||||
return if (isTokenValid) {
|
||||
@@ -95,7 +95,7 @@ constructor(
|
||||
handler: Handler = Handler(Looper.getMainLooper()),
|
||||
npciCredData: NpciCredData,
|
||||
metricInfo: MetricInfo<RepoResult<NpciTokenResponse>>,
|
||||
): NpciResult<String> {
|
||||
): NpciResult {
|
||||
|
||||
mutexForFetchCredentials.withLock {
|
||||
val npciTokenResult = getToken(metricInfo = metricInfo)
|
||||
@@ -139,7 +139,7 @@ constructor(
|
||||
private suspend fun registerUser(
|
||||
npciClService: NpciClService,
|
||||
metricInfo: MetricInfo<RepoResult<NpciTokenResponse>>,
|
||||
): NpciResult<String> {
|
||||
): NpciResult {
|
||||
val npciClServiceInstance = npciClService.instance()
|
||||
val deviceData = deviceInfoProvider.getDeviceData()
|
||||
val mobileNumber = deviceData.provider.phoneNumber
|
||||
@@ -302,7 +302,7 @@ constructor(
|
||||
npciKey: String,
|
||||
deviceData: DeviceData,
|
||||
npciCredData: NpciCredData,
|
||||
onResult: (NpciResult<String>) -> Unit,
|
||||
onResult: (NpciResult) -> Unit,
|
||||
) {
|
||||
val credParser = CredParser(credTypes = npciCredData.credTypeTxIdMap.keys.toList())
|
||||
val remoteResultReceiver =
|
||||
@@ -398,7 +398,7 @@ constructor(
|
||||
npciClServiceInstance: CLServices,
|
||||
handler: Handler,
|
||||
credParser: CredParser,
|
||||
onResult: (NpciResult<String>) -> Unit,
|
||||
onResult: (NpciResult) -> Unit,
|
||||
): CLRemoteResultReceiver {
|
||||
val remoteResultReceiver =
|
||||
CLRemoteResultReceiver(
|
||||
|
||||
@@ -735,10 +735,7 @@ constructor(
|
||||
)
|
||||
}
|
||||
|
||||
private suspend fun onRevokeMandateCLCallback(
|
||||
npciResult: NpciResult<String>,
|
||||
upiRequestId: String,
|
||||
) {
|
||||
private suspend fun onRevokeMandateCLCallback(npciResult: NpciResult, upiRequestId: String) {
|
||||
when (npciResult) {
|
||||
is NpciResult.Success -> {
|
||||
updateUIState(uiState = LinkedAccountDetailScreenUIState.MandateDeletionInProgress)
|
||||
@@ -865,7 +862,7 @@ constructor(
|
||||
}
|
||||
|
||||
private suspend fun onChangePinCLCallback(
|
||||
npciResult: NpciResult<String>,
|
||||
npciResult: NpciResult,
|
||||
upiRequestId: String,
|
||||
linkedAccountEntity: LinkedAccountEntity,
|
||||
pspType: PspType, // TODO: Multibank - pass pspType after multibank api integration
|
||||
|
||||
@@ -531,7 +531,7 @@ constructor(
|
||||
}
|
||||
|
||||
private suspend fun onSetResetPinCLCallback(
|
||||
npciResult: NpciResult<String>,
|
||||
npciResult: NpciResult,
|
||||
actionName: String,
|
||||
upiRequestId: String,
|
||||
linkedAccountEntity: LinkedAccountEntity,
|
||||
|
||||
Reference in New Issue
Block a user