/**
 * Instantly Lead Unsubscribed Trigger Definition
 *
 * Webhook trigger for Instantly lead unsubscribe events.
 * Uses Instantly's native snake_case format - no transformation needed.
 */

import type { TriggerDefinition, WebhookTriggerConfig } from '../../../../platform/registry/types'

/**
 * Instantly lead unsubscribed webhook payload structure
 *
 * Uses snake_case matching Instantly's API. Workflows receive this directly.
 */
export interface InstantlyLeadUnsubscribedPayload {
  timestamp: string
  event_type: 'lead_unsubscribed'
  workspace: string
  campaign_id: string
  campaign_name?: string
  lead_email: string
  email_account: string
}

/**
 * Instantly Lead Unsubscribed Trigger Definition
 *
 * Trigger type: webhook
 * Provider: instantly
 * Event: lead_unsubscribed
 */
export const instantlyLeadUnsubscribedTrigger: TriggerDefinition = {
  resourceId: 'trigger-instantly-lead-unsubscribed',
  type: 'trigger',
  triggerType: 'webhook',
  name: 'Instantly Lead Unsubscribed',
  description: 'Webhook fired when a lead unsubscribes from an Instantly email campaign',
  version: '1.0.0',
  status: 'dev',
  webhookPath: '/webhooks/instantly/lead-unsubscribed',
  config: {
    provider: 'instantly',
    event: 'lead_unsubscribed'
  } as WebhookTriggerConfig
}
