Last active
February 25, 2021 15:31
-
-
Save yostane/752a457dd127df982a7f1ae2c56207e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
authenticateButton.setOnClickListener { | |
val service = retrofit.create(TerminalService::class.java) | |
val loginCall = service.login(loginEditText.text.toString(), passwordEditText.text.toString()) | |
loginCall.enqueue(object : Callback<ResponseBody>{ | |
override fun onResponse(call: Call<ResponseBody>, response: Response<ResponseBody>) { | |
val token = response.body()?.string() | |
if (token != null){ | |
Log.d("PPE_LOG", "The token is $token") | |
} else { | |
Log.w("PPE_LOG", "Login failed") | |
} | |
} | |
override fun onFailure(call: Call<ResponseBody>, t: Throwable) { | |
Log.e("PPE_LOG", "Login failed") | |
} | |
}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import okhttp3.ResponseBody | |
import retrofit2.Call | |
import retrofit2.http.GET | |
import retrofit2.http.Query | |
interface TerminalService { | |
@GET("login.php") | |
fun login(@Query("login") login: String, @Query("mdp") password: String): Call<ResponseBody> | |
@GET("reservations.php") | |
fun reservations(@Query("token") token: String): Call<List<TerminalReservation>> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment