/**
 * @ai-summary API calls for email ingestion pending associations
 */

import { apiClient } from '../../../core/api/client';
import type {
  PendingVehicleAssociation,
  PendingAssociationCount,
  ResolveAssociationResult,
} from '../types/email-ingestion.types';

export const emailIngestionApi = {
  getPending: async (): Promise<PendingVehicleAssociation[]> => {
    const response = await apiClient.get('/email-ingestion/pending');
    return response.data;
  },

  getPendingCount: async (): Promise<PendingAssociationCount> => {
    const response = await apiClient.get('/email-ingestion/pending/count');
    return response.data;
  },

  resolve: async (associationId: string, vehicleId: string): Promise<ResolveAssociationResult> => {
    const response = await apiClient.post(`/email-ingestion/pending/${associationId}/resolve`, {
      vehicleId,
    });
    return response.data;
  },

  dismiss: async (associationId: string): Promise<void> => {
    await apiClient.delete(`/email-ingestion/pending/${associationId}`);
  },
};
