var _ = require('lodash');

/**
 * Create new base Mailer instance
 * @param {Object} _config Additional configuration
 * @constructor
 */
function BaseMailer(_config) {
  this._config = {};

  _.forOwn(_config, function (value, key) {
    this.set(key, value);
  }.bind(this));
}

/**
 * Get configuration value
 * @param {String} [path]
 * @returns {*}
 */
BaseMailer.prototype.get = function (path) {
  return typeof path === 'undefined' ? this._config : _.get(this._config, path);
};

/**
 * Set new configuration value
 * @param {String} path
 * @param {*} value
 * @returns {BaseMailer}
 */
BaseMailer.prototype.set = function (path, value) {
  _.set(this._config, path, value);
  return this;
};

/**
 * Returns transporter
 * @returns {*}
 */
BaseMailer.prototype.getTransporter = function () {
  return this._transporter;
};

/**
 * Set new transporter
 * @param transporter
 * @returns {BaseMailer}
 */
BaseMailer.prototype.setTransporter = function (transporter) {
  this._transporter = transporter;
  return this;
};

BaseMailer.prototype.send = _;

module.exports = BaseMailer;

import _ from 'lodash';

export default class BaseMailer {
  constructor(_config) {
    this._config = {};
    this._provider = {};

    _.assign(this._config, _config);
  }

  /**
   * Get configuration value
   * @param {String} [path]
   * @returns {*}
   */
  get(path) {
    return typeof path === 'undefined' ? this._config : _.get(this._config, path);
  }

  /**
   * Set new configuration value
   * @param {String} path
   * @param {*} value
   * @returns {BaseMailer}
   */
  set(path, value) {
    _.set(this._config, path, value);
    return this;
  }

  /**
   * Returns provider
   * @returns {*}
   */
  getProvider() {
    return this._provider;
  }

  /**
   * Set new provider
   * @param provider
   * @returns {BaseMailer}
   */
  setProvider(provider) {
    this._provider = provider;
    return this;
  }
}

Rewrite BaseMailer with ES6