package moe.lava.neon.api

import io.ktor.client.call.body
import io.ktor.client.statement.HttpResponse
import io.ktor.util.reflect.TypeInfo
import io.ktor.util.reflect.typeInfo

class ApiResponse<T>(
    val response: HttpResponse,
    private val bodyType: TypeInfo,
) {
    suspend fun body() = response.body(bodyType) as T
}

inline fun <reified T> HttpResponse.wrap() = ApiResponse<T>(this, typeInfo<T>())
