NTP-69433 | Owais | gold sell page backward compatibility (#16691)
This commit is contained in:
@@ -73,6 +73,7 @@ data class ExtraDataDetails(
|
||||
@SerializedName("loaderScreen") val loaderScreen: ActionCheckResponse? = null,
|
||||
@SerializedName("isUserInvested") val isUserInvested: Boolean? = null,
|
||||
@SerializedName("reward") val reward: Reward? = null,
|
||||
@SerializedName("backOnRefresh") val backOnRefresh: Boolean? = null,
|
||||
) : Parcelable
|
||||
|
||||
@Parcelize data class CacheConfig(val ttl: Long? = 0, val maxConsumptions: Int? = 0) : Parcelable
|
||||
|
||||
@@ -70,9 +70,15 @@ class DigitalGoldSellRepo @Inject constructor(private val retrofitService: Retro
|
||||
metricInfo = getGoldMetricInfo(isNae = { !it.isSuccessWithData() }),
|
||||
)
|
||||
|
||||
suspend fun fetchUpiValidationV2(upiId: String) =
|
||||
suspend fun fetchUpiValidationV2(upiId: String, source: String?) =
|
||||
apiResponseCallback(
|
||||
retrofitService.fetchUpiValidationV2(
|
||||
retrofitService.fetchUpiValidationV2(upiId = upiId, source = source.toString()),
|
||||
metricInfo = getGoldMetricInfo(isNae = { !it.isSuccessWithData() }),
|
||||
)
|
||||
|
||||
suspend fun fetchUpiValidationV3(upiId: String) =
|
||||
apiResponseCallback(
|
||||
retrofitService.fetchUpiValidationV3(
|
||||
upiValidationRequest = UpiValidationRequest(upiId)
|
||||
),
|
||||
metricInfo = getGoldMetricInfo(isNae = { !it.isSuccessWithData() }),
|
||||
|
||||
@@ -179,8 +179,14 @@ interface RetrofitService {
|
||||
@GET("/kuber/order/add-upi-page-content")
|
||||
suspend fun fetchAddUpiPageContent(): Response<GenericResponse<WidgetResponse>>
|
||||
|
||||
@POST("/kuber/upi/v2")
|
||||
@GET("/kuber/upi/v2/validate")
|
||||
suspend fun fetchUpiValidationV2(
|
||||
@Query("upiId") upiId: String,
|
||||
@Query("source") source: String,
|
||||
): Response<GenericResponse<UpiValidationResponse>>
|
||||
|
||||
@POST("/kuber/upi/v2")
|
||||
suspend fun fetchUpiValidationV3(
|
||||
@Body upiValidationRequest: UpiValidationRequest
|
||||
): Response<GenericResponse<UpiValidationResponse>>
|
||||
|
||||
|
||||
@@ -303,7 +303,7 @@ class DigitalGoldSellActivity : GoldBaseActivity(), WidgetCallback, NewBottomShe
|
||||
}
|
||||
|
||||
private fun handleBackPress() {
|
||||
if (sharedVM.isAddUpiIdScreenVisible()) {
|
||||
if (sharedVM.isAddUpiIdScreenVisible() && sharedVM.getBackOnRefresh() == false) {
|
||||
sharedVM.setRefreshScreen(true)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -143,11 +143,15 @@ class DigitalGoldSellUpiFragment :
|
||||
widgetResponse ->
|
||||
clearInputWidgetValues()
|
||||
|
||||
widgetResponse.extraData?.backOnRefresh?.let { sharedVM.setBackOnRefresh(it) }
|
||||
sharedVM.setAddUpiIdScreenVisible(false)
|
||||
binding.rvItems.isVisible = true
|
||||
sharedVM.setActivityComponent(true)
|
||||
stopShimmer()
|
||||
widgetResponse.header?.let { header -> sharedVM.setHeaders(header) }
|
||||
widgetResponse.header?.let { header ->
|
||||
viewModel.prefetchData(header.actionData?.url, screenName = screenName)
|
||||
sharedVM.setHeaders(header)
|
||||
}
|
||||
widgetResponse.footerWidget?.let { listOfWidgets ->
|
||||
useCommonFooter = widgetResponse.extraData?.useCommonFooter.orTrue()
|
||||
if (useCommonFooter) {
|
||||
@@ -230,7 +234,13 @@ class DigitalGoldSellUpiFragment :
|
||||
TemporaryStorageHelper.SOFT_REF_CACHE.remove(SELL_GOLD_INPUT_SCREEN)
|
||||
TemporaryStorageHelper.setIsDataModified(SELL_GOLD_INPUT_SCREEN, true)
|
||||
}
|
||||
fetchDigitalSellUpiScreen(isPriceExpired = !sharedVM.isAddUpiIdScreenVisible())
|
||||
if (sharedVM.getBackOnRefresh() == false) {
|
||||
fetchDigitalSellUpiScreen(
|
||||
isPriceExpired = !sharedVM.isAddUpiIdScreenVisible()
|
||||
)
|
||||
} else {
|
||||
activity?.onBackPressed()
|
||||
}
|
||||
sharedVM.setRefreshScreen(false)
|
||||
}
|
||||
}
|
||||
@@ -247,7 +257,9 @@ class DigitalGoldSellUpiFragment :
|
||||
upiValidationResponse.data?.bottomSheetData?.let {
|
||||
widgetNaviAnalyticsEventTracker.onWidgetViewedEvent(it.metaData?.viewedData)
|
||||
showCommonBottomSheet(it)
|
||||
navigateWith(upiValidationResponse.data?.actionData)
|
||||
if (sharedVM.getBackOnRefresh() == false) {
|
||||
navigateWith(upiValidationResponse.data?.actionData)
|
||||
}
|
||||
}
|
||||
?: run {
|
||||
upiValidationResponse.data?.widgetBottomSheetData?.let { bottomSheetData ->
|
||||
@@ -434,13 +446,19 @@ class DigitalGoldSellUpiFragment :
|
||||
fetchUpiValidationResponse(naviClickAction.actionData)
|
||||
return
|
||||
}
|
||||
if (naviClickAction.actionData?.url.equals(ADD_NEW_UPI_ID_SCREEN)) {
|
||||
if (
|
||||
naviClickAction.actionData?.url.equals(ADD_NEW_UPI_ID_SCREEN) &&
|
||||
sharedVM.getBackOnRefresh() == false
|
||||
) {
|
||||
showShimmer()
|
||||
viewModel.fetchAddUpiPageContent()
|
||||
widgetBottomSheet?.safelyDismissDialog()
|
||||
return
|
||||
}
|
||||
if (naviClickAction.actionData?.url.equals(CONTINUE_WITH_SELECTED_UPI)) {
|
||||
if (
|
||||
naviClickAction.actionData?.url.equals(CONTINUE_WITH_SELECTED_UPI) &&
|
||||
sharedVM.getBackOnRefresh() == false
|
||||
) {
|
||||
widgetBottomSheet?.safelyDismissDialog()
|
||||
return
|
||||
}
|
||||
@@ -481,7 +499,10 @@ class DigitalGoldSellUpiFragment :
|
||||
}
|
||||
}
|
||||
is NaviWidgetClickWithCtaData -> {
|
||||
if (naviClickAction.ctaData?.url.equals(ADD_NEW_UPI_ID_SCREEN)) {
|
||||
if (
|
||||
naviClickAction.ctaData?.url.equals(ADD_NEW_UPI_ID_SCREEN) &&
|
||||
sharedVM.getBackOnRefresh() == false
|
||||
) {
|
||||
showShimmer()
|
||||
viewModel.fetchAddUpiPageContent()
|
||||
widgetBottomSheet?.safelyDismissDialog()
|
||||
@@ -492,8 +513,12 @@ class DigitalGoldSellUpiFragment :
|
||||
}
|
||||
|
||||
private fun fetchUpiValidationResponse(actionData: ActionData?) {
|
||||
actionData?.bottomSheetData?.let { showCommonBottomSheet(it) }
|
||||
viewModel.fetchUpiValidationV2(sharedVM.getUpiId())
|
||||
if (sharedVM.getBackOnRefresh() == false) {
|
||||
viewModel.fetchUpiValidationV3(sharedVM.getUpiId())
|
||||
} else {
|
||||
actionData?.bottomSheetData?.let { showCommonBottomSheet(it) }
|
||||
viewModel.fetchUpiValidationV2(upiId = sharedVM.getUpiId(), source = null)
|
||||
}
|
||||
}
|
||||
|
||||
private fun toShowBottomSheet(action: ActionData?) {
|
||||
@@ -622,7 +647,10 @@ class DigitalGoldSellUpiFragment :
|
||||
commonBottomSheet.dismiss()
|
||||
}
|
||||
|
||||
if (actionData?.url.equals(REFRESH_AFTER_UPI_VERIFICATION)) {
|
||||
if (
|
||||
actionData?.url.equals(REFRESH_AFTER_UPI_VERIFICATION) &&
|
||||
sharedVM.getBackOnRefresh() == false
|
||||
) {
|
||||
fetchDigitalSellUpiScreen()
|
||||
commonBottomSheet.dismiss()
|
||||
return
|
||||
|
||||
@@ -69,6 +69,14 @@ class DigitalGoldSellSharedVM : BaseVM(isExceptionNeedToShow = false) {
|
||||
|
||||
private var exchangeRateId: String = ""
|
||||
|
||||
private var backOnRefresh: Boolean? = null
|
||||
|
||||
fun setBackOnRefresh(backOnRefresh: Boolean) {
|
||||
this.backOnRefresh = backOnRefresh
|
||||
}
|
||||
|
||||
fun getBackOnRefresh() = backOnRefresh
|
||||
|
||||
fun setActualSellAmount(actualSellAmount: Double) {
|
||||
this.actualSellAmount = actualSellAmount
|
||||
}
|
||||
|
||||
@@ -175,9 +175,20 @@ class DigitalGoldSellVM @Inject constructor(private val goldSellRepo: DigitalGol
|
||||
}
|
||||
}
|
||||
|
||||
fun fetchUpiValidationV2(upiId: String) {
|
||||
fun fetchUpiValidationV2(upiId: String, source: String?) {
|
||||
coroutineScope.launch {
|
||||
val response = goldSellRepo.fetchUpiValidationV2(upiId)
|
||||
val response = goldSellRepo.fetchUpiValidationV2(upiId, source = source)
|
||||
if (response.error.isNull() && response.errors.isNullOrEmpty()) {
|
||||
_upiIdValidationResponse.value = response.data
|
||||
} else {
|
||||
setErrorData(response.errors, response.error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun fetchUpiValidationV3(upiId: String) {
|
||||
coroutineScope.launch {
|
||||
val response = goldSellRepo.fetchUpiValidationV3(upiId)
|
||||
if (response.error.isNull() && response.errors.isNullOrEmpty()) {
|
||||
_upiIdValidationResponse.value = response.data
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user