Calls API pour les users implémentées

workShana
Louis LABORIE 3 months ago
parent 2818828c3c
commit aa95ce53a2

@ -0,0 +1,29 @@
package com.example.veraxapplication.modele
import com.example.veraxapplication.modele.user.User
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.http.GET
object RetrofitClientUser {
private const val BASE_URL = "https://codefirst.iut.uca.fr/containers/Verax-verax-api"
val retrofit: Retrofit by lazy {
Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build()
}
// interface UserApiService {
// @GET("users")
// suspend fun getUsers() : List<User>
// }
}
object ApiClientUser {
val apiService: UserApiService by lazy {
RetrofitClientUser.retrofit.create(UserApiService::class.java)
}
}

@ -7,4 +7,5 @@ import retrofit2.http.GET
interface ApiService {
@GET("articles/")
fun getArticles(): Call<List<Article>>
}

@ -0,0 +1,9 @@
import com.example.veraxapplication.modele.user.User
interface IUsersDataManager {
val allUsers: List<Any?>?
fun getUser(pseudo : String): User?
fun getUsers(): List<User>
}

@ -0,0 +1,12 @@
package com.example.veraxapplication.modele
import com.example.veraxapplication.modele.articles.Article
import com.example.veraxapplication.modele.user.User
import retrofit2.Call
import retrofit2.http.GET
interface UserApiService {
@GET("users/")
fun getUsers(): Call<List<User>>
}

@ -0,0 +1,3 @@
package com.example.veraxapplication.modele.user
data class User(val pseudo : String, val mdp : String, val mail : String, val nom : String, val prenom : String, val role : Char)
Loading…
Cancel
Save