import { WeaTools } from 'ecCom';

const Method = {
  Post: "POST",
  Get: "GET"
}

const APIList = [{
  // 基础信息（表单信息）
  name: "getFields",
  path: "/coremail/base/getFields",
  type: Method.Get
}, {
  // 基础信息菜单信息（标题、按钮等信息）
  name: "baseGetRightMenu",
  path: "/coremail/base/getRightMenu",
  type: Method.Get
}, {
  // 同步日志列表
  name: "getDatas",
  path: "/coremail/log/getDatas",
  type: Method.Get
}, {
  // 同步日志菜单信息（标题，按钮等信息）
  name: "logGetRightMenu",
  path: "/coremail/log/getRightMenu",
  type: Method.Get
}, {
  // 同步日志高级查询表单
  name: "getCondition",
  path: "/coremail/log/getCondition",
  type: Method.Get
}, {
  name: "init",
  path: "/newcoremail/init",
  type: Method.Post
}, {
  name: "test",
  path: "/newcoremail/test",
  type: Method.Post
}, {
  name: "save",
  path: "/newcoremail/save",
  type: Method.Post
}, {
  name: "getCoreMailList",
  path: "/newcoremail/getCoreMailList",
  type: Method.Post
}, {
  name: "getCoreMailRightMenu",
  path: "/newcoremail/getCoreMailRightMenu",
  type: Method.Post
}, {
  name: "getCoremailMailAddForm",
  path: "/newcoremail/getCoremailMailAddForm",
  type: Method.Post
}, {
  name: "getCoreMailSaveOperation",
  path: "/newcoremail/getCoreMailSaveOperation",
  type: Method.Post
}, {
  name: "getCoreMailCondition",
  path: "/newcoremail/getCoreMailCondition",
  type: Method.Post
}, {
  name: "getCoreMailDelete",
  path: "/newcoremail/getCoreMailDelete",
  type: Method.Post
} , {
  name: "getCoreMailOperation",
  path: "/newcoremail/getCoreMailOperation",
  type: Method.Post
}
]

const API = (function () {
  const Obj = {};
  APIList.map(item => {
    Obj[item.name] = (params) => {
      return WeaTools.callApi(`/api/integration${item.path}`, item.type, params);
    }
  })
  return Obj;
})();


API.view = params => {
  return WeaTools.callApi('/api/common/log/view', 'POST', params);
}


export default API;

