31 lines
848 B
Kotlin
Raw Normal View History

2023-02-06 13:44:27 -06:00
package com.isolaatti.connectivity
import okhttp3.OkHttpClient
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
2023-07-08 02:17:19 -06:00
import java.io.IOException
2023-02-06 13:44:27 -06:00
import javax.inject.Inject
2023-02-11 23:41:23 -06:00
class RetrofitClient @Inject constructor(private val authenticationInterceptor: AuthenticationInterceptor) {
2023-02-06 13:44:27 -06:00
2023-02-11 23:41:23 -06:00
companion object {
// These urls don't need auth header
val excludedUrlsFromAuthentication = listOf(
"/api/LogIn"
)
const val BASE_URL = "https://isolaatti.com/api/"
2023-02-06 13:44:27 -06:00
}
private val okHttpClient get() = OkHttpClient.Builder()
2023-02-11 23:41:23 -06:00
.addInterceptor(authenticationInterceptor)
2023-02-06 13:44:27 -06:00
.build()
val client: Retrofit get() = Retrofit.Builder()
2023-02-11 23:41:23 -06:00
.baseUrl(BASE_URL)
2023-02-06 13:44:27 -06:00
.client(okHttpClient)
.addConverterFactory(GsonConverterFactory.create())
.build()
}