TP-35278 | separate doc download support in LoanAggreementV2Activity (#7191)

* TP-35278 | first commit

* TP-35278 | fix 1.0
This commit is contained in:
Mayank Sheoran
2023-07-20 16:04:53 +05:30
committed by GitHub
parent f569b19a31
commit dedc6f74b6
5 changed files with 23 additions and 7 deletions

View File

@@ -18,9 +18,10 @@ data class FetchLoanAgreementResponse(
data class Details(
@SerializedName("uri") val uri: String?,
@SerializedName("rawCopyUri") val rawUri: String?,
@SerializedName("documentName") val documentName: String? = null,
@SerializedName("documentReferenceId") val documentReferenceId: String?,
@SerializedName("sanctionLetter") val sanctionLetter: SanctionLetterDetails? = null,
@SerializedName("balanceTransferRequestLetter") val balanceTransferDoc: SanctionLetterDetails? = null
@SerializedName("balanceTransferRequestLetter") val balanceTransferDoc: SanctionLetterDetails? = null,
)
data class SanctionLetterDetails(

View File

@@ -1378,7 +1378,8 @@ interface RetrofitService {
@GET("/loan-origination-manager/loan-applications/{loanApplicationId}/v2/loan-agreement-view")
suspend fun fetchLoanAgreementPollingDetails(
@Path("loanApplicationId") loanApplicationId: String
@Path("loanApplicationId") loanApplicationId: String,
@Query("documentType") documentType: String? = null
): Response<GenericResponse<UploadDataAsyncResponse>>
@GET("/litmus-proxy/v1/proxy/experiment")

View File

@@ -30,8 +30,8 @@ class LoanAgreementRepository : ResponseCallback() {
suspend fun fetchLoanAgreementV2View(loanApplicationId: String) =
apiResponseCallback(retrofitService().fetchLoanAgreementV2View(loanApplicationId))
suspend fun fetchLoanAgreementPollingDetails(loanApplicationId: String) =
apiResponseCallback(retrofitService().fetchLoanAgreementPollingDetails(loanApplicationId))
suspend fun fetchLoanAgreementPollingDetails(loanApplicationId: String, documentType: String? = null) =
apiResponseCallback(retrofitService().fetchLoanAgreementPollingDetails(loanApplicationId, documentType))
suspend fun fetchAsyncRequestDataForLoanAgreementPage(requestId: String) =
apiResponseCallback(retrofitService().fetchAsyncRequestDataForLoanAgreementPage(requestId))

View File

@@ -80,9 +80,9 @@ class LoanAgreementV2VM : BaseVM() {
}
}
fun fetchLoanAgreementPollingDetails(loanApplicationId: String) {
fun fetchLoanAgreementPollingDetails(loanApplicationId: String, documentType: String? = null) {
coroutineScope.launch {
val response = repository.fetchLoanAgreementPollingDetails(loanApplicationId)
val response = repository.fetchLoanAgreementPollingDetails(loanApplicationId, documentType)
if (response.isValidResponse()) {
_loanAgreementPollingDetails.value = response.data
} else {

View File

@@ -16,6 +16,7 @@ import androidx.core.view.isVisible
import androidx.databinding.DataBindingUtil
import androidx.lifecycle.ViewModelProvider
import com.google.android.play.core.splitcompat.SplitCompat
import com.navi.base.model.CtaData
import com.navi.base.sharedpref.PreferenceManager
import com.navi.base.utils.orElse
import com.navi.common.firebasedb.FirebaseStatusType
@@ -45,16 +46,22 @@ class LoanAgreementV2Activity : BaseActivity(), NaviHeaderView.InteractionListen
private var loanAgreementV2Data: FetchLoanAgreementV2Response? = null
private val helpEventTracker by lazy { NaviAnalytics.naviAnalytics.Faq() }
private val loanAgreementEventTracker by lazy { NaviAnalytics.naviAnalytics.LoanAgreement(screenName) }
private var documentType: String? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = DataBindingUtil.setContentView(this, R.layout.pl_activity_loan_agreement_v2)
super.setContentView(binding.root)
getCtaParameters()
initError(viewModel, actionErrorV2Enabled = true)
initListeners()
initObserver()
fetchLoanAgreementPollingDetails()
}
private fun getCtaParameters() {
documentType = intent.extras?.getString(DOCUMENT_TYPE)
}
private fun initListeners() {
binding.headerView.setOnInteractionListener(this)
binding.sanctionLetterDownloader.setOnClickListener {
@@ -90,6 +97,12 @@ class LoanAgreementV2Activity : BaseActivity(), NaviHeaderView.InteractionListen
downloadUrl = loanAgreementV2Data?.content?.details?.balanceTransferDoc?.uri,
destinationPath = BALANCE_TRANSFER_FILE_NAME,
)
loanAgreementV2Data?.content?.details?.documentName?.let { documentName ->
downloadDocuments(
downloadUrl = loanAgreementV2Data?.content?.details?.uri,
destinationPath = documentName,
)
}
}
private fun initObserver() {
@@ -190,7 +203,7 @@ class LoanAgreementV2Activity : BaseActivity(), NaviHeaderView.InteractionListen
if(isDataPollingEnabled){
PreferenceManager.getStringPreference(LOAN_APPLICATION_ID)?.let {
startShimmer()
viewModel.fetchLoanAgreementPollingDetails(it)
viewModel.fetchLoanAgreementPollingDetails(it, documentType)
}
}
else{
@@ -242,6 +255,7 @@ class LoanAgreementV2Activity : BaseActivity(), NaviHeaderView.InteractionListen
const val TAG = "LOAN_AGREEMENT_V2"
const val SANCTION_LETTER_FILE_NAME = "Navi_Personal_loan_Sanction_letter"
const val BALANCE_TRANSFER_FILE_NAME = "Balance_Transfer_Request_letter"
const val DOCUMENT_TYPE = "documentType"
}
override fun attachBaseContext(newBase: Context?) {