package de.tsschulz.tt_tagebuch.shared.api

import de.tsschulz.tt_tagebuch.shared.api.http.AuthedHttpClient
import de.tsschulz.tt_tagebuch.shared.api.models.MemberActivityStatDto
import de.tsschulz.tt_tagebuch.shared.api.models.MemberLastParticipationDto
import io.ktor.client.call.body
import io.ktor.client.request.get
import io.ktor.client.request.parameter

class MemberActivitiesApi(
    private val client: AuthedHttpClient,
) {
    suspend fun listActivityStats(clubId: Int, memberId: Int, period: String = "year"): List<MemberActivityStatDto> {
        return client.http.get("/api/member-activities/$clubId/$memberId") {
            parameter("period", period)
        }.body()
    }

    suspend fun listLastParticipations(clubId: Int, memberId: Int, limit: Int = 12): List<MemberLastParticipationDto> {
        return client.http.get("/api/member-activities/$clubId/$memberId/last-participations") {
            parameter("limit", limit)
        }.body()
    }
}
