package dev.inmo.postssystem.features.status.client

import dev.inmo.postssystem.features.status.common.statusAuthorisedPathPart
import dev.inmo.postssystem.features.status.common.statusRootPart
import dev.inmo.micro_utils.ktor.client.UnifiedRequester
import dev.inmo.micro_utils.ktor.common.buildStandardUrl
import io.ktor.client.HttpClient
import io.ktor.client.request.get
import io.ktor.client.statement.HttpResponse
import io.ktor.http.HttpStatusCode

class StatusFeatureClient(
    baseUrl: String,
    private val client: HttpClient
) {
    private val fullStatusUrl = buildStandardUrl(
        baseUrl,
        statusRootPart
    )
    private val fullAuthorisedStatusUrl = buildStandardUrl(
        fullStatusUrl,
        statusAuthorisedPathPart
    )

    suspend fun checkServerStatus() = client.get<HttpResponse>(fullStatusUrl).status == HttpStatusCode.OK
    suspend fun checkServerStatusWithAuth() = client.get<HttpResponse>(fullAuthorisedStatusUrl).status == HttpStatusCode.OK
}
