import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BindMeasuringDevicesForm, CollectingDeviceForm, CollectingDeviceQuery, CollectingDeviceVO } from './types';

export const listCollectingDevice = (params?: CollectingDeviceQuery): AxiosPromise<CollectingDeviceVO[]> => {
  return request({
    url: '/ems/collectingDevice/list',
    method: 'get',
    params
  });
};

export const getCollectingDevice = (id: string | number): AxiosPromise<CollectingDeviceVO> => {
  return request({
    url: '/ems/collectingDevice/' + id,
    method: 'get'
  });
};

export const addCollectingDevice = (data: CollectingDeviceForm) => {
  return request({
    url: '/ems/collectingDevice',
    method: 'post',
    data
  });
};

export const updateCollectingDevice = (data: CollectingDeviceForm) => {
  return request({
    url: '/ems/collectingDevice',
    method: 'put',
    data
  });
};

export const bindMeasuringDevices = (data: BindMeasuringDevicesForm) => {
  return request({
    url: '/ems/collectingDevice/bindMeasuringDevices',
    method: 'put',
    data
  });
};

export const delCollectingDevice = (ids: string | number | Array<string | number>) => {
  return request({
    url: '/ems/collectingDevice/' + ids,
    method: 'delete'
  });
};
