package org.example.petshopdesktop.api.endpoints;

import com.fasterxml.jackson.core.type.TypeReference;
import org.example.petshopdesktop.api.ApiClient;
import org.example.petshopdesktop.api.dto.activity.ActivityLogResponse;

import java.util.List;

public class ActivityLogApi {
    private static final ActivityLogApi INSTANCE = new ActivityLogApi();
    private final ApiClient apiClient;

    private ActivityLogApi() {
        this.apiClient = ApiClient.getInstance();
    }

    public static ActivityLogApi getInstance() {
        return INSTANCE;
    }

    public List<ActivityLogResponse> getActivityLogs(int limit) throws Exception {
        String path = "/api/v1/activity-logs?limit=" + limit;
        String response = apiClient.getRawResponse(path);
        return apiClient.getObjectMapper().readValue(
            response,
            new TypeReference<List<ActivityLogResponse>>() {}
        );
    }
}
