import {get, post, put, del} from '../http/http'

const prefix = "dawn/api/v1/"

const apiEmails = {
  /**
   * 获取邮件配置
   */
  getEmailConfiguration() {
    return get(prefix + "email/config")
  },
  /**
   * 保存邮件配置
   * @param {Object} data
   */
  saveEmailConfiguration(data) {
    return post(prefix + "email/config", data)
  },
  /**
   * 获取邮件协议选项列表
   */
  getProtocolOptions() {
    return get(prefix + "email/protocol-select")
  },
  /**
   * 创建邮件收件人
   * @param {Object} data {recipientEmail}
   */
  creatEmailRecipient(data) {
    return post(prefix + "email/recipient", data)
  },
  /**
   * 删除邮件收件人
   * @param {Object} recipientId 收件人id
   */
  deleteEmailRecipient(recipientId) {
    return del(prefix + "email/recipient/" + recipientId)
  },
  /**
   * 分页获取邮件收件人列表
   * @param {Object} data {emailId,criteria}
   */
  getRecipientPages(data) {
    return post(prefix + "email/recipient-pages", data)
  },
  /**
   * 分页获取通知类型
   * @param {Object} data {emailId,recipientId,assignmentStatus}
   */
  getAssignNotifyPages(data) {
    return post(prefix + "email/notify-type-pages", data)
  },
  /**
   * 分配指定收件人的通知类型
   * @param {Object} data {emailId,recipientId,notifyTypeIds}
   */
  assignEmailNotify(data) {
    return post(prefix + "email/assign-notify-types", data)
  },
  /**
   * 取消分配指定收件人的通知类型
   * @param {Object} data {emailId,recipientId,notifyTypeIds}
   */
  unassignEmailNotify(data) {
    return post(prefix + "email/unassign-notify-types", data)
  },
  /**
   * 向指定收件人发送测试邮件
   * @param {Object} data {recipientId}
   */
  sendTestMail(data) {
    return post(prefix + "email/send-test", data)
  }
}

export default apiEmails;