Slide 6
Slide 6 text
● Retrofit Interface
An interface that defines HTTP operations
@GET("api/breeds/image/random")
suspend fun getRandomDogImage(): DogImageResponse
● Retrofit class
Creates an instance of retrofit and implements the retrofit interface methods
val apiClient: ApiService= Retrofit.Builder()
.baseUrl("https://dog.ceo")
.client(OkHttpClient())
.addConverterFactory(GsonConverterFactory.create())
.build()
.create(ApiService::class.java)
● Retrofit Converters
Defines format that data will be represented in. GSON is JSON mapping.
Retrofit Classes