import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import {
  CompareReportQuery,
  CompareReportResult,
  ElectricityDeviceOption,
  ElectricityReportQuery,
  ElectricityReportResult,
  EnergyReportQuery,
  EnergyReportResult,
  RealTimeCurveQuery,
  RealTimeCurveResult,
  SeniorFlowResult,
  SeniorPowerQuery,
  SeniorPowerResult,
  TemperatureDeviceOption,
  TemperatureReportQuery,
  TemperatureReportResult,
  TrendReportQuery,
  TrendReportResult,
  WaterDeviceOption,
  WaterReportQuery,
  WaterReportResult
} from './types';

export const getEnergyReport = (params: EnergyReportQuery): AxiosPromise<EnergyReportResult> => {
  return request({
    url: '/ems/report/energy',
    method: 'get',
    params
  });
};

export const listTemperatureDevices = (): AxiosPromise<TemperatureDeviceOption[]> => {
  return request({
    url: '/ems/temperature/devices',
    method: 'get'
  });
};

export const getTemperatureReport = (params: TemperatureReportQuery): AxiosPromise<TemperatureReportResult> => {
  return request({
    url: '/ems/temperature/line',
    method: 'get',
    params
  });
};

export const listElectricityDevices = (): AxiosPromise<ElectricityDeviceOption[]> => {
  return request({
    url: '/ems/electricity/devices',
    method: 'get'
  });
};

export const getElectricityReport = (params: ElectricityReportQuery): AxiosPromise<ElectricityReportResult> => {
  return request({
    url: '/ems/electricity/line',
    method: 'get',
    params
  });
};

export const listWaterDevices = (): AxiosPromise<WaterDeviceOption[]> => {
  return request({
    url: '/ems/water/devices',
    method: 'get'
  });
};

export const getWaterReport = (params: WaterReportQuery): AxiosPromise<WaterReportResult> => {
  return request({
    url: '/ems/water/line',
    method: 'get',
    params
  });
};

export const getSeniorPowerReport = (params: SeniorPowerQuery): AxiosPromise<SeniorPowerResult> => {
  return request({
    url: '/ems/senior/power',
    method: 'get',
    params
  });
};

export const getSeniorFlowReport = (params: SeniorPowerQuery): AxiosPromise<SeniorFlowResult> => {
  return request({
    url: '/ems/senior/flow',
    method: 'get',
    params
  });
};

export const getCompareReport = (params: CompareReportQuery): AxiosPromise<CompareReportResult> => {
  return request({
    url: '/ems/report/compare',
    method: 'get',
    params
  });
};

export const getTrendReport = (params: TrendReportQuery): AxiosPromise<TrendReportResult> => {
  return request({
    url: '/ems/report/trend',
    method: 'get',
    params
  });
};

export const getRealTimeCurve = (params: RealTimeCurveQuery): AxiosPromise<RealTimeCurveResult> => {
  return request({
    url: '/ems/report/realTimeCurve',
    method: 'get',
    params
  });
};
