package com.github.libretube.api

import kotlinx.serialization.Serializable
import retrofit2.http.Body
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.POST

@Serializable
data class LoginRequest(
    val username: String,
    val password: String
)

@Serializable
data class LoginResponse(
    val status: String,
    val token: String? = null,
    val username: String? = null,
    val role: String? = null,
    val credits: Int? = null
)

@Serializable
data class TokenValidationRequest(
    val token: String
)

@Serializable
data class TokenValidationResponse(
    val status: String
)

@Serializable
data class PlaybackHeartbeatResponse(
    val status: String? = null,
    val reason: String? = null,
    val message: String? = null
)

interface PanelApiService {
    @POST("login.php")
    suspend fun login(
        @Body request: LoginRequest
    ): LoginResponse

    @POST("validar_token.php")
    suspend fun validateToken(
        @Body request: TokenValidationRequest
    ): TokenValidationResponse

    @FormUrlEncoded
    @POST("check_code.php")
    suspend fun checkPlaybackCode(
        @Field("code") code: String
    ): PlaybackHeartbeatResponse
}
