package com.fabledsword.minstrel.api.endpoints

import com.fabledsword.minstrel.models.wire.ArtistSuggestionWire
import com.fabledsword.minstrel.models.wire.CreateRequestBody
import com.fabledsword.minstrel.models.wire.LidarrSearchResultWire
import com.fabledsword.minstrel.models.wire.SnoozeSuggestionBody
import com.fabledsword.minstrel.models.wire.SuggestionSnoozeWire
import retrofit2.http.Body
import retrofit2.http.DELETE
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query

/**
 * Retrofit interface for Discover / Lidarr search / request creation.
 * Mirrors `flutter_client/lib/api/endpoints/discover.dart`.
 *
 * `/api/lidarr/search` has a 60s LRU on the server so quick re-types
 * of the same query are cheap.
 *
 * Cancel + my-requests-list endpoints live on RequestsApi (Phase 10
 * Commit B), not here.
 */
interface DiscoverApi {
    @GET("api/discover/suggestions")
    suspend fun listSuggestions(): List<ArtistSuggestionWire>

    @GET("api/lidarr/search")
    suspend fun search(
        @Query("q") query: String,
        @Query("kind") kind: String,
    ): List<LidarrSearchResultWire>

    @POST("api/requests")
    suspend fun createRequest(@Body body: CreateRequestBody)

    /**
     * Parks a suggestion — "not right now", NOT a dislike. Time-boxed
     * server-side (90 days) and never fed into the taste profile.
     *
     * [body] must carry the artist's name: candidates are out-of-library, so
     * the server has no local row to resolve a display name from and returns
     * 400 without it.
     */
    @POST("api/discover/suggestions/{mbid}/snooze")
    suspend fun snoozeSuggestion(
        @Path("mbid") mbid: String,
        @Body body: SnoozeSuggestionBody,
    )

    /** Brings a parked suggestion back. 404 when it wasn't snoozed. */
    @DELETE("api/discover/suggestions/{mbid}/snooze")
    suspend fun unsnoozeSuggestion(@Path("mbid") mbid: String)

    /**
     * Currently-parked suggestions. Server filters expired rows, so every
     * row returned is still snoozed. This is the only route back to an
     * un-snooze once the card has left the deck.
     */
    @GET("api/discover/snoozes")
    suspend fun listSnoozes(): List<SuggestionSnoozeWire>
}
