import { apiGet, apiPost } from '@/lib/http'
import type {
  AdminPagination,
  AdminWebhookEventDetail,
  AdminWebhookEventListItem,
  AdminWebhookReplayResponse,
} from '@/types/admin'

export function fetchAdminWebhookEvents(params?: Record<string, unknown>) {
  return apiGet<{ items: AdminWebhookEventListItem[]; pagination: AdminPagination }>(
    '/api/v1/admin/webhook-events',
    params,
  )
}

export function fetchAdminWebhookEventDetail(eventId: number | string) {
  return apiGet<AdminWebhookEventDetail>(`/api/v1/admin/webhook-events/${eventId}`)
}

export function replayAdminWebhookEvent(eventId: number | string) {
  return apiPost<AdminWebhookReplayResponse>(`/api/v1/admin/webhook-events/${eventId}/replay`, {})
}
