import axios from "axios";
import { iotPlatformUrl } from '@/config/env'
import { getDevcieApp } from "@/api/app";

var appInfo = {}
var intervalInfo = null;

function getAppInfo() {
  getDevcieApp().then(res => {
    appInfo = res.data;
  });
}
function intervalInfofu() {
  if (intervalInfo) {
    return;
  }
  getAppInfo();
  intervalInfo = setInterval(() => {
    getAppInfo();
  }, 30 * 60 * 1000);
}

export function startInterval() {
  intervalInfofu()
}

export function getProdFunList(param) {
  return axios.get(iotPlatformUrl + "/openapi/sign/prod/fun/list", { params: param, headers: appInfo })
}

export function getProdCmdList(param) {
  return axios.get(iotPlatformUrl + "/openapi/sign/prod/cmd/list", { params: param, headers: appInfo })
}

export function getDataUploadList(param) {
  return axios({
    method: 'post',
    url: iotPlatformUrl + "/openapi/sign/dev/data/upload/field/list",
    data: param,
    headers: appInfo
  })
}
