import Axios from 'axios'

import {
  REQUEST_CONFIG, PERIOD_REPORT, PERIOD_REPORT_EXPORT, PERIOD_REPORT_QUERY, PERIOD_REPORT_TOTAL, DEVICE_DOWNLOAD
} from '../../utils/RequestUrls'

var staticMethods = {
  /**
   * @Description  : 分页查询API
   * @author       : ls
   * @date         : 2020/5/6 16:16
   * @param        :
   * @return       :
   */
  putPeriodReportListQueryterms: function (beginItem, endItem, selectList) {
    return Axios.put(PERIOD_REPORT_QUERY + '/' + beginItem + '/' + endItem + '/', selectList, REQUEST_CONFIG)
  },
  /**
   * @Description  : 查询总页数
   * @author       : ls
   * @date         : 2020/5/6 16:06
   * @param        :
   * @return       :
   */
  putPeriodReportListCounts: function (selectList) {
    return Axios.put(PERIOD_REPORT_TOTAL, selectList, REQUEST_CONFIG)
  },
  /**
   * @Description  : 删除
   * @author       : ls
   * @date         : 2020/5/2 14:15
   * @param        :
   * @return       :
   */
  deleteDeletePeriodReport: function (keyList) {
    return Axios.delete(PERIOD_REPORT, {
      data: keyList,
      headers: {'Content-Type': 'application/json', 'Encoding': 'utf-8'}
    })
  },
  /**
   * @Description  : 周期报表下载
   * @author       : ls
   * @date         : 2020/6/15 14:19
   * @param        :
   * @return       :
   */
  putDownloadPeriodReport: function (deviceKey) {
    return Axios.put(PERIOD_REPORT_EXPORT, deviceKey, {
      headers: {
        'Content-Type': 'application/json'
      },
      responseType: 'arraybuffer'
    })
  }
}

function PeriodReportAPI () {
  return Object.freeze(Object.assign(
    {
      // object methods comes here
    },
    staticMethods
  ))
}
// inject static methods
Object.assign(PeriodReportAPI, staticMethods)
export default PeriodReportAPI
