import api from '@/services/api';
import { handleRequest } from '@/services/serviceUtils';

/**
 * Service for Fleet Monitoring and Quality (Moki).
 */
export const monitoringService = {
  // --- Monitoramento Frota (Telemetria) ---
  
  createMonitoring: (data) => handleRequest({
    apiFn: async () => {
      const response = await api.post('/monitoramento_frota', data);
      return response.data;
    }
  }),

  getMonitoring: () => handleRequest({
    apiFn: async () => {
      const response = await api.get('/monitoramento_frota/apresentar');
      return response.data;
    }
  }),

  updateMonitoring: (id, data) => handleRequest({
    apiFn: async () => {
      const response = await api.put(`/monitoramento_frota/${id}`, data);
      return response.data;
    }
  }),

  // --- Moki Frota (Checklists) ---

  getMokiData: () => handleRequest({
    apiFn: async () => {
      const response = await api.get('/moki_frota/apresentar');
      return response.data;
    }
  }),

  updateMokiData: (id, data) => handleRequest({
    apiFn: async () => {
      const response = await api.put(`/moki_frota/${id}`, data);
      return response.data;
    }
  })
};
