parent
051ddf7978
commit
c9647fa011
@ -0,0 +1,8 @@
|
|||||||
|
package sae.android.sae_2a.data
|
||||||
|
|
||||||
|
data class Group(
|
||||||
|
val id : Long,
|
||||||
|
val num : Int,
|
||||||
|
val year : Int,
|
||||||
|
val sector : String
|
||||||
|
)
|
@ -1,7 +1,8 @@
|
|||||||
package sae.android.sae_2a.data
|
package sae.android.sae_2a.data
|
||||||
|
|
||||||
data class Vocabulary(
|
data class Vocabulary(
|
||||||
val name: String,
|
val word : String,
|
||||||
val aut: String?,
|
val LangueName: String,
|
||||||
|
|
||||||
val words: Map<String, String>
|
val words: Map<String, String>
|
||||||
)
|
)
|
@ -0,0 +1,27 @@
|
|||||||
|
package sae.android.sae_2a.service
|
||||||
|
|
||||||
|
import com.google.gson.Gson
|
||||||
|
import com.google.gson.GsonBuilder
|
||||||
|
import okhttp3.OkHttpClient
|
||||||
|
import retrofit2.Retrofit
|
||||||
|
import retrofit2.converter.gson.GsonConverterFactory
|
||||||
|
|
||||||
|
object ApiClient {
|
||||||
|
private val BASE_URL: String = "https://codefirst.iut.uca.fr/containers/antoinejourdain-api_container/api/v1/"
|
||||||
|
|
||||||
|
private val httpClient : OkHttpClient by lazy {
|
||||||
|
OkHttpClient.Builder().build()
|
||||||
|
}
|
||||||
|
|
||||||
|
private val gson : Gson by lazy {
|
||||||
|
GsonBuilder().setLenient().create()
|
||||||
|
}
|
||||||
|
|
||||||
|
private val retrofit : Retrofit by lazy {
|
||||||
|
Retrofit.Builder()
|
||||||
|
.baseUrl(BASE_URL)
|
||||||
|
.client(httpClient)
|
||||||
|
.addConverterFactory(GsonConverterFactory.create(gson))
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package sae.android.sae_2a.service
|
||||||
|
|
||||||
|
import retrofit2.Response
|
||||||
|
import retrofit2.http.Body
|
||||||
|
import retrofit2.http.GET
|
||||||
|
import retrofit2.http.Path
|
||||||
|
import sae.android.sae_2a.data.Group
|
||||||
|
import sae.android.sae_2a.data.Vocabulary
|
||||||
|
|
||||||
|
interface GroupService {
|
||||||
|
|
||||||
|
@GET("Group")
|
||||||
|
suspend fun getVocabulary(@Body index : Int, @Body count : Int) : Response<MutableList<Group>>
|
||||||
|
|
||||||
|
@GET("Group/{id}")
|
||||||
|
suspend fun getVocById(@Path("id") id : Int) : Response<Group>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package sae.android.sae_2a.service
|
||||||
|
|
||||||
|
import retrofit2.Response
|
||||||
|
import retrofit2.http.Body
|
||||||
|
import retrofit2.http.DELETE
|
||||||
|
import retrofit2.http.GET
|
||||||
|
import retrofit2.http.POST
|
||||||
|
import retrofit2.http.PUT
|
||||||
|
import retrofit2.http.Path
|
||||||
|
import retrofit2.http.Query
|
||||||
|
import sae.android.sae_2a.data.Vocabulary
|
||||||
|
|
||||||
|
|
||||||
|
interface UserService {
|
||||||
|
|
||||||
|
@GET("Vocabulary")
|
||||||
|
suspend fun getVocabulary(@Body index : Int, @Body count: Int) : Response<MutableList<Vocabulary>>
|
||||||
|
|
||||||
|
@GET("Vocabulary/{word}")
|
||||||
|
suspend fun getVocByWord(@Path("word") word : String) : Response<Vocabulary>
|
||||||
|
|
||||||
|
@PUT("Vocabulary/{vocabulary}")
|
||||||
|
suspend fun updateVoc(@Path("vocabulary") vocabulary: Vocabulary) : Response<Vocabulary>
|
||||||
|
|
||||||
|
@DELETE("Vocabulary/{word}")
|
||||||
|
suspend fun deleteVoc(@Path("word") word: String) : Response<Vocabulary>
|
||||||
|
|
||||||
|
@POST("Vocabulary/{vocabulary}")
|
||||||
|
suspend fun addVoc(@Path("vocabulary") vocabulary: Vocabulary) : Response<Vocabulary>
|
||||||
|
|
||||||
|
@GET("Vocabulary/langue/{langue}")
|
||||||
|
suspend fun getByLangue(@Path("langue") langue : String,@Body index : Int, @Body count : Int) : Response<Vocabulary>
|
||||||
|
|
||||||
|
@POST("Vocabulary/AddTranslation")
|
||||||
|
suspend fun addTranslation(@Query("vocId") vocId : String,@Query("translationId") translationId : Long ) : Response<Vocabulary>
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue