import request from '@/service/request'

/**
 * 获取账户的系统配置
 * @returns
 */
export const getSysConf = () => {
  return request<IOT.API.SYS.Sys>({
    url: '/sysConf',
    method: 'GET'
  })
}

/**
 * 修改账户配置
 * @returns
 */
export const updateSysConf = (data: IOT.API.SYS.Sys) => {
  return request<string>({
    url: '/sysConf',
    method: 'PUT',
    data
  })
}

/**
 * 新增账户配置
 * @returns
 */
export const addSysConf = (data: IOT.API.SYS.Sys) => {
  return request<string>({
    url: '/sysConf',
    method: 'POST',
    data
  })
}

/**
 * 查询通知方式列表
 * @returns
 */
export const getNoticeMethod = (params: any) => {
  return request<IOT.API.SYS.Notice[]>({
    url: '/notificationMethod/page',
    method: 'GET',
    params
  })
}

/**
 * 新增通知方式
 * @returns
 */
export const addNoticeMethod = (data: any) => {
  return request<string>({
    url: '/notificationMethod',
    method: 'POST',
    data
  })
}

export const updateNoticeMethod = (data: any) => {
  return request<string>({
    url: '/notificationMethod',
    method: 'PUT',
    data
  })
}

/**
 * 通知方式 详情
 * @returns
 */
export const getNoticeById = (id: string) => {
  return request<IOT.API.SYS.Notice>({
    url: `/notificationMethod/${id}`,
    method: 'GET'
  })
}

export const delNotice = (id: string) => {
  return request<string>({
    url: `/notificationMethod/${id}`,
    method: 'DELETE'
  })
}

export const updateNoticeStaus = ({ id, status }: {id: string, status: string}) => {
  return request<string>({
    url: `/notificationMethod/status?id=${id}&status=${status}`,
    method: 'PUT'
  })
}

export const updateNoticeLabel = ({ id, label }: {id: string, label: string}) => {
  return request<string>({
    url: `/notificationMethod/label?id=${id}&label=${label}`,
    method: 'PUT'
  })
}
