in progress!
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package com.example.quiz.data.model.dtos.auth;
|
||||
|
||||
public class LoginPayload {
|
||||
private String pin;
|
||||
|
||||
public LoginPayload(String pin) {
|
||||
this.pin = pin;
|
||||
}
|
||||
|
||||
public String getPin() {
|
||||
return pin;
|
||||
}
|
||||
|
||||
public void setPin(String pin) {
|
||||
this.pin = pin;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
package com.example.quiz.data.model.dtos.auth;
|
||||
|
||||
public class LoginResponse {
|
||||
private int id;
|
||||
private String code;
|
||||
private String profile;
|
||||
private String principalCode;
|
||||
private String caisseProfile;
|
||||
private String statut;
|
||||
private String zone;
|
||||
private String kiosk;
|
||||
private String fonction;
|
||||
private String dateEmbauche;
|
||||
private String derniereConnexion;
|
||||
private String nom;
|
||||
private String prenom;
|
||||
private String autresNom;
|
||||
private String dateNaissance;
|
||||
private String lieuNaissance;
|
||||
private String ville;
|
||||
private String adresse;
|
||||
private String cni;
|
||||
private double limiteInferieure;
|
||||
private double limiteSuperieure;
|
||||
private double limiteParTransaction;
|
||||
private String autreAdresse1;
|
||||
|
||||
public LoginResponse(int id, String code, String profile, String principalCode, String caisseProfile, String statut, String zone, String kiosk, String fonction, String dateEmbauche, String derniereConnexion, String nom, String prenom, String autresNom, String dateNaissance, String lieuNaissance, String ville, String adresse, String cni, double limiteInferieure, double limiteSuperieure, double limiteParTransaction, String autreAdresse1) {
|
||||
this.id = id;
|
||||
this.code = code;
|
||||
this.profile = profile;
|
||||
this.principalCode = principalCode;
|
||||
this.caisseProfile = caisseProfile;
|
||||
this.statut = statut;
|
||||
this.zone = zone;
|
||||
this.kiosk = kiosk;
|
||||
this.fonction = fonction;
|
||||
this.dateEmbauche = dateEmbauche;
|
||||
this.derniereConnexion = derniereConnexion;
|
||||
this.nom = nom;
|
||||
this.prenom = prenom;
|
||||
this.autresNom = autresNom;
|
||||
this.dateNaissance = dateNaissance;
|
||||
this.lieuNaissance = lieuNaissance;
|
||||
this.ville = ville;
|
||||
this.adresse = adresse;
|
||||
this.cni = cni;
|
||||
this.limiteInferieure = limiteInferieure;
|
||||
this.limiteSuperieure = limiteSuperieure;
|
||||
this.limiteParTransaction = limiteParTransaction;
|
||||
this.autreAdresse1 = autreAdresse1;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getProfile() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
public void setProfile(String profile) {
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
public String getPrincipalCode() {
|
||||
return principalCode;
|
||||
}
|
||||
|
||||
public void setPrincipalCode(String principalCode) {
|
||||
this.principalCode = principalCode;
|
||||
}
|
||||
|
||||
public String getCaisseProfile() {
|
||||
return caisseProfile;
|
||||
}
|
||||
|
||||
public void setCaisseProfile(String caisseProfile) {
|
||||
this.caisseProfile = caisseProfile;
|
||||
}
|
||||
|
||||
public String getStatut() {
|
||||
return statut;
|
||||
}
|
||||
|
||||
public void setStatut(String statut) {
|
||||
this.statut = statut;
|
||||
}
|
||||
|
||||
public String getZone() {
|
||||
return zone;
|
||||
}
|
||||
|
||||
public void setZone(String zone) {
|
||||
this.zone = zone;
|
||||
}
|
||||
|
||||
public String getKiosk() {
|
||||
return kiosk;
|
||||
}
|
||||
|
||||
public void setKiosk(String kiosk) {
|
||||
this.kiosk = kiosk;
|
||||
}
|
||||
|
||||
public String getFonction() {
|
||||
return fonction;
|
||||
}
|
||||
|
||||
public void setFonction(String fonction) {
|
||||
this.fonction = fonction;
|
||||
}
|
||||
|
||||
public String getDateEmbauche() {
|
||||
return dateEmbauche;
|
||||
}
|
||||
|
||||
public void setDateEmbauche(String dateEmbauche) {
|
||||
this.dateEmbauche = dateEmbauche;
|
||||
}
|
||||
|
||||
public String getDerniereConnexion() {
|
||||
return derniereConnexion;
|
||||
}
|
||||
|
||||
public void setDerniereConnexion(String derniereConnexion) {
|
||||
this.derniereConnexion = derniereConnexion;
|
||||
}
|
||||
|
||||
public String getNom() {
|
||||
return nom;
|
||||
}
|
||||
|
||||
public void setNom(String nom) {
|
||||
this.nom = nom;
|
||||
}
|
||||
|
||||
public String getPrenom() {
|
||||
return prenom;
|
||||
}
|
||||
|
||||
public void setPrenom(String prenom) {
|
||||
this.prenom = prenom;
|
||||
}
|
||||
|
||||
public String getAutresNom() {
|
||||
return autresNom;
|
||||
}
|
||||
|
||||
public void setAutresNom(String autresNom) {
|
||||
this.autresNom = autresNom;
|
||||
}
|
||||
|
||||
public String getDateNaissance() {
|
||||
return dateNaissance;
|
||||
}
|
||||
|
||||
public void setDateNaissance(String dateNaissance) {
|
||||
this.dateNaissance = dateNaissance;
|
||||
}
|
||||
|
||||
public String getLieuNaissance() {
|
||||
return lieuNaissance;
|
||||
}
|
||||
|
||||
public void setLieuNaissance(String lieuNaissance) {
|
||||
this.lieuNaissance = lieuNaissance;
|
||||
}
|
||||
|
||||
public String getVille() {
|
||||
return ville;
|
||||
}
|
||||
|
||||
public void setVille(String ville) {
|
||||
this.ville = ville;
|
||||
}
|
||||
|
||||
public String getAdresse() {
|
||||
return adresse;
|
||||
}
|
||||
|
||||
public void setAdresse(String adresse) {
|
||||
this.adresse = adresse;
|
||||
}
|
||||
|
||||
public String getCni() {
|
||||
return cni;
|
||||
}
|
||||
|
||||
public void setCni(String cni) {
|
||||
this.cni = cni;
|
||||
}
|
||||
|
||||
public double getLimiteInferieure() {
|
||||
return limiteInferieure;
|
||||
}
|
||||
|
||||
public void setLimiteInferieure(double limiteInferieure) {
|
||||
this.limiteInferieure = limiteInferieure;
|
||||
}
|
||||
|
||||
public double getLimiteSuperieure() {
|
||||
return limiteSuperieure;
|
||||
}
|
||||
|
||||
public void setLimiteSuperieure(double limiteSuperieure) {
|
||||
this.limiteSuperieure = limiteSuperieure;
|
||||
}
|
||||
|
||||
public double getLimiteParTransaction() {
|
||||
return limiteParTransaction;
|
||||
}
|
||||
|
||||
public void setLimiteParTransaction(double limiteParTransaction) {
|
||||
this.limiteParTransaction = limiteParTransaction;
|
||||
}
|
||||
|
||||
public String getAutreAdresse1() {
|
||||
return autreAdresse1;
|
||||
}
|
||||
|
||||
public void setAutreAdresse1(String autreAdresse1) {
|
||||
this.autreAdresse1 = autreAdresse1;
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ import retrofit2.converter.gson.GsonConverterFactory;
|
||||
@Module
|
||||
@InstallIn(SingletonComponent.class)
|
||||
public class ApiClient {
|
||||
private static final String BASE_URL = "https://performances-leeds-operations-continued.trycloudflare.com/api/v1/";
|
||||
private static final String BASE_URL = "https://970b6b1c025c.ngrok-free.app/api/v1/";
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
|
||||
@@ -3,6 +3,8 @@ 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 com.example.quiz.data.model.dtos.auth.LoginPayload;
|
||||
import com.example.quiz.data.model.dtos.auth.LoginResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -21,4 +23,7 @@ public interface ApiService {
|
||||
|
||||
@POST("pari")
|
||||
Call<Pari> createPari(@Body Pari pari);
|
||||
|
||||
@POST("auth/agent/login")
|
||||
Call<LoginResponse> login(@Body LoginPayload loginPayload);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.example.quiz.data.repository;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.example.quiz.data.model.dtos.auth.LoginPayload;
|
||||
import com.example.quiz.data.model.dtos.auth.LoginResponse;
|
||||
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 LoginRepository {
|
||||
private ApiService apiService;
|
||||
@Inject
|
||||
public LoginRepository(ApiService apiService) {
|
||||
this.apiService = apiService;
|
||||
}
|
||||
|
||||
public LiveData<Result<LoginResponse>> login(LoginPayload loginPayload){
|
||||
MutableLiveData<Result<LoginResponse>> liveLogin = new MutableLiveData<Result<LoginResponse>>();
|
||||
liveLogin.setValue(Result.loading());
|
||||
apiService.login(loginPayload).enqueue(new Callback<LoginResponse>() {
|
||||
@Override
|
||||
public void onResponse(Call<LoginResponse> call, Response<LoginResponse> response) {
|
||||
if(response.isSuccessful()){
|
||||
liveLogin.postValue(Result.success(response.body()));
|
||||
}else{
|
||||
liveLogin.postValue(Result.error(response.message()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<LoginResponse> call, Throwable throwable) {
|
||||
liveLogin.postValue(Result.error(throwable.getMessage()));
|
||||
}
|
||||
});
|
||||
return liveLogin;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user