import api from './api';

const BASE = '/risks';

const riskService = {
    getAll:  async (params = {}) => { const r = await api.get(BASE, { params }); return r.data.data; },
    getStats: async ()           => { const r = await api.get(`${BASE}/stats`);  return r.data.data; },
    sync:    async ()            => { const r = await api.post(`${BASE}/sync`);  return r.data.data; },
    create:  async (data)        => { const r = await api.post(BASE, data);      return r.data.data; },
    update:  async (id, data)    => { const r = await api.put(`${BASE}/${id}`, data); return r.data.data; },
    delete:  async (id)          => { await api.delete(`${BASE}/${id}`); },
};

export default riskService;
