import Axios from 'axios'

import {
  REQUEST_CONFIG, CONTROLL_TEMPERATURE, CONTROLL_SOFTWARE, CONTROLL_HARDWARE,
  CONTROLL_FANSTATUS, CONTROLL_REBOOT
} from '../../utils/RequestUrls'

var staticMethods = {

  // 获取设备温度
  getDeviceTemperature: function (panelsDeviceKey) {
    return Axios.put(CONTROLL_TEMPERATURE, panelsDeviceKey, REQUEST_CONFIG)
  },

  // 获取软件版本
  getDeviceSoftware: function (panelsDeviceKey) {
    return Axios.get(CONTROLL_SOFTWARE + panelsDeviceKey + '/', REQUEST_CONFIG)
  },

  // 获取硬件版本
  getDeviceHardware: function (panelsDeviceKey) {
    return Axios.get(CONTROLL_HARDWARE + panelsDeviceKey + '/', REQUEST_CONFIG)
  },

  // 获取风扇状态
  getDevcieFanstatus: function (panelsDeviceKey) {
    // return Axios.get(CONTROLL_FANSTATUS+panelsDeviceKey+"/",REQUEST_CONFIG);
    return Axios.put(CONTROLL_FANSTATUS, panelsDeviceKey, REQUEST_CONFIG)
  },

  // 重启设备
  getRestartDevice: function (panelsDeviceKey) {
    return Axios.get(CONTROLL_REBOOT + panelsDeviceKey + '/', REQUEST_CONFIG)
  }
}

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