import request from '@/utils/request'

export function getActiveExternalApis() {
  return request({
    url: '/companyWorkflow/externalApi/activeList',
    method: 'get'
  })
}

export function getActiveExternalApisLegacy() {
  return request({
    url: '/api/admin/external-api/active-list',
    method: 'get'
  })
}

export function listAllWorkflowTemplates() {
  return request({
    url: '/workflow/lobster/template/list',
    method: 'get'
  })
}

export function listWorkflowTemplate(query) {
  return request({
    url: '/workflow/lobster/template/list',
    method: 'get',
    params: query
  })
}
export function listWorkflowTemplateByStatus(query) {
  return request({
    url: '/workflow/lobster/template/listTemplate',
    method: 'get',
    params: query
  })
}

export function getWorkflowTemplateDetail(id) {
  return request({
    url: '/workflow/lobster/template/' + id,
    method: 'get'
  })
}

export function updateWorkflowTemplate(id, data) {
  return request({
    url: '/workflow/lobster/template/' + id,
    method: 'put',
    data
  })
}

export function updateWorkflowTemplateStatus(id, status) {
  return request({
    url: '/workflow/lobster/template/' + id + '/' + status,
    method: 'put'
  })
}

export function saveWorkflowCanvas(id, data) {
  return request({
    url: '/workflow/lobster/canvas/' + id,
    method: 'put',
    data
  })
}

export function deleteWorkflowTemplate(id) {
  return request({
    url: '/workflow/lobster/template/' + id,
    method: 'delete'
  })
}

export function aiGenerateWorkflow(data) {
  return request({
    url: '/workflow/lobster/ai-generator/generate',
    method: 'post',
    data
  })
}

export function getGenerateResultDetail(recordId) {
  return request({
    url: '/workflow/lobster/ai-generator/result/' + recordId + '/detail',
    method: 'get'
  })
}

export function confirmGenerateResult(recordId) {
  return request({
    url: '/workflow/lobster/ai-generator/confirm/' + recordId,
    method: 'post'
  })
}

export function confirmGenerateResultEdited(recordId, data) {
  return request({
    url: '/workflow/lobster/ai-generator/confirm/' + recordId + '/edited',
    method: 'post',
    data
  })
}
