const Logs = require('../libs/logs');

const SETTING = {
  innerDefaultAmount: 10000,
  minProfitAmount: 0,
  innerRebateRatio: 0,
  obRebateRatio: 0,
  hgRebateRatio: 0,
  runWorkerEnabled: false
}

const getSetting = (key) => {
  if (key) {
    return SETTING[key];
  }
  return SETTING;
}

const updateSetting = (fields) => {
  Object.keys(fields).forEach(key => {
    if (SETTING.hasOwnProperty(key) && SETTING[key] !== fields[key]) {
      SETTING[key] = fields[key];
      Logs.out('updateSetting', key, fields[key]);
    }
  });
}

module.exports = { getSetting, updateSetting };