create pari
This commit is contained in:
266
app/src/main/java/com/example/quiz/data/model/Pari.java
Normal file
266
app/src/main/java/com/example/quiz/data/model/Pari.java
Normal file
@@ -0,0 +1,266 @@
|
||||
package com.example.quiz.data.model;
|
||||
|
||||
import com.example.quiz.data.model.enums.CourseType;
|
||||
import com.example.quiz.data.model.enums.PariStatut;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
public class Pari {
|
||||
private String numeroTicket;
|
||||
private String typePari;
|
||||
private String typeFormule;
|
||||
private int mise;
|
||||
private String datePari;
|
||||
private int courseId;
|
||||
private String idParieur;
|
||||
private String nomParieur;
|
||||
private int cheval;
|
||||
private int cheval1;
|
||||
private int cheval2;
|
||||
private int cheval3;
|
||||
private int premier;
|
||||
private int deuxieme;
|
||||
private int troisieme;
|
||||
private List<Integer> chevauxOrdre;
|
||||
private List<Integer> chevauxSelectionnes;
|
||||
private List<Integer> ordrePredit;
|
||||
private boolean validationOrdreExact;
|
||||
private String typeMulti;
|
||||
private PariStatut status;
|
||||
private boolean estPaye;
|
||||
private boolean estRembourse;
|
||||
|
||||
public Pari(
|
||||
String numeroTicket,
|
||||
String typePari,
|
||||
String typeFormule,
|
||||
int mise,
|
||||
String datePari,
|
||||
int courseId,
|
||||
String idParieur,
|
||||
String nomParieur,
|
||||
int cheval,
|
||||
int cheval1,
|
||||
int cheval2,
|
||||
int cheval3,
|
||||
int premier,
|
||||
int deuxieme,
|
||||
int troisieme,
|
||||
List<Integer> chevauxOrdre,
|
||||
List<Integer> chevauxSelectionnes,
|
||||
List<Integer> ordrePredit,
|
||||
boolean validationOrdreExact,
|
||||
String typeMulti,
|
||||
PariStatut status,
|
||||
boolean estPaye,
|
||||
boolean estRembourse) {
|
||||
this.numeroTicket = numeroTicket;
|
||||
this.typePari = typePari;
|
||||
this.typeFormule = typeFormule;
|
||||
this.mise = mise;
|
||||
this.datePari = datePari;
|
||||
this.courseId = courseId;
|
||||
this.idParieur = idParieur;
|
||||
this.nomParieur = nomParieur;
|
||||
this.cheval = cheval;
|
||||
this.cheval1 = cheval1;
|
||||
this.cheval2 = cheval2;
|
||||
this.cheval3 = cheval3;
|
||||
this.premier = premier;
|
||||
this.deuxieme = deuxieme;
|
||||
this.troisieme = troisieme;
|
||||
this.chevauxOrdre = chevauxOrdre;
|
||||
this.chevauxSelectionnes = chevauxSelectionnes;
|
||||
this.ordrePredit = ordrePredit;
|
||||
this.validationOrdreExact = validationOrdreExact;
|
||||
this.typeMulti = typeMulti;
|
||||
this.status = status;
|
||||
this.estPaye = estPaye;
|
||||
this.estRembourse = estRembourse;
|
||||
}
|
||||
|
||||
public String getNumeroTicket() {
|
||||
return numeroTicket;
|
||||
}
|
||||
|
||||
public void setNumeroTicket(String numeroTicket) {
|
||||
this.numeroTicket = numeroTicket;
|
||||
}
|
||||
|
||||
public String getTypePari() {
|
||||
return typePari;
|
||||
}
|
||||
|
||||
public void setTypePari(String typePari) {
|
||||
this.typePari = typePari;
|
||||
}
|
||||
|
||||
public String getTypeFormule() {
|
||||
return typeFormule;
|
||||
}
|
||||
|
||||
public void setTypeFormule(String typeFormule) {
|
||||
this.typeFormule = typeFormule;
|
||||
}
|
||||
|
||||
public int getMise() {
|
||||
return mise;
|
||||
}
|
||||
|
||||
public void setMise(int mise) {
|
||||
this.mise = mise;
|
||||
}
|
||||
|
||||
public String getDatePari() {
|
||||
return datePari;
|
||||
}
|
||||
|
||||
public void setDatePari(String datePari) {
|
||||
this.datePari = datePari;
|
||||
}
|
||||
|
||||
public int getCourseId() {
|
||||
return courseId;
|
||||
}
|
||||
|
||||
public void setCourseId(int courseId) {
|
||||
this.courseId = courseId;
|
||||
}
|
||||
|
||||
public String getIdParieur() {
|
||||
return idParieur;
|
||||
}
|
||||
|
||||
public void setIdParieur(String idParieur) {
|
||||
this.idParieur = idParieur;
|
||||
}
|
||||
|
||||
public String getNomParieur() {
|
||||
return nomParieur;
|
||||
}
|
||||
|
||||
public void setNomParieur(String nomParieur) {
|
||||
this.nomParieur = nomParieur;
|
||||
}
|
||||
|
||||
public int getCheval() {
|
||||
return cheval;
|
||||
}
|
||||
|
||||
public void setCheval(int cheval) {
|
||||
this.cheval = cheval;
|
||||
}
|
||||
|
||||
public int getCheval1() {
|
||||
return cheval1;
|
||||
}
|
||||
|
||||
public void setCheval1(int cheval1) {
|
||||
this.cheval1 = cheval1;
|
||||
}
|
||||
|
||||
public int getCheval2() {
|
||||
return cheval2;
|
||||
}
|
||||
|
||||
public void setCheval2(int cheval2) {
|
||||
this.cheval2 = cheval2;
|
||||
}
|
||||
|
||||
public int getCheval3() {
|
||||
return cheval3;
|
||||
}
|
||||
|
||||
public void setCheval3(int cheval3) {
|
||||
this.cheval3 = cheval3;
|
||||
}
|
||||
|
||||
public int getPremier() {
|
||||
return premier;
|
||||
}
|
||||
|
||||
public void setPremier(int premier) {
|
||||
this.premier = premier;
|
||||
}
|
||||
|
||||
public int getDeuxieme() {
|
||||
return deuxieme;
|
||||
}
|
||||
|
||||
public void setDeuxieme(int deuxieme) {
|
||||
this.deuxieme = deuxieme;
|
||||
}
|
||||
|
||||
public int getTroisieme() {
|
||||
return troisieme;
|
||||
}
|
||||
|
||||
public void setTroisieme(int troisieme) {
|
||||
this.troisieme = troisieme;
|
||||
}
|
||||
|
||||
public List<Integer> getChevauxOrdre() {
|
||||
return chevauxOrdre;
|
||||
}
|
||||
|
||||
public void setChevauxOrdre(List<Integer> chevauxOrdre) {
|
||||
this.chevauxOrdre = chevauxOrdre;
|
||||
}
|
||||
|
||||
public List<Integer> getChevauxSelectionnes() {
|
||||
return chevauxSelectionnes;
|
||||
}
|
||||
|
||||
public void setChevauxSelectionnes(List<Integer> chevauxSelectionnes) {
|
||||
this.chevauxSelectionnes = chevauxSelectionnes;
|
||||
}
|
||||
|
||||
public List<Integer> getOrdrePredit() {
|
||||
return ordrePredit;
|
||||
}
|
||||
|
||||
public void setOrdrePredit(List<Integer> ordrePredit) {
|
||||
this.ordrePredit = ordrePredit;
|
||||
}
|
||||
|
||||
public boolean isValidationOrdreExact() {
|
||||
return validationOrdreExact;
|
||||
}
|
||||
|
||||
public void setValidationOrdreExact(boolean validationOrdreExact) {
|
||||
this.validationOrdreExact = validationOrdreExact;
|
||||
}
|
||||
|
||||
public String getTypeMulti() {
|
||||
return typeMulti;
|
||||
}
|
||||
|
||||
public void setTypeMulti(String typeMulti) {
|
||||
this.typeMulti = typeMulti;
|
||||
}
|
||||
|
||||
public PariStatut getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(PariStatut status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public boolean isEstPaye() {
|
||||
return estPaye;
|
||||
}
|
||||
|
||||
public void setEstPaye(boolean estPaye) {
|
||||
this.estPaye = estPaye;
|
||||
}
|
||||
|
||||
public boolean isEstRembourse() {
|
||||
return estRembourse;
|
||||
}
|
||||
|
||||
public void setEstRembourse(boolean estRembourse) {
|
||||
this.estRembourse = estRembourse;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.example.quiz.data.model.enums;
|
||||
|
||||
public enum PariStatut {
|
||||
EN_ATTENTE,
|
||||
PERDANT,
|
||||
VALIDEE
|
||||
}
|
||||
@@ -1,12 +1,15 @@
|
||||
package com.example.quiz.data.remote;
|
||||
|
||||
import com.example.quiz.data.model.Course;
|
||||
import com.example.quiz.data.model.Pari;
|
||||
import com.example.quiz.data.model.Reunion;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.http.Body;
|
||||
import retrofit2.http.GET;
|
||||
import retrofit2.http.POST;
|
||||
|
||||
public interface ApiService {
|
||||
@GET("reunions")
|
||||
@@ -14,4 +17,7 @@ public interface ApiService {
|
||||
|
||||
@GET("course/avenir")
|
||||
Call<List<Course>> getCourses();
|
||||
|
||||
@POST("/pari")
|
||||
Call<Pari> createPari(@Body Pari pari);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.example.quiz.data.repository;
|
||||
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.example.quiz.data.model.Pari;
|
||||
import com.example.quiz.data.remote.ApiService;
|
||||
import com.example.quiz.utils.Result;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class PariRepository {
|
||||
private ApiService apiService;
|
||||
|
||||
@Inject
|
||||
public PariRepository(ApiService apiService) {
|
||||
this.apiService = apiService;
|
||||
}
|
||||
|
||||
public LiveData<Result<Pari>> createPari(Pari pari) {
|
||||
MutableLiveData<Result<Pari>> pariResponse = new MutableLiveData<Result<Pari>>();
|
||||
pariResponse.setValue(Result.loading());
|
||||
apiService.createPari(pari).enqueue(new Callback<Pari>() {
|
||||
@Override
|
||||
public void onResponse(Call<Pari> call, Response<Pari> response) {
|
||||
if(response.isSuccessful()){
|
||||
pariResponse.postValue(Result.success(response.body()));
|
||||
}else {
|
||||
pariResponse.postValue(Result.error(response.message()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<Pari> call, Throwable throwable) {
|
||||
pariResponse.postValue(Result.error(throwable.getMessage()));
|
||||
}
|
||||
});
|
||||
return pariResponse;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user