|
|
|
@ -9,6 +9,7 @@ import java.util.* |
|
|
|
|
import java.util.concurrent.TimeUnit |
|
|
|
|
import kotlin.coroutines.resume |
|
|
|
|
|
|
|
|
|
@Suppress("unused") |
|
|
|
|
object HttpHelper { |
|
|
|
|
|
|
|
|
|
val client: OkHttpClient by lazy { |
|
|
|
@ -47,6 +48,15 @@ object HttpHelper { |
|
|
|
|
return null |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
suspend fun simpleGetSync(url: String, encode: String? = null): String? { |
|
|
|
|
NetworkUtils.getBaseUrl(url)?.let { baseUrl -> |
|
|
|
|
val response = getApiService<HttpGetApi>(baseUrl, encode) |
|
|
|
|
.getAsync(url, mapOf()) |
|
|
|
|
return response.body() |
|
|
|
|
} |
|
|
|
|
return null |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inline fun <reified T> getApiService(baseUrl: String, encode: String? = null): T { |
|
|
|
|
return getRetrofit(baseUrl, encode).create(T::class.java) |
|
|
|
|
} |
|
|
|
|