/**
 * @file Exports the Blizzard.js module.
 * @module lib/blizzard
 * @requires axios
 * @requires lib/endpoints
 * @requires lib/account
 * @requires lib/wow
 * @requires lib/sc2
 * @requires lib/d3
 */

const axios = require('axios');

const pkg = require('../package.json');
const endpoints = require('./endpoints');

const Account = require('./account');
const D3 = require('./d3');
const SC2 = require('./sc2');
const WoW = require('./wow');

/**
 * Blizzard.js class constructor.
 *
 * @constructor
 * @param  {Object} args       Blizzard.js configuration settings
 * @param  {Object} [instance] An [axios](https://github.com/mzabriskie/axios) compatible instance configuration
 * @return {Function}          Blizzard.js constructor function
 */
const Blizzard = function Blizzard (args, instance) {
  this.version = pkg.version;

  const defaultEndpoint = endpoints.getEndpoint(args.origin, args.locale);

  this.defaults = {
    origin: defaultEndpoint.origin,
    params: {
      apikey: args.apikey,
      access_token: args.access_token,
      locale: defaultEndpoint.locale,
    },
  };

  this.instance = Object.assign(
    {},
    instance,
    {
      headers: {
        'User-Agent': 'Node.js/' + process.version + ' Blizzard.js/' + this.version,
      },
    }
  );

  this.axios = axios.create(this.instance);

  /**
   * Account API methods
   *
   * @member {Object}
   * @see {@link lib/account}
   */
  this.account = new Account(this);

  /**
  * Diablo 3 API methods
  *
  * @member {Object}
  * @see {@link lib/d3}
  */
  this.d3 = new D3(this);

  /**
   * Starcraft 2 API methods
   *
   * @member {Object}
   * @see {@link lib/sc2}
   */
  this.sc2 = new SC2(this);

  /**
  * World of Warcraft API methods
  *
  * @member {Object}
  * @see {@link lib/wow}
  */
  this.wow = new WoW(this);

};

/**
 * Get a URL friendly battletag.
 *
 * @param  {String} tag A user battletag "tag#1234"
 * @return {String}     A safe battletag "tag-1234"
 */
Blizzard.prototype.battletag = function battletag (tag) {
  return tag.replace('#', '-');
};

/**
 * Filter an objects keys from an array of keys.
 *
 * @param  {Array} keys A list of keys to be returned
 * @param  {Object} obj An object that may contain <code>keys</code>
 * @return {Object}     A new object containing <code>keys</code>
 */
Blizzard.prototype.params = function params (keys, obj) {
  return Object.keys(obj)
    .filter(key => keys.indexOf(key) !== -1)
    .reduce((value, key) => Object.assign(value, { [key]: obj[key] }), {});
};

/**
 * Perform a single request to the Blizzard API.
 *
 * @param  {String} path          The pathname of the API resource
 * @param  {Object} args          API request parameters
 * @param  {String} [args.origin] The region key
 * @param  {String} [args.locale] A locale code for this region
 * @param  {Object} [instance]    An [axios](https://github.com/mzabriskie/axios) compatible instance configuration
 * @return {Promise}              A theneable Promises/A+ reference
 */
Blizzard.prototype.get = function get (path, args, instance) {
  const config = Object.assign({}, args);
  const apikey = this.params(['apikey'], config);
  const access_token = this.params(['access_token'], config);
  const endpoint = endpoints.getEndpoint(config.origin, config.locale || this.defaults.params.locale);
  const params = Object.assign({}, this.defaults.params, config.params, apikey, access_token, { locale: endpoint.locale });
  const obj = Object.assign({}, this.instance, instance, { params });

  return this.axios.get(`${endpoint.hostname}${encodeURI(path)}`, obj);
};

/**
 * Perform multiple requests to the Blizzard API.
 *
 * @param  {Array} requests A list of Blizzard get requests
 * @return {Promise}        A theneable Promises/A+ reference
 */
Blizzard.prototype.all = function all (requests) {
  return axios.all(requests);
};

module.exports = Blizzard;

@@ -361,16 +361,21 @@
 %0Aconst D
+iablo
 3 = requ
@@ -394,17 +394,24 @@
 %0Aconst S
-C
+tarcraft
 2 = requ
@@ -432,17 +432,29 @@
 const Wo
-W
+rldOfWarcraft
  = requi
@@ -1370,32 +1370,33 @@
 ount API methods
+.
 %0A   *%0A   * @memb
@@ -1502,32 +1502,33 @@
 lo 3 API methods
+.
 %0A  *%0A  * @member
@@ -1583,16 +1583,21 @@
  = new D
+iablo
 3(this);
@@ -1632,16 +1632,17 @@
  methods
+.
 %0A   *%0A  
@@ -1715,9 +1715,16 @@
 ew S
-C
+tarcraft
 2(th
@@ -1768,16 +1768,17 @@
  methods
+.
 %0A  *%0A  *
@@ -1844,17 +1844,29 @@
 = new Wo
-W
+rldOfWarcraft
 (this);%0A
@@ -3011,33 +3011,32 @@
           A then
-e
 able Promises/A+
@@ -3792,17 +3792,16 @@
   A then
-e
 able Pro
@@ -3883,16 +3883,21 @@
  return 
+this.
 axios.al

Update API method constructors and comments