import request from '@/utils/request'
import type {
  IntentRule,
  IntentRuleCreate,
  IntentRuleUpdate,
  IntentRuleListResponse
} from '@/types/intent-rule'

export function listIntentRules(params?: {
  response_type?: string
  is_enabled?: boolean
}): Promise<IntentRuleListResponse> {
  return request({
    url: '/admin/intent-rules',
    method: 'get',
    params
  })
}

export function getIntentRule(ruleId: string): Promise<IntentRule> {
  return request({
    url: `/admin/intent-rules/${ruleId}`,
    method: 'get'
  })
}

export function createIntentRule(data: IntentRuleCreate): Promise<IntentRule> {
  return request({
    url: '/admin/intent-rules',
    method: 'post',
    data
  })
}

export function updateIntentRule(ruleId: string, data: IntentRuleUpdate): Promise<IntentRule> {
  return request({
    url: `/admin/intent-rules/${ruleId}`,
    method: 'put',
    data
  })
}

export function deleteIntentRule(ruleId: string): Promise<void> {
  return request({
    url: `/admin/intent-rules/${ruleId}`,
    method: 'delete'
  })
}

export type {
  IntentRule,
  IntentRuleCreate,
  IntentRuleUpdate,
  IntentRuleListResponse
}
