import Axios from 'axios'
import {NET_PHY_ADMQ,NET_PHY_QUERY,NET_PHY_UPLOAD,NET_PHY_DOWNLOAD,REQUEST_CONFIG} from "../../../utils/RequestUrls";

var staticMethods = {
  getNetPhyLinkCollection: function(){
    return Axios.get(NET_PHY_ADMQ);
  },

  // 添加网络物理连接
  postAddNetPhyLink: function (netPhy) {
    return Axios.post(NET_PHY_ADMQ,netPhy,REQUEST_CONFIG);
  },

  // 删除网络物理连接
  deleteDeleteNetPhyLink: function (netPhyList) {
    return Axios.delete(NET_PHY_ADMQ,{
      data:netPhyList,
      headers:{'Content-Type':'application/json','Encoding':'utf-8'}
    });
  },

  // 修改网络物理连接
  putModifyNetPhyLink: function (netPhy) {
    return Axios.put(NET_PHY_ADMQ,netPhy,REQUEST_CONFIG);
  },

  // 条件查询网络物理连接
  putConditionQueryNetPhyLink: function (conditionSet) {
    return Axios.put(NET_PHY_QUERY,conditionSet,REQUEST_CONFIG);
  },

  // 网络物理连接文件下载
  putDownloadNetPhyLink: function (conditionSet) {
    return Axios.put(NET_PHY_DOWNLOAD,conditionSet,{
      headers: {
        'Content-Type': 'application/json'
      },
      responseType: 'arraybuffer'
    });
  },

  // 网络物理连接文件上传
  postUploadNetPhyLink: function (fileFormData) {
    return Axios.post(NET_PHY_UPLOAD,fileFormData,{headers: {
        'Content-Type': 'multipart/form-data',
        'Accept': 'application/json'
      }});
  }

};

function NetworkPhysicsAPI (websocketService = null) {

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