|
@@ -14,11 +14,115 @@ class BetsDetailViewModel(val apiService: ApiService, val prefHelper: PrefHelper
|
|
|
private val _state = MutableLiveData(BetsDetailViewState())
|
|
|
val state: LiveData<BetsDetailViewState> = _state
|
|
|
|
|
|
- fun getBetsDetailData(invoiceNum: String) {
|
|
|
+ fun getLottPlusInvoiceDetail(invoiceNum: String) {
|
|
|
if (_state.value!!.isProgress) return
|
|
|
_state.value = prev().copy(isProgress = true)
|
|
|
disposables.add(
|
|
|
- apiService.getBettingDetail(invoiceNum)
|
|
|
+ apiService.getLottPlusInvoiceDetail(invoiceNum)
|
|
|
+ .timeout(60, TimeUnit.SECONDS)
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe({
|
|
|
+ if (it.resultCode == "1") {
|
|
|
+ _state.value = prev().copy(
|
|
|
+ isProgress = false,
|
|
|
+ error = null,
|
|
|
+ betDetailData = it.data
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ _state.value =
|
|
|
+ prev().copy(isProgress = false, error = "[${it.message.description}]")
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ val message: String = "ប្រតិបត្តិការមិនជោគជ័យ\n" + it.getErrorCode()
|
|
|
+ _state.value = prev().copy(isProgress = false, error = message)
|
|
|
+ })
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ fun getLott80InvoiceDetail(invoiceNum: String) {
|
|
|
+ if (_state.value!!.isProgress) return
|
|
|
+ _state.value = prev().copy(isProgress = true)
|
|
|
+ disposables.add(
|
|
|
+ apiService.getLott80Invoice(invoiceNum)
|
|
|
+ .timeout(60, TimeUnit.SECONDS)
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe({
|
|
|
+ if (it.resultCode == "1") {
|
|
|
+ _state.value = prev().copy(
|
|
|
+ isProgress = false,
|
|
|
+ error = null,
|
|
|
+ betDetailData = it.data
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ _state.value =
|
|
|
+ prev().copy(isProgress = false, error = "[${it.message.description}]")
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ val message: String = "ប្រតិបត្តិការមិនជោគជ័យ\n" + it.getErrorCode()
|
|
|
+ _state.value = prev().copy(isProgress = false, error = message)
|
|
|
+ })
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ fun getYukiInvoiceDetail(invoiceNum: String) {
|
|
|
+ if (_state.value!!.isProgress) return
|
|
|
+ _state.value = prev().copy(isProgress = true)
|
|
|
+ disposables.add(
|
|
|
+ apiService.getYukiInvoiceDetail(invoiceNum)
|
|
|
+ .timeout(60, TimeUnit.SECONDS)
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe({
|
|
|
+ if (it.resultCode == "1") {
|
|
|
+ _state.value = prev().copy(
|
|
|
+ isProgress = false,
|
|
|
+ error = null,
|
|
|
+ betDetailYukiData = it.data
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ _state.value =
|
|
|
+ prev().copy(isProgress = false, error = "[${it.message.description}]")
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ val message: String = "ប្រតិបត្តិការមិនជោគជ័យ\n" + it.getErrorCode()
|
|
|
+ _state.value = prev().copy(isProgress = false, error = message)
|
|
|
+ })
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ fun get6NumberInvoiceDetail(invoiceNum: String) {
|
|
|
+ if (_state.value!!.isProgress) return
|
|
|
+ _state.value = prev().copy(isProgress = true)
|
|
|
+ disposables.add(
|
|
|
+ apiService.get6NumberInvoiceDetail(invoiceNum)
|
|
|
+ .timeout(60, TimeUnit.SECONDS)
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe({
|
|
|
+ if (it.resultCode == "1") {
|
|
|
+ _state.value = prev().copy(
|
|
|
+ isProgress = false,
|
|
|
+ error = null,
|
|
|
+ betDetailData = it.data
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ _state.value =
|
|
|
+ prev().copy(isProgress = false, error = "[${it.message.description}]")
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ val message: String = "ប្រតិបត្តិការមិនជោគជ័យ\n" + it.getErrorCode()
|
|
|
+ _state.value = prev().copy(isProgress = false, error = message)
|
|
|
+ })
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ fun getCockInvoiceDetail(invoiceNum: String) {
|
|
|
+ if (_state.value!!.isProgress) return
|
|
|
+ _state.value = prev().copy(isProgress = true)
|
|
|
+ disposables.add(
|
|
|
+ apiService.getCockInvoiceDetail(invoiceNum)
|
|
|
.timeout(60, TimeUnit.SECONDS)
|
|
|
.subscribeOn(Schedulers.io())
|
|
|
.observeOn(AndroidSchedulers.mainThread())
|