"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = exports.API = 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_IOT_TOKEN: 'cityinterface/rest/services.svc/generateGCKToken',
  GENERATE_QRCODE: 'cityinterface/rest/services.svc/generatetokenByqrcode',
  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_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',
  SEND_MESSAGE_CODE: 'CityInterface/rest/services/portal.svc/SendMessVerificationCode',
  CHANGE_PASSWORD: 'cityinterface/rest/services.svc/changepassword',
  IOT_CHANGE_PASSWORD: 'CityInterface/rest/services/OMS.svc/U_UpdatePasswordQuickGCK',
  FILE_DOWNLOAD: '"/cityinterface/rest/services/filedownload.svc/download'
};
exports.API = API;

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()
    };
    var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
    return vm.get(API.GET_CONFIG, data, config).then(function (res) {
      return Promise.resolve(res);
    });
  };

  vm.generateToken = function () {
    var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
    var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
    return vm.get(window.globalConfig.loginTemplate === 'Dark - IOTMultiLogin.html' ? API.GENERATE_IOT_TOKEN : API.GENERATE_TOKEN, data, config).then(function (res) {
      return Promise.resolve(res);
    });
  };

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

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

  vm.getUserInfo = function () {
    var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
    var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
    return vm.get(API.GET_USER_INFO, data, config).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.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] : {};
    var config = arguments.length > 1 ? arguments[1] : undefined;
    return vm.get(API.GET_WEATHER, data, config).then(function (res) {
      return Promise.resolve(res);
    });
  };

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

  vm.changePassword = function () {
    var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
    var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
    return vm.get(window.globalConfig.loginTemplate === 'Dark - IOTMultiLogin.html' ? API.IOT_CHANGE_PASSWORD : API.CHANGE_PASSWORD, data, config).then(function (res) {
      return Promise.resolve(res);
    });
  };
};

exports["default"] = _default;