import { get, post, patch, del } from './client.js';

export async function fetchCounters(params = {}) {
  const query = new URLSearchParams(params).toString();
  return get(query ? `/api/counter?${query}` : '/api/counter');
}

export async function fetchCounter(id) {
  return get(`/api/counter/${id}`);
}

export async function createCounter(data) {
  return post('/api/counter', data);
}

export async function updateCounter(id, data) {
  return patch(`/api/counter/${id}`, data);
}

export async function deleteCounter(id) {
  return del('/api/counter', { body: JSON.stringify({ CounterID: id }) });
}
