package dev.lions.unionflow.client.service;

import dev.lions.unionflow.server.api.dto.analytics.AnalyticsDataResponse;
import dev.lions.unionflow.server.api.dto.analytics.DashboardWidgetResponse;
import dev.lions.unionflow.server.api.dto.analytics.KPITrendResponse;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
import org.eclipse.microprofile.rest.client.annotation.RegisterClientHeaders;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import java.util.List;
import java.util.Map;

@RegisterRestClient(configKey = "unionflow-api")
@RegisterClientHeaders(dev.lions.unionflow.client.security.AuthHeaderFactory.class)
@Path("/api/v1/analytics")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public interface AnalyticsService {
    
    @GET
    @Path("/metriques/{typeMetrique}")
    AnalyticsDataResponse calculerMetrique(
        @PathParam("typeMetrique") String typeMetrique,
        @QueryParam("periode") String periode,
        @QueryParam("organisationId") String organisationId
    );
    
    @GET
    @Path("/tendances/{typeMetrique}")
    Map<String, Object> calculerTendanceKPI(
        @PathParam("typeMetrique") String typeMetrique,
        @QueryParam("periode") String periode,
        @QueryParam("organisationId") String organisationId
    );
    
    @GET
    @Path("/kpis")
    Map<String, Object> obtenirTousLesKPI(
        @QueryParam("periode") String periode,
        @QueryParam("organisationId") String organisationId
    );
    
    @GET
    @Path("/evolutions")
    Map<String, Object> obtenirEvolutionsKPI(
        @QueryParam("periode") String periode,
        @QueryParam("organisationId") String organisationId
    );
    
    @GET
    @Path("/performance-globale")
    Map<String, Object> calculerPerformanceGlobale(
        @QueryParam("periode") String periode,
        @QueryParam("organisationId") String organisationId
    );
    
    @GET
    @Path("/dashboard/widgets")
    List<Map<String, Object>> obtenirWidgetsTableauBord(
        @QueryParam("organisationId") String organisationId,
        @QueryParam("utilisateurId") String utilisateurId
    );
}

