import { apiGet } from './client';
import type { Contact } from '@/types';

export async function fetchContacts(deviceId?: string): Promise<Contact[]> {
  try {
    const qs = deviceId ? `?deviceId=${encodeURIComponent(deviceId)}` : '';
    return await apiGet<Contact[]>(`/my/contacts${qs}`);
  } catch (err) {
    throw err instanceof Error ? err : new Error('fetchContacts failed');
  }
}
