package de.tsschulz.tt_tagebuch.shared.api

import de.tsschulz.tt_tagebuch.shared.api.http.AuthedHttpClient
import de.tsschulz.tt_tagebuch.shared.api.models.ClubAccessDecisionBody
import de.tsschulz.tt_tagebuch.shared.api.models.PendingUserClubJoinDto
import io.ktor.client.call.body
import io.ktor.client.request.get
import io.ktor.client.request.post
import io.ktor.client.request.setBody

class ClubApprovalsApi(
    private val client: AuthedHttpClient,
) {
    suspend fun listPending(clubId: Int): List<PendingUserClubJoinDto> {
        return client.http.get("/api/clubs/pending/$clubId").body()
    }

    suspend fun approve(body: ClubAccessDecisionBody) {
        client.http.post("/api/clubs/approve") { setBody(body) }
    }

    suspend fun reject(body: ClubAccessDecisionBody) {
        client.http.post("/api/clubs/reject") { setBody(body) }
    }
}
