package com.fabledsword.minstrel.api.endpoints

import com.fabledsword.minstrel.models.wire.AdminInvitesListWire
import com.fabledsword.minstrel.models.wire.InviteWire
import kotlinx.serialization.Serializable
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path

/**
 * Retrofit interface for `/api/admin/invites`. Mirrors
 * `flutter_client/lib/api/endpoints/admin_invites.dart`.
 *
 * Server TTL is hardcoded at 24h; the only configurable field is the
 * optional `note` on create.
 */
interface AdminInvitesApi {
    @GET("api/admin/invites")
    suspend fun list(): AdminInvitesListWire

    @POST("api/admin/invites")
    suspend fun create(@Body body: CreateInviteBody): InviteWire

    @DELETE("api/admin/invites/{token}")
    suspend fun revoke(@Path("token") token: String)
}

/**
 * Body for `POST /api/admin/invites`. The Flutter client omits the
 * field when note is empty; Kotlin/serialization just serializes
 * null which the server treats identically.
 */
@Serializable
data class CreateInviteBody(val note: String? = null)
