Created
January 24, 2020 12:46
-
-
Save iambaljeet/15de8f2b13715a427012ffea0ea69631 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
object ApiProvider { | |
private val retrofit = Retrofit.Builder() | |
.baseUrl(ApiService.BASE_URL) | |
.client(getHttpClient()) | |
.addConverterFactory(GsonConverterFactory.create()) | |
.build() | |
private fun getHttpClient(): OkHttpClient { | |
val logging = HttpLoggingInterceptor() | |
logging.level = HttpLoggingInterceptor.Level.BODY | |
val httpClient = OkHttpClient.Builder() | |
httpClient.addInterceptor(logging) | |
return httpClient.build() | |
} | |
fun <S> createService(serviceClass: Class<S>?): S { | |
return retrofit.create(serviceClass) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment