package dev.lions.user.manager.client.api;

import dev.lions.user.manager.client.filter.AuthHeaderFactory;
import dev.lions.user.manager.dto.audit.AuditLogDTO;
import dev.lions.user.manager.enums.audit.TypeActionAudit;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import org.eclipse.microprofile.rest.client.annotation.RegisterClientHeaders;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;

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

@RegisterRestClient(configKey = "user-api")
@RegisterClientHeaders(AuthHeaderFactory.class)
@Path("/api/audit")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public interface AuditRestClient {

        @GET
        List<AuditLogDTO> searchLogs(
                        @QueryParam("acteur") String acteur,
                        @QueryParam("dateDebut") String dateDebut,
                        @QueryParam("dateFin") String dateFin,
                        @QueryParam("typeAction") TypeActionAudit typeAction,
                        @QueryParam("ressourceType") String ressourceType,
                        @QueryParam("succes") Boolean succes,
                        @QueryParam("page") int page,
                        @QueryParam("pageSize") int pageSize);

        @GET
        @Path("/stats/actions")
        Map<TypeActionAudit, Long> getActionStatistics(
                        @QueryParam("dateDebut") String dateDebut,
                        @QueryParam("dateFin") String dateFin);

        @GET
        @Path("/stats/activity")
        Map<String, Long> getUserActivityStatistics(
                        @QueryParam("dateDebut") String dateDebut,
                        @QueryParam("dateFin") String dateFin);

        @GET
        @Path("/stats/failures")
        long getFailureCount(
                        @QueryParam("dateDebut") String dateDebut,
                        @QueryParam("dateFin") String dateFin);

        @GET
        @Path("/stats/successes")
        long getSuccessCount(
                        @QueryParam("dateDebut") String dateDebut,
                        @QueryParam("dateFin") String dateFin);
}
