|
|
@ -5,7 +5,6 @@ import androidx.lifecycle.MutableLiveData |
|
|
|
import androidx.lifecycle.ViewModel |
|
|
|
import androidx.lifecycle.viewModelScope |
|
|
|
import com.google.gson.JsonObject |
|
|
|
import com.nivesh.production.bajajfd.model.CheckFDKYCRequest |
|
|
|
import com.nivesh.production.bajajfd.model.GetCodeRequest |
|
|
|
import com.nivesh.production.bajajfd.model.GetMaturityAmountRequest |
|
|
|
import com.nivesh.production.bajajfd.model.GetRatesRequest |
|
|
@ -19,57 +18,62 @@ import kotlinx.coroutines.launch |
|
|
|
class StepOneBajajFDViewModel(private val mainRepository: MainRepository) : ViewModel() { |
|
|
|
|
|
|
|
val getCodeMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() |
|
|
|
fun getCode(requestBody: GetCodeRequest, token : String, activity: Activity) = viewModelScope.launch( |
|
|
|
Common.handleError(activity) |
|
|
|
) { |
|
|
|
if (Common.isNetworkAvailable(activity)) { |
|
|
|
getCodeMutableData.postValue(Resource.Loading()) |
|
|
|
val response = mainRepository.getCodesResponse(requestBody, token) |
|
|
|
getCodeMutableData.postValue(handleResponse(response)) |
|
|
|
fun getCode(requestBody: GetCodeRequest, token: String, activity: Activity) = |
|
|
|
viewModelScope.launch( |
|
|
|
Common.handleError(activity) |
|
|
|
) { |
|
|
|
if (Common.isNetworkAvailable(activity)) { |
|
|
|
getCodeMutableData.postValue(Resource.Loading()) |
|
|
|
val response = mainRepository.getCodesResponse(requestBody, token) |
|
|
|
getCodeMutableData.postValue(handleResponse(response)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
val getRatesMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() |
|
|
|
fun getRates(getRatesRequest: GetRatesRequest, token: String, activity: Activity) = viewModelScope.launch( |
|
|
|
Common.handleError(activity) |
|
|
|
) { |
|
|
|
if (Common.isNetworkAvailable(activity)) { |
|
|
|
getRatesMutableData.postValue(Resource.Loading()) |
|
|
|
val response = mainRepository.getRatesResponse(getRatesRequest, token) |
|
|
|
getRatesMutableData.postValue(handleResponse(response)) |
|
|
|
fun getRates(getRatesRequest: GetRatesRequest, token: String, activity: Activity) = |
|
|
|
viewModelScope.launch( |
|
|
|
Common.handleError(activity) |
|
|
|
) { |
|
|
|
if (Common.isNetworkAvailable(activity)) { |
|
|
|
getRatesMutableData.postValue(Resource.Loading()) |
|
|
|
val response = mainRepository.getRatesResponse(getRatesRequest, token) |
|
|
|
getRatesMutableData.postValue(handleResponse(response)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
val getMaturityAmountMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() |
|
|
|
fun getMaturityAmount(requestBody: GetMaturityAmountRequest, activity: Activity) = viewModelScope.launch ( |
|
|
|
Common.handleError(activity) |
|
|
|
){ |
|
|
|
if (Common.isNetworkAvailable(activity)) { |
|
|
|
getMaturityAmountMutableData.postValue(Resource.Loading()) |
|
|
|
val response = mainRepository.createCalculateFDMaturityAmount(requestBody, token) |
|
|
|
getMaturityAmountMutableData.postValue(handleResponse(response)) |
|
|
|
fun getMaturityAmount(requestBody: GetMaturityAmountRequest, activity: Activity) = |
|
|
|
viewModelScope.launch( |
|
|
|
Common.handleError(activity) |
|
|
|
) { |
|
|
|
if (Common.isNetworkAvailable(activity)) { |
|
|
|
getMaturityAmountMutableData.postValue(Resource.Loading()) |
|
|
|
val response = mainRepository.createCalculateFDMaturityAmount(requestBody, token) |
|
|
|
getMaturityAmountMutableData.postValue(handleResponse(response)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
val getMinAmountMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() |
|
|
|
fun getMinAmount(requestBody: GetCodeRequest, token : String, activity: Activity) = viewModelScope.launch( |
|
|
|
Common.handleError(activity) |
|
|
|
) { |
|
|
|
if (Common.isNetworkAvailable(activity)) { |
|
|
|
getMinAmountMutableData.postValue(Resource.Loading()) |
|
|
|
val response = mainRepository.getCodesResponse(requestBody, token) |
|
|
|
getMinAmountMutableData.postValue(handleResponse(response)) |
|
|
|
fun getMinAmount(requestBody: GetCodeRequest, token: String, activity: Activity) = |
|
|
|
viewModelScope.launch( |
|
|
|
Common.handleError(activity) |
|
|
|
) { |
|
|
|
if (Common.isNetworkAvailable(activity)) { |
|
|
|
getMinAmountMutableData.postValue(Resource.Loading()) |
|
|
|
val response = mainRepository.getCodesResponse(requestBody, token) |
|
|
|
getMinAmountMutableData.postValue(handleResponse(response)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
val getMaxAmountMutableData: MutableLiveData<Resource<JsonObject>> = MutableLiveData() |
|
|
|
fun getMaxAmount(requestBody: GetCodeRequest, token : String,activity: Activity) = viewModelScope.launch( |
|
|
|
Common.handleError(activity) |
|
|
|
) { |
|
|
|
if (Common.isNetworkAvailable(activity)) { |
|
|
|
getMaxAmountMutableData.postValue(Resource.Loading()) |
|
|
|
val response = mainRepository.getCodesResponse(requestBody, token) |
|
|
|
getMaxAmountMutableData.postValue(handleResponse(response)) |
|
|
|
fun getMaxAmount(requestBody: GetCodeRequest, token: String, activity: Activity) = |
|
|
|
viewModelScope.launch( |
|
|
|
Common.handleError(activity) |
|
|
|
) { |
|
|
|
if (Common.isNetworkAvailable(activity)) { |
|
|
|
getMaxAmountMutableData.postValue(Resource.Loading()) |
|
|
|
val response = mainRepository.getCodesResponse(requestBody, token) |
|
|
|
getMaxAmountMutableData.postValue(handleResponse(response)) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |