package dev.lions.unionflow.client.service;

import dev.lions.unionflow.server.api.dto.communication.request.SendMessageRequest;
import dev.lions.unionflow.server.api.dto.communication.response.MessageResponse;
import org.eclipse.microprofile.rest.client.annotation.RegisterClientHeaders;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;

import java.util.List;
import java.util.Map;
import java.util.UUID;

@RegisterRestClient(configKey = "unionflow-api")
@RegisterClientHeaders(dev.lions.unionflow.client.security.AuthHeaderFactory.class)
@Path("/api/messages")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public interface MessageService {

    @GET
    List<MessageResponse> listerMessages(
        @QueryParam("conversationId") UUID conversationId,
        @QueryParam("limit") @DefaultValue("50") int limit
    );

    @POST
    MessageResponse envoyer(SendMessageRequest request);

    @PUT
    @Path("/{id}")
    MessageResponse modifier(@PathParam("id") UUID id, Map<String, String> body);

    @DELETE
    @Path("/{id}")
    void supprimer(@PathParam("id") UUID id);

    @POST
    @Path("/broadcast")
    MessageResponse diffuser(SendMessageRequest request);
}
