Skip to content

Instantly share code, notes, and snippets.

@akbarsha03
Created June 1, 2017 18:18
Show Gist options
  • Save akbarsha03/798b4ddf6e80761351e329f1857c30a7 to your computer and use it in GitHub Desktop.
Save akbarsha03/798b4ddf6e80761351e329f1857c30a7 to your computer and use it in GitHub Desktop.
object Api {
val instance: RestAPI = Retrofit.Builder().run {
baseUrl(AppConst.API.BASE_URL)
addCallAdapterFactory(RxJavaCallAdapterFactory.create())
addConverterFactory(JacksonConverterFactory.create(ObjectMapper()))
client(OkHttpClient.Builder()
.apply {
addInterceptor(HttpLoggingInterceptor()
.apply { level = HttpLoggingInterceptor.Level.BODY })
.takeIf { BuildConfig.DEBUG }
}
.build())
build()
}.create(RestAPI::class.java)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment