import apiClient from './client'
import type {
  SendJobListResponse,
  SendJobResponse,
  SendPecRequest,
} from '@/types/api.types'

export interface SendJobFilters {
  page?: number
  page_size?: number
  mailbox_id?: string
  status?: string
}

export const sendApi = {
  send: (data: SendPecRequest) =>
    apiClient.post<SendJobResponse>('/send', data).then((r) => r.data),

  listJobs: (filters: SendJobFilters = {}) =>
    apiClient.get<SendJobListResponse>('/send/jobs', { params: filters }).then((r) => r.data),

  getJob: (id: string) =>
    apiClient.get<SendJobResponse>(`/send/jobs/${id}`).then((r) => r.data),

  cancelJob: (id: string) => apiClient.delete(`/send/jobs/${id}`),
}
