com.stytch.java.consumer.api.project.Project.kt Maven / Gradle / Ivy
package com.stytch.java.consumer.api.project
// !!!
// WARNING: This file is autogenerated
// Only modify code within MANUAL() sections
// or your changes may be overwritten later!
// !!!
import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.Moshi
import com.squareup.moshi.Types
import com.stytch.java.common.InstantAdapter
import com.stytch.java.common.StytchResult
import com.stytch.java.consumer.models.project.MetricsRequest
import com.stytch.java.consumer.models.project.MetricsResponse
import com.stytch.java.http.HttpClient
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.future.asCompletableFuture
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.util.concurrent.CompletableFuture
public interface Project {
public suspend fun metrics(data: MetricsRequest): StytchResult
public fun metrics(
data: MetricsRequest,
callback: (StytchResult) -> Unit,
)
public fun metricsCompletable(data: MetricsRequest): CompletableFuture>
}
internal class ProjectImpl(
private val httpClient: HttpClient,
private val coroutineScope: CoroutineScope,
) : Project {
private val moshi = Moshi.Builder().add(InstantAdapter()).build()
override suspend fun metrics(data: MetricsRequest): StytchResult =
withContext(Dispatchers.IO) {
var headers = emptyMap()
val asJson = moshi.adapter(MetricsRequest::class.java).toJson(data)
val type = Types.newParameterizedType(Map::class.java, String::class.java, Any::class.java)
val adapter: JsonAdapter