import {GET, Delete, POST, PUT} from "@/utils/request";

const GetGroups = (params) => {
  return POST("/group/page", params, true);
};

const AddGroup = (data) => {
  return POST("/group", data, true);
};

const DeleteGroup = (id) => {
  return Delete(`/group/${id}`, {});
};

const DeleteAllGroup = (data) => {
  return POST(`/group/delete`, data, true);
};

const GetGroupsDetail = (id) => {
  return POST(`/group/${id}`, {});
};

const UpdateGroupCondition = (data) => {
  return PUT(`/group/${data.id}`, data, true);
};

const UpdateGroupConfiguration = (params) => {
  return GET("/group/configuration", params);
};

const GetVehicleByCondition = (data) => {
  return POST(`/group/vehicle/getAllVIDs/${data.id}`, data, true);
};

const GetVehicleByGroup = (data) => {
  return POST(`/group/vehicle/getInfos`, data, true);
}

const GetVehicleInfoByVid = (data) => {
  return POST(`/vehicle/getVehicleInfo`, data, true);
}

const GetVINByVid = (data) => {
  return POST(`/vehicle/getVINs`, data, true);
}

const GetVIDByVin = (data) => {
  return POST(`/vehicle/getVIDs`, data, true);
}

const UpdateGroupVehicle = (data) => {
  return PUT(`/group/vin/${data.id}`, data, true);
}

const UnbindConfiguration = (params) => {
  return GET(`/group/configuration/unbind`, params);
}

const getAttributeKV= () => {
  return PUT(`/group/attribute/kv`, {}, true);
};

const GetAttribute = () => {
  return GET("/group/attribute/all", {});
};

const GetPolicyJson = (id) => {
  return GET(`/group/policy/detail/${id}`, {});
};

const GetPolicyByVersion = (data) => {
  return POST("/group/policy/view", data, true);
};

export {
  getAttributeKV,
  GetAttribute,
  GetPolicyJson,
  GetPolicyByVersion,
  GetGroups,
  AddGroup,
  DeleteGroup,
  DeleteAllGroup,
  GetGroupsDetail,
  UpdateGroupCondition,
  UpdateGroupConfiguration,
  GetVehicleByCondition,
  GetVehicleByGroup,
  GetVehicleInfoByVid,
  GetVINByVid,
  GetVIDByVin,
  UnbindConfiguration,
  UpdateGroupVehicle
};
