|
@ -19,6 +19,7 @@ import com.nivesh.production.bajajfd.ui.providerfactory.* |
|
|
import com.nivesh.production.bajajfd.util.Common |
|
|
import com.nivesh.production.bajajfd.util.Common |
|
|
import com.nivesh.production.bajajfd.util.Common.Companion.defaultShape |
|
|
import com.nivesh.production.bajajfd.util.Common.Companion.defaultShape |
|
|
import com.nivesh.production.bajajfd.util.Common.Companion.selectedShape |
|
|
import com.nivesh.production.bajajfd.util.Common.Companion.selectedShape |
|
|
|
|
|
import com.nivesh.production.bajajfd.util.Common.Companion.showDialogValidation |
|
|
import com.nivesh.production.bajajfd.util.Constants.Companion.token |
|
|
import com.nivesh.production.bajajfd.util.Constants.Companion.token |
|
|
import com.nivesh.production.bajajfd.util.Resource |
|
|
import com.nivesh.production.bajajfd.util.Resource |
|
|
import com.nivesh.production.bajajfd.viewModel.* |
|
|
import com.nivesh.production.bajajfd.viewModel.* |
|
@ -43,7 +44,7 @@ class BajajFdMainActivity : AppCompatActivity(), BajajFDInterface { |
|
|
var nomineeGuardianDetails: NomineeGuardianDetails |
|
|
var nomineeGuardianDetails: NomineeGuardianDetails |
|
|
var getClientDetailsResponse: getClientDetailsResponse |
|
|
var getClientDetailsResponse: getClientDetailsResponse |
|
|
|
|
|
|
|
|
var stepCount : Int = 0 |
|
|
|
|
|
|
|
|
private var stepCount: Int = 0 |
|
|
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) { |
|
|
override fun onCreate(savedInstanceState: Bundle?) { |
|
|
super.onCreate(savedInstanceState) |
|
|
super.onCreate(savedInstanceState) |
|
@ -120,17 +121,19 @@ class BajajFdMainActivity : AppCompatActivity(), BajajFDInterface { |
|
|
stepCount = stepsCountResponse.Response.StepsCount |
|
|
stepCount = stepsCountResponse.Response.StepsCount |
|
|
getClientDetailsApi(stepsCountResponse.Response.StepsCount) |
|
|
getClientDetailsApi(stepsCountResponse.Response.StepsCount) |
|
|
} |
|
|
} |
|
|
// 650 -> refreshToken() |
|
|
|
|
|
|
|
|
650 -> refreshToken(fdStepsCount) |
|
|
else -> { |
|
|
else -> { |
|
|
|
|
|
|
|
|
|
|
|
showDialogValidation( |
|
|
|
|
|
this@BajajFdMainActivity, |
|
|
|
|
|
stepsCountResponse.Response.Errors[0].ErrorMessage |
|
|
|
|
|
) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
is Resource.Error -> { |
|
|
is Resource.Error -> { |
|
|
response.message?.let { message -> |
|
|
response.message?.let { message -> |
|
|
Log.e(" ", "An error occurred:$message") |
|
|
|
|
|
|
|
|
showDialogValidation(this@BajajFdMainActivity, message) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
is Resource.Loading -> { |
|
|
is Resource.Loading -> { |
|
@ -140,6 +143,13 @@ class BajajFdMainActivity : AppCompatActivity(), BajajFDInterface { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun refreshToken(fdStepsCount: FDStepsCountRequest) { |
|
|
|
|
|
if (Common.isNetworkAvailable(this@BajajFdMainActivity)) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun getClientDetailsApi(stepsCount: Int) { |
|
|
private fun getClientDetailsApi(stepsCount: Int) { |
|
|
if (Common.isNetworkAvailable(this@BajajFdMainActivity)) { |
|
|
if (Common.isNetworkAvailable(this@BajajFdMainActivity)) { |
|
|
val getClientDetailsRequest = getClientDetailsRequest() |
|
|
val getClientDetailsRequest = getClientDetailsRequest() |
|
@ -183,14 +193,16 @@ class BajajFdMainActivity : AppCompatActivity(), BajajFDInterface { |
|
|
checkFDCKYCApi() |
|
|
checkFDCKYCApi() |
|
|
} |
|
|
} |
|
|
// 650 -> refreshToken() |
|
|
// 650 -> refreshToken() |
|
|
else -> {} |
|
|
|
|
|
|
|
|
else -> { |
|
|
|
|
|
showDialogValidation(this@BajajFdMainActivity, response.message) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
is Resource.Error -> { |
|
|
is Resource.Error -> { |
|
|
response.message?.let { message -> |
|
|
response.message?.let { message -> |
|
|
Log.e(" ", "An error occurred:$message") |
|
|
|
|
|
|
|
|
showDialogValidation(this@BajajFdMainActivity, message) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
is Resource.Loading -> { |
|
|
is Resource.Loading -> { |
|
@ -282,10 +294,11 @@ class BajajFdMainActivity : AppCompatActivity(), BajajFDInterface { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private fun checkFDCKYCApi() { |
|
|
private fun checkFDCKYCApi() { |
|
|
if (Common.isNetworkAvailable(this@BajajFdMainActivity)){ |
|
|
|
|
|
|
|
|
if (Common.isNetworkAvailable(this@BajajFdMainActivity)) { |
|
|
if (getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CM_MOBILE?.isNotEmpty()!! && getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_DOB?.isNotEmpty()!! && getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_PAN?.isNotEmpty()!! && getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE?.isNotEmpty()!!) { |
|
|
if (getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CM_MOBILE?.isNotEmpty()!! && getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_DOB?.isNotEmpty()!! && getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_PAN?.isNotEmpty()!! && getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_CODE?.isNotEmpty()!!) { |
|
|
val checkFDKYCRequest = CheckFDKYCRequest() |
|
|
val checkFDKYCRequest = CheckFDKYCRequest() |
|
|
checkFDKYCRequest.Mobile = getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CM_MOBILE |
|
|
|
|
|
|
|
|
checkFDKYCRequest.Mobile = |
|
|
|
|
|
getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CM_MOBILE |
|
|
checkFDKYCRequest.DOB = |
|
|
checkFDKYCRequest.DOB = |
|
|
getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_DOB |
|
|
getClientDetailsResponse.ObjectResponse?.clientDetails?.clientMasterMFD?.CLIENT_DOB |
|
|
checkFDKYCRequest.PAN = |
|
|
checkFDKYCRequest.PAN = |
|
@ -309,14 +322,19 @@ class BajajFdMainActivity : AppCompatActivity(), BajajFDInterface { |
|
|
fdInvestmentDetails.CustomerType = "" |
|
|
fdInvestmentDetails.CustomerType = "" |
|
|
} |
|
|
} |
|
|
// 650 -> refreshToken() |
|
|
// 650 -> refreshToken() |
|
|
else -> {} |
|
|
|
|
|
|
|
|
else -> { |
|
|
|
|
|
showDialogValidation( |
|
|
|
|
|
this@BajajFdMainActivity, |
|
|
|
|
|
getCodeResponse.Response.Errors[0].ErrorMessage |
|
|
|
|
|
) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
is Resource.Error -> { |
|
|
is Resource.Error -> { |
|
|
response.message?.let { message -> |
|
|
response.message?.let { message -> |
|
|
Log.e(" ", "An error occurred:$message") |
|
|
|
|
|
|
|
|
showDialogValidation(this@BajajFdMainActivity, message) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
is Resource.Loading -> { |
|
|
is Resource.Loading -> { |
|
@ -352,13 +370,13 @@ class BajajFdMainActivity : AppCompatActivity(), BajajFDInterface { |
|
|
// step 2 response |
|
|
// step 2 response |
|
|
override fun stepTwoApi(data: CreateFDRequest) { |
|
|
override fun stepTwoApi(data: CreateFDRequest) { |
|
|
Log.e("stepTwoApi", " response ---> $data") |
|
|
Log.e("stepTwoApi", " response ---> $data") |
|
|
if (stepCount == 4) { |
|
|
|
|
|
// go to step 3 image Upload |
|
|
|
|
|
binding.viewPager.currentItem = 2 |
|
|
|
|
|
}else{ |
|
|
|
|
|
// call create fd api bypass step 3 |
|
|
|
|
|
createFDApi(data , 2) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (stepCount == 4) { |
|
|
|
|
|
// go to step 3 image Upload |
|
|
|
|
|
binding.viewPager.currentItem = 2 |
|
|
|
|
|
} else { |
|
|
|
|
|
// call create fd api bypass step 3 |
|
|
|
|
|
createFDApi(data, 2) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -376,14 +394,14 @@ class BajajFdMainActivity : AppCompatActivity(), BajajFDInterface { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private fun createFDApi(data: CreateFDRequest, currentItem: Int) { |
|
|
private fun createFDApi(data: CreateFDRequest, currentItem: Int) { |
|
|
if (Common.isNetworkAvailable(this@BajajFdMainActivity)){ |
|
|
|
|
|
|
|
|
if (Common.isNetworkAvailable(this@BajajFdMainActivity)) { |
|
|
|
|
|
|
|
|
viewModel.createFDApi(data, token) |
|
|
viewModel.createFDApi(data, token) |
|
|
viewModel.getFDResponseMutableData.observe(this) { response -> |
|
|
viewModel.getFDResponseMutableData.observe(this) { response -> |
|
|
when (response) { |
|
|
when (response) { |
|
|
is Resource.Success -> { |
|
|
is Resource.Success -> { |
|
|
Log.e("response", "-->$response") |
|
|
Log.e("response", "-->$response") |
|
|
val createFDApplicationResponse : CreateFDApplicationResponse = |
|
|
|
|
|
|
|
|
val createFDApplicationResponse: CreateFDApplicationResponse = |
|
|
Gson().fromJson( |
|
|
Gson().fromJson( |
|
|
response.data?.toString(), |
|
|
response.data?.toString(), |
|
|
CreateFDApplicationResponse::class.java |
|
|
CreateFDApplicationResponse::class.java |
|
@ -392,17 +410,23 @@ class BajajFdMainActivity : AppCompatActivity(), BajajFDInterface { |
|
|
when (code) { |
|
|
when (code) { |
|
|
200 -> { |
|
|
200 -> { |
|
|
binding.viewPager.currentItem = currentItem |
|
|
binding.viewPager.currentItem = currentItem |
|
|
StepFourBajajFDFragment.getInstance(this).getFDData(createFDApplicationResponse) |
|
|
|
|
|
|
|
|
StepFourBajajFDFragment.getInstance(this) |
|
|
|
|
|
.getFDData(createFDApplicationResponse) |
|
|
} |
|
|
} |
|
|
// 650 -> refreshToken() |
|
|
// 650 -> refreshToken() |
|
|
else -> {} |
|
|
|
|
|
|
|
|
else -> { |
|
|
|
|
|
showDialogValidation( |
|
|
|
|
|
this@BajajFdMainActivity, |
|
|
|
|
|
createFDApplicationResponse.Response.Errors[0].ErrorMessage |
|
|
|
|
|
) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
is Resource.Error -> { |
|
|
is Resource.Error -> { |
|
|
response.message?.let { message -> |
|
|
response.message?.let { message -> |
|
|
Log.e(" ", "An error occurred:$message") |
|
|
|
|
|
|
|
|
showDialogValidation(this@BajajFdMainActivity, message) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
is Resource.Loading -> { |
|
|
is Resource.Loading -> { |
|
@ -416,5 +440,4 @@ class BajajFdMainActivity : AppCompatActivity(), BajajFDInterface { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |