import { config, networkUtils } from '@utils';

const { request } = networkUtils;
const { api } = config;
const { message } = api;
const { notification, isValidRcpt } = message;

/**
 * 系统消息一览表
 *
 * @param params 参数对象
 * {
 *  limit:10,
 *  offset:0,
 *  sortBy:"createTime",
 *  sortDirection:"DESC",
 *  type:'INBOX_TODO', // 非必填 INBOX_TODO 待办(默认类型); INBOX_WARN 告警; INBOX_INFO 其他;
 *  createTimeFrom: '2018-07-08 12:22:11', // 非必填 起始时间
 *  createTimeTo: '2018-07-09 12:22:11', // 非必填 结束时间
 *  unread: '1', // 非必填 过滤消息状态： 1未读  0已读
 *  wechat: true, // 非必填 是否是微信端调用接口
 * }
 */
export async function query(params) {
  return request({
    url: notification,
    method: 'get',
    data: params,
  });
}

export async function getSingle(params) {
  const { type, id } = params;
  return request({
    url: `${notification}/${type}/${id}`,
    method: 'post',
  });
}

export async function rcptValid() {
  return request({
    url: isValidRcpt,
    method: 'get',
  });
}
