import { api } from './client'

export async function fetchSmtpConfigs() {
  const { data } = await api.get('/smtp/configs')
  return data
}

export async function createSmtpConfig(payload) {
  const { data } = await api.post('/smtp/configs', payload)
  return data
}

export async function updateSmtpConfig(configId, payload) {
  const { data } = await api.put(`/smtp/configs/${configId}`, payload)
  return data
}

export async function deleteSmtpConfig(configId) {
  const { data } = await api.delete(`/smtp/configs/${configId}`)
  return data
}

export async function testSmtpConfig(configId, email) {
  const { data } = await api.post(`/smtp/configs/${configId}/test`, { email })
  return data
}

export async function setPrimarySmtpConfig(configId) {
  const { data } = await api.post(`/smtp/configs/${configId}/primary`)
  return data
}

export async function clearPrimarySmtpConfig() {
  const { data } = await api.post('/smtp/configs/primary/clear')
  return data
}
