From 00a2266a4da928ebe81cee7d128de0bcf3ff200e Mon Sep 17 00:00:00 2001 From: Sergio De la torre Date: Fri, 19 Apr 2024 10:51:54 +0200 Subject: [PATCH] =?UTF-8?q?refs=20#3520=20feat:silex=E2=86=92salix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/es/verdnatura/domain/ApiUtils.kt | 46 ------------------- 1 file changed, 46 deletions(-) delete mode 100644 app/src/main/java/es/verdnatura/domain/ApiUtils.kt diff --git a/app/src/main/java/es/verdnatura/domain/ApiUtils.kt b/app/src/main/java/es/verdnatura/domain/ApiUtils.kt deleted file mode 100644 index ff8300e0..00000000 --- a/app/src/main/java/es/verdnatura/domain/ApiUtils.kt +++ /dev/null @@ -1,46 +0,0 @@ -package es.verdnatura.domain - -import android.content.Context -import es.verdnatura.MobileApplication -import es.verdnatura.domain.ConstAndValues.BASEURL -import es.verdnatura.domain.ConstAndValues.BASE_URL -import es.verdnatura.presentation.common.InteceptorListener -import kotlinx.coroutines.runBlocking -import okhttp3.OkHttpClient -import retrofit2.Retrofit -import retrofit2.converter.gson.GsonConverterFactory -import java.util.concurrent.TimeUnit - -class ApiUtils { - companion object { - - fun getApiService(context: Context, myObserver: InteceptorListener?): VerdnaturaService { - var client = OkHttpClient.Builder().addInterceptor(SilexInterceptor(context,myObserver)) - .connectTimeout(10, TimeUnit.SECONDS).writeTimeout(10, TimeUnit.SECONDS) - .readTimeout(40, TimeUnit.SECONDS).build() - - val retrofit = Retrofit.Builder().baseUrl(getBaseUrlLocal(context)) - .addConverterFactory(GsonConverterFactory.create()).client(client).build() - - return retrofit.create(VerdnaturaService::class.java) - } - - private fun getBaseUrlLocal(context: Context): String { - var url = (context as MobileApplication).dataStoreApp.readDataStoreKey(BASEURL) - if (url.isNullOrEmpty()) { - runBlocking { - (context).dataStoreApp.editDataStoreKey( - BASEURL, BASE_URL - ) - } - } else { - if (!url.contains("http")) { - url = "https://" + url - } - } - return if (url.isNullOrEmpty()) BASE_URL else url - } - - } - -} \ No newline at end of file