'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _ioauthoringConfigManager = require('../managers/ioauthoringConfigManager');

var _ioauthoringConfigManager2 = _interopRequireDefault(_ioauthoringConfigManager);

var _appUtils = require('../utils/appUtils');

var _appUtils2 = _interopRequireDefault(_appUtils);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/*
 * *******************************************************************************
 *  * Copyright (c) 2018 Edgeworx, Inc.
 *  *
 *  * This program and the accompanying materials are made available under the
 *  * terms of the Eclipse Public License v. 2.0 which is available at
 *  * http://www.eclipse.org/legal/epl-2.0
 *  *
 *  * SPDX-License-Identifier: EPL-2.0
 *  *******************************************************************************
 *
 */

var getConfigDataByKey = function getConfigDataByKey(props, params, callback) {

  _ioauthoringConfigManager2.default.getByKey(props.key).then(_appUtils2.default.onFind.bind(null, params, props.setProperty, 'Unable to find configurations', callback));
};

var configList = function configList() {
  _ioauthoringConfigManager2.default.list().then(function (config) {
    if (config && config.length > 0) {
      console.log('\nFollowing is the configuration information:');
      for (var i = 0; i < config.length; i++) {
        console.log(config[i].key + ' | ' + config[i].value);
      }
    } else {
      console.log('\nNo Configuration Data Found.');
    }
  });
};

exports.default = {
  configList: configList,
  getConfigDataByKey: getConfigDataByKey
};