Created
May 26, 2020 18:11
-
-
Save Barros9/e97cd73b336b51f0154f222f0795c7d6 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
import retrofit2.Call | |
import retrofit2.Retrofit | |
import retrofit2.converter.scalars.ScalarsConverterFactory | |
import retrofit2.http.GET | |
private const val BASE_URL = "PUT_HERE_URL" | |
private val retrofit = Retrofit.Builder() | |
.addConverterFactory(ScalarsConverterFactory.create()) | |
.baseUrl(BASE_URL) | |
.build() | |
interface ApiService { | |
@GET("PUT_HERE_GET_VALUE") | |
fun get(): | |
Call<String> | |
} | |
object Api { | |
val retrofitService: ApiService by lazy { retrofit.create(ApiService::class.java) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Retrofit Sample
Created a retrofit object pointing to the desired BASE_URL. An interface that expose the get() method, where @get annotation indicates the endpoint will be requested with the GET HTTP method, it returns a retrofit callback with a String.
Usage