/**
 * @ai-summary API client for ownership-costs feature
 */

import { apiClient } from '../../../core/api/client';
import type { CreateOwnershipCostRequest, OwnershipCost, UpdateOwnershipCostRequest } from '../types/ownership-costs.types';

export const ownershipCostsApi = {
  async list(filters?: { vehicleId?: string }) {
    const res = await apiClient.get<OwnershipCost[]>('/ownership-costs', { params: filters });
    return res.data;
  },
  async get(id: string) {
    const res = await apiClient.get<OwnershipCost>(`/ownership-costs/${id}`);
    return res.data;
  },
  async create(payload: CreateOwnershipCostRequest) {
    const res = await apiClient.post<OwnershipCost>('/ownership-costs', payload);
    return res.data;
  },
  async update(id: string, payload: UpdateOwnershipCostRequest) {
    const res = await apiClient.put<OwnershipCost>(`/ownership-costs/${id}`, payload);
    return res.data;
  },
  async remove(id: string) {
    await apiClient.delete(`/ownership-costs/${id}`);
  },
};
