JoakimForslund
02/05/2019, 9:35 AMinternal suspend inline fun <reified T> makeRequest(): T? {
val httpClient = HttpClient(mBlockHttpClientConfig)
var result: T? = null
try {
result = httpClient.request<T> {
method = mHttpMethod
url {
takeFrom(restieUrl)
encodedPath = mPath
}
mContentType?.let {
accept(it)
}
mParameters.takeIf { it.size > 0 } ?: let {
mParameters.forEach { param ->
parameter(param.first, param.second)
}
}
body = mBody
}
SdkLogger(LOGGER_TYPE.DANGEROUS, "WTF: $result")
} catch (e: Exception) {
SdkLogger(LOGGER_TYPE.ERROR, "BOOOM: ${e.message}")
} finally {
return result
}
}
This is currently not able to cast the specified generic even though mBlockHttpClientConfig contains:
install(JsonFeature) {
serializer = KotlinxSerializer().apply {
setMapper(GameAvailable::class, GameAvailable.serializer())
setMapper(GameOptions::class, GameOptions.serializer())
setMapper(ReportMatch::class, ReportMatch.serializer())
}
}