package com.mytatvarnsdk.utils

import androidx.annotation.Keep
import okhttp3.OkHttpClient
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import java.util.concurrent.TimeUnit

@Keep
class RetrofitInstance {

  companion object {
    val BASE_URL = "https://www.google.com"

    // Shared OkHttpClient with 30s timeouts for all CGM APIs
    private val httpClient: OkHttpClient by lazy {
      OkHttpClient.Builder()
        .connectTimeout(30, TimeUnit.SECONDS)
        .readTimeout(30, TimeUnit.SECONDS)
        .writeTimeout(30, TimeUnit.SECONDS)
        .build()
    }

    fun getRetroInstance(): Retrofit {
      return Retrofit.Builder()
        .baseUrl(BASE_URL)
        .client(httpClient)
        .addConverterFactory(GsonConverterFactory.create())
        .build()
    }
  }
}
