"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _kit_utils = require("kit_utils");

var API = {
  GET_CONFIG: '/CityInterface/rest/services.svc/GetConfig',
  GENERATE_TOKEN: '/cityinterface/rest/services.svc/generatetoken',
  GENERATE_TOKEN_CHANGE: '/cityinterface/rest/services.svc/generatetokenquick',
  GET_WEB_SITE_CONFIG: '/CityInterface/rest/services.svc/GetWebSiteConfig',
  GET_USER_INFO: '/CityInterface/rest/services.svc/getUserInfo',
  GET_OA: '/CityInterface/rest/services/OA.svc/getLoginInfo',
  GET_LOGS: '/CityInterface/rest/services/portal.svc/OMMonitor/SaveLoginInfo',
  GET_INFORMATION: '/CityInterface/rest/services/CountyProduct.svc/SCADAOper/GetInformationInfo',
  GET_CITY: 'https://pv.sohu.com/cityjson?ie=utf-8',
  GET_ALL_GROUPS_INFO_FORUSER: 'CityInterface/rest/Services/Portal.svc/AuthorityManage/GetAllGroupsInfoForUser',
  GET_WEATHER: '/CityInterface/rest/services/CountyProduct.svc/GetWeather'
};

var _default = function _default(vm) {
  vm.getConfig = function () {
    var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
      client: _kit_utils.params.getParams('client') || 'city',
      ts: Date.now()
    };
    return vm.get(API.GET_CONFIG, data).then(function (res) {
      return Promise.resolve(res);
    });
  };

  vm.generateToken = function () {
    var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
    return vm.get(API.GENERATE_TOKEN, data).then(function (res) {
      return Promise.resolve(res);
    });
  };

  vm.getWebSiteConfig = function () {
    var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
    return vm.get(API.GET_WEB_SITE_CONFIG, data).then(function (res) {
      return Promise.resolve(res);
    });
  };

  vm.getUserInfo = function () {
    var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
    return vm.get(API.GET_USER_INFO, data).then(function (res) {
      return Promise.resolve(res);
    });
  };

  vm.getOA = function () {
    var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
    return vm.get(API.GET_OA, data).then(function (res) {
      return Promise.resolve(res);
    });
  };

  vm.writeLogs = function () {
    var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
    var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
    return vm.post(API.GET_LOGS, data, config).then(function (res) {
      return Promise.resolve(res);
    });
  };

  vm.getInformationInfo = function () {
    var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
    return vm.get(API.GET_INFORMATION, data).then(function (res) {
      return Promise.resolve(res);
    });
  };

  vm.getCity = function () {
    return vm.get(API.GET_CITY).then(function (res) {
      return Promise.resolve(res);
    });
  };

  vm.generateTokenQuick = function () {
    var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
    return vm.get(API.GENERATE_TOKEN_CHANGE, data).then(function (res) {
      return Promise.resolve(res);
    });
  };

  vm.getAllGroupsInfoForUser = function () {
    var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
    var config = arguments.length > 1 ? arguments[1] : undefined;
    return vm.get(API.GET_ALL_GROUPS_INFO_FORUSER, data, config).then(function (res) {
      return Promise.resolve(res);
    });
  };

  vm.getWeather = function () {
    var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
    return vm.get(API.GET_WEATHER, data).then(function (res) {
      return Promise.resolve(res);
    });
  };
};

exports["default"] = _default;