import {SUBNET_SERVICE, SUBNET_SERVICE_MODIFY, SUBNET_SERVICE_DELETE, REQUEST_CONFIG} from "../../../utils/RequestUrls";
import Axios from 'axios'

var staticMethods = {
  getAllServiceSubnetCollection: function(){
    return Axios.get(SUBNET_SERVICE);
  },

  //新增ServiceSubnet（待测试及确认）
  postServiceSubnetAdd:function (eline) {
    return Axios.post(SUBNET_SERVICE, eline, REQUEST_CONFIG);
  },

  //修改（待测试及确认）
  putServiceSubnetUpdate:function (eline,serviceSubnetIDForupdate,serviceSubnetNameForUpdate) {
    return Axios.put(SUBNET_SERVICE + '/' + serviceSubnetIDForupdate + '/' + serviceSubnetNameForUpdate, eline, REQUEST_CONFIG);
  },

  //删除（待测试及确认）
  ServiceSubnetDelete:function (serviceSubnetKeyList) {
    return Axios.delete(SUBNET_SERVICE_DELETE,{
      data:serviceSubnetKeyList,
      headers:{'Content-Type':'application/json','Encoding':'utf-8'}
    })
  },

  // 修改子网设备
  putModifySubnetDevices: function (serviceSubnet) {
    return Axios.put(SUBNET_SERVICE_MODIFY, serviceSubnet, REQUEST_CONFIG);
  }
}

function ServiceSubnetAPI (websocketService = null) {
  return Object.freeze(Object.assign(
    {
      // object methods comes here
    },
    staticMethods
  ))
}

Object.assign(ServiceSubnetAPI, staticMethods);
export default ServiceSubnetAPI
