From e9116836626b1bf2853380a836c39760e6790986 Mon Sep 17 00:00:00 2001 From: Renaud BEURET Date: Tue, 19 Mar 2024 17:25:15 +0100 Subject: [PATCH] =?UTF-8?q?[ADD]=20Service=20de=20requ=C3=AAtes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 3 ++ .idea/ScienceQuest.iml | 9 ++++++ .idea/compiler.xml | 6 ++++ .idea/deploymentTargetDropDown.xml | 10 ++++++ .idea/gradle.xml | 19 ++++++++++++ .idea/kotlinc.xml | 6 ++++ .idea/migrations.xml | 10 ++++++ .idea/misc.xml | 6 ++++ .idea/vcs.xml | 6 ++++ android/.idea/.name | 1 + android/.idea/deploymentTargetDropDown.xml | 7 +++-- .../iut/sciencequest/model/RequestService.kt | 31 +++++++++++++++++++ 12 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/ScienceQuest.iml create mode 100644 .idea/compiler.xml create mode 100644 .idea/deploymentTargetDropDown.xml create mode 100644 .idea/gradle.xml create mode 100644 .idea/kotlinc.xml create mode 100644 .idea/migrations.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/vcs.xml create mode 100644 android/.idea/.name create mode 100644 android/app/src/main/java/fr/iut/sciencequest/model/RequestService.kt diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/ScienceQuest.iml b/.idea/ScienceQuest.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/ScienceQuest.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..b589d56 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml new file mode 100644 index 0000000..0c0c338 --- /dev/null +++ b/.idea/deploymentTargetDropDown.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..ce56490 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..fdf8d99 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/migrations.xml b/.idea/migrations.xml new file mode 100644 index 0000000..848eaa5 --- /dev/null +++ b/.idea/migrations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..ac801d8 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/android/.idea/.name b/android/.idea/.name new file mode 100644 index 0000000..7c66ae3 --- /dev/null +++ b/android/.idea/.name @@ -0,0 +1 @@ +ScienceQuest \ No newline at end of file diff --git a/android/.idea/deploymentTargetDropDown.xml b/android/.idea/deploymentTargetDropDown.xml index 81d842f..3d7ae4a 100644 --- a/android/.idea/deploymentTargetDropDown.xml +++ b/android/.idea/deploymentTargetDropDown.xml @@ -2,6 +2,9 @@ + + + @@ -10,12 +13,12 @@ - + - + diff --git a/android/app/src/main/java/fr/iut/sciencequest/model/RequestService.kt b/android/app/src/main/java/fr/iut/sciencequest/model/RequestService.kt new file mode 100644 index 0000000..f302816 --- /dev/null +++ b/android/app/src/main/java/fr/iut/sciencequest/model/RequestService.kt @@ -0,0 +1,31 @@ +package fr.iut.sciencequest.model + +import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory +import fr.iut.sciencequest.model.dto.ScientifiqueDTO +import kotlinx.serialization.json.Json +import okhttp3.MediaType +import okhttp3.OkHttpClient +import retrofit2.Call +import retrofit2.Retrofit +import retrofit2.http.GET +import retrofit2.http.Path + +// a remplir +private const val API_BASE_URL = "" + +val httpClient = OkHttpClient() + +interface RequestService { + @GET("scientifiques/{index}/{count}") + fun getScientifiques(@Path("index") index: Int, @Path("count") count: Int): Call> + + @GET("scientifiques/{id}") + fun getScientifique(@Path("id") id: Int) +} + +fun createRequestService(): Retrofit = + Retrofit.Builder() + .baseUrl(API_BASE_URL) + .addConverterFactory(Json { ignoreUnknownKeys = true }.asConverterFactory(MediaType.get("application/json"))) + .client(httpClient) + .build() \ No newline at end of file