package com.example.quiz.viewModel;

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

import com.example.quiz.data.model.Pari;
import com.example.quiz.data.model.ParisResponse;
import com.example.quiz.data.model.dtos.paris.SoldeResponse;
import com.example.quiz.data.repository.PariRepository;
import com.example.quiz.utils.Result;

import java.util.List;

import javax.inject.Inject;

import dagger.hilt.android.lifecycle.HiltViewModel;

@HiltViewModel
public class PariViewModel extends ViewModel {
    private final PariRepository pariRepository;
    private LiveData<Result<ParisResponse>> pari;

    private LiveData<Result<List<ParisResponse>>> derniersParis;

    private LiveData<Result<ParisResponse>> pariAnnule;

    private LiveData<Result<ParisResponse>> pariPaye;


    private LiveData<Result<ParisResponse>> pariByNumero;

    private LiveData<Result<SoldeResponse>> solde;

    private LiveData<Result<SoldeResponse>> soldeByDay;

    private LiveData<Result<ParisResponse>> pariRembourse;

    @Inject
    public PariViewModel(PariRepository repository){
        this.pariRepository = repository;
    }

    public LiveData<Result<ParisResponse>> createPari(Pari pari){
        this.pari = pariRepository.createPari(pari);
        return this.pari;
    }

    public LiveData<Result<List<ParisResponse>>> getDerniersParis(String agentId){
        derniersParis = pariRepository.derniersParis(agentId);
        return pariRepository.derniersParis(agentId);
    }

    public LiveData<Result<ParisResponse>> annulerPari(String numeroTicket, String agentId){
        pariAnnule = pariRepository.annulerPari(numeroTicket, agentId);
        return pariAnnule;
    }

    public LiveData<Result<SoldeResponse>> getSoldeByCourse(String agentId, String courseId){
        solde = pariRepository.getSoldeByCourse(agentId, courseId);
        return solde;
    }

    public LiveData<Result<SoldeResponse>> getSoldeByDay(String agentId, String day){
        soldeByDay = pariRepository.getSoldeByDay(agentId, day);
        return soldeByDay;
    }

    public LiveData<Result<ParisResponse>> getPariByNumero(String numeroTicket){
        pariByNumero = pariRepository.getPariByNumero(numeroTicket);
        return pariByNumero;
    }

    public LiveData<Result<ParisResponse>> payerPari(String numeroTicket){
        pariPaye = pariRepository.payTicket(numeroTicket);
        return pariPaye;
    }

    public LiveData<Result<ParisResponse>> rembourserPari(String numeroTicket){
        pariRembourse = pariRepository.rembourserTicket(numeroTicket);
        return pariRembourse;
    }
}
