import Axios from 'axios'
import {
  CABINET_ADMQ,
  LOCATION_ADMQ,
  CABINET_QUERY,
  CABINET_UPLOAD,
  CABINET_DOWNLOAD,
  REQUEST_CONFIG,
  FIRMWARE_QUERY,
  LOCATION_DOWNLOAD, LOCATION_QUERY, LOCATION_UPLOAD, SUBNET_UPLOAD
} from "../../utils/RequestUrls";

var staticMethods = {
  getCabinetCollection: function(){
    return Axios.get(CABINET_ADMQ);
  },

  // 添加机架
  postAddCabinet: function (cabinet) {
    return Axios.post(CABINET_ADMQ,cabinet,REQUEST_CONFIG);
  },

  // 删除机架
  deleteDeleteCabinet: function (cabinetKeyList) {
    return Axios.delete(CABINET_ADMQ,{
      data:cabinetKeyList,
      headers:{'Content-Type':'application/json','Encoding':'utf-8'}
    });
  },

  // 修改机架
  putModifyCabinet: function (cabinet) {
    return Axios.put(CABINET_ADMQ,cabinet,REQUEST_CONFIG);
  },

  // 条件查询机架
  putConditionQueryCabinet: function (conditionSet) {
    return Axios.put(CABINET_QUERY,conditionSet,REQUEST_CONFIG);
  },

  // 机架文件下载
  putDownloadCabinet: function (conditionSet) {
    return Axios.put(CABINET_DOWNLOAD,conditionSet,{
      headers: {
        'Content-Type': 'application/json'
      },
      responseType: 'arraybuffer'
    });
  },

  // 机架文件上传
  postUploadCabinet: function (fileFormData) {
    return Axios.post(CABINET_UPLOAD + '/1',fileFormData,{headers: {
        'Content-Type': 'multipart/form-data',
        'Accept': 'application/json'
      }});
  }

};

function CabinetAPI (websocketService = null) {

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