package com.posibolt.retrofitdemo import com.google.gson.GsonBuilder import okhttp3.OkHttpClient import okhttp3.logging.HttpLoggingInterceptor import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory import java.util.concurrent.TimeUnit class RetrofitInstance { companion object{ //show Network information in to the logcat val intercepter = HttpLoggingInterceptor().apply { this.level = HttpLoggingInterceptor.Level.BODY } val client = OkHttpClient.Builder().apply { this.addInterceptor(intercepter) // time out setting .connectTimeout(3,TimeUnit.SECONDS) .readTimeout(20,TimeUnit.SECONDS) .writeTimeout(25,TimeUnit.SECONDS) }.build() val BASE_URL = "https://jsonplaceholder.typicode.com" fun getRetrofitInstance():Retrofit{ return Retrofit.Builder().baseUrl(BASE_URL) // .client(client) .addConverterFactory(GsonConverterFactory.create(GsonBuilder().create())).build() } } }