From ecd3702085ebea844ea27ab3cc115622f7dc86b3 Mon Sep 17 00:00:00 2001 From: Chris Blanchard Date: Mon, 31 Aug 2015 15:30:33 +0100 Subject: [PATCH] Added hive client --- lib/hive/client.js | 30 ++++++++++++++++++++++++++++++ spec/hiveClient.js | 11 +++++++++++ 2 files changed, 41 insertions(+) create mode 100644 lib/hive/client.js create mode 100644 spec/hiveClient.js diff --git a/lib/hive/client.js b/lib/hive/client.js new file mode 100644 index 0000000..88b2f39 --- /dev/null +++ b/lib/hive/client.js @@ -0,0 +1,30 @@ +"use strict"; + +var path = require("path"); +var request = require("request"); +var logger = require("winston"); +var querystring = require('querystring'); +var config = require(path.join(__dirname, "../../config/config")); + +function HiveClient (options) { + if (!(this instanceof HiveClient)) { + return new HiveClient(options); + } + + this.baseUrl = config.hive_url; +} + +HiveClient.prototype.getUserStats = (user, callback) => { + if (!user || !user.hive.id) { + return callback(new Error("Invalid user instance supplied")); + } + + var id = user.hive.id; + var url = this.baseUrl + "api/get/playerData/" + id; + return request({ + url: url, + json: true + }, callback); +}; + +module.exports = HiveClient; diff --git a/spec/hiveClient.js b/spec/hiveClient.js new file mode 100644 index 0000000..2a0c8ce --- /dev/null +++ b/spec/hiveClient.js @@ -0,0 +1,11 @@ +"use strict"; + +var helper = require("./helpers/index.js"); +var HiveClient = helper.HiveClient; +var assert = require("chai").assert; +var fs = require("fs"); +var path = require("path"); + +describe("ENSL Client", function () { + +}); \ No newline at end of file