package es.verdnatura.presentation.view.feature.paletizador.fragment

import android.content.Context
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import es.verdnatura.domain.SalixCallback
import es.verdnatura.presentation.base.BaseViewModel
import es.verdnatura.presentation.common.ResponseItemVO
import retrofit2.Response

class ExpeditionScanSorterViewModel(val context: Context) : BaseViewModel(context) {

    private val _responsescan by lazy { MutableLiveData<ResponseItemVO>() }
    val responsescan: LiveData<ResponseItemVO>
        get() = _responsescan

    fun expeditionScan(vExpeditionId: String) {
        salix.expeditionScan(params = arrayListOf(vExpeditionId))
            .enqueue(object : SalixCallback<Unit>(context) {
                override fun onSuccess(response: Response<Unit>) {

                    _responsescan.value =
                        ResponseItemVO(isError = false, response = response.message()!!)
                    super.onSuccess(response)
                }

            })
    }

}