package ru.myitschool.work.ui.qr.result;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import ru.myitschool.work.data.repository.OpenRepositoryImpl;
import ru.myitschool.work.domain.open.OpenUseCase;

public class ResultViewModel extends ViewModel {

    private final MutableLiveData<Boolean> mutableIsCorrectLiveData = new MutableLiveData<>();
    public final LiveData<Boolean> isCorrectLiveData = mutableIsCorrectLiveData;

    private final OpenUseCase openUseCase = new OpenUseCase(OpenRepositoryImpl.getInstance());


    public void startQuery(String currentLogin, Long code) {
        openUseCase.execute(currentLogin, code, status -> {
            if (status.getStatusCode() == 200) {
                mutableIsCorrectLiveData.setValue(true);
            } else /*(status.getStatusCode() == 400 || status.getStatusCode() == 401)*/ {
                mutableIsCorrectLiveData.setValue(false);
            }
        });
    }
}
