package com.fabledsword.minstrel.api.endpoints

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

/**
 * Retrofit interface for `/api/admin/users`. Mirrors
 * `flutter_client/lib/api/endpoints/admin_users.dart`.
 *
 * Note: the PUT-auto-approve body field is `auto_approve`, NOT
 * `auto_approve_requests` — the request shape differs from the
 * response field name. Verified against `internal/api/admin_users.go
 * adminAutoApproveReq` (May 2026).
 */
interface AdminUsersApi {
    @GET("api/admin/users")
    suspend fun list(): AdminUsersListWire

    @PUT("api/admin/users/{id}/admin")
    suspend fun setAdmin(@Path("id") id: String, @Body body: SetAdminBody)

    @PUT("api/admin/users/{id}/auto-approve")
    suspend fun setAutoApprove(@Path("id") id: String, @Body body: SetAutoApproveBody)

    @POST("api/admin/users/{id}/reset-password")
    suspend fun resetPassword(@Path("id") id: String, @Body body: ResetPasswordBody)

    @DELETE("api/admin/users/{id}")
    suspend fun delete(@Path("id") id: String)
}

@Serializable
data class SetAdminBody(
    @kotlinx.serialization.SerialName("is_admin") val isAdmin: Boolean,
)

@Serializable
data class SetAutoApproveBody(
    @kotlinx.serialization.SerialName("auto_approve") val autoApprove: Boolean,
)

@Serializable
data class ResetPasswordBody(val password: String)
