import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { EventsReportVO, EventsReportForm, EventsReportQuery } from '@/api/sense/eventsReport/types';

/**
 * 查询推送记录列表
 * @param query
 * @returns {*}
 */

export const listEventsReport = (query?: EventsReportQuery): AxiosPromise<EventsReportVO[]> => {
  return request({
    url: '/sense/eventsReport/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询推送记录详细
 * @param id
 */
export const getEventsReport = (id: string | number): AxiosPromise<EventsReportVO> => {
  return request({
    url: '/sense/eventsReport/' + id,
    method: 'get'
  });
};

/**
 * 新增推送记录
 * @param data
 */
export const addEventsReport = (data: EventsReportForm) => {
  return request({
    url: '/sense/eventsReport',
    method: 'post',
    data: data
  });
};

/**
 * 修改推送记录
 * @param data
 */
export const updateEventsReport = (data: EventsReportForm) => {
  return request({
    url: '/sense/eventsReport',
    method: 'put',
    data: data
  });
};

/**
 * 删除推送记录
 * @param id
 */
export const delEventsReport = (id: string | number | Array<string | number>) => {
  return request({
    url: '/sense/eventsReport/' + id,
    method: 'delete'
  });
};

/**
 * 批量重试失败推送
 * @param id
 */
export const againReport = (id: string | number | Array<string | number>) => {
  return request({
    url: '/sense/eventsReport/againReport/' + id,
    method: 'get'
  });
};
