To reinforce kotlin patterns, instead of
val astronomyService = Retrofit.Builder()
.client(createHttpClient().build())
.baseUrl("https://api.nasa.gov/planetary/")
.addConverterFactory(MoshiConverterFactory.create())
.build().create<AstronomyService>()
why not the kotlin builder pattern?
val astronomyService = Retrofit.Builder().apply {
client = createHttpClient().build()
baseUrl = "https://api.nasa.gov/planetary/")
converterFactory += MoshiConverterFactory.create()
}
.build().create<AstronomyService>()
// Or, if those don't have setters
val astronomyService = Retrofit.Builder().apply {
client(createHttpClient().build())
baseUrl("https://api.nasa.gov/planetary/")
addConverterFactory(MoshiConverterFactory.create())
}
.build().create<AstronomyService>()