Added hive client

This commit is contained in:
Chris Blanchard 2015-08-31 15:30:33 +01:00
parent 87e0ad99b4
commit ecd3702085
2 changed files with 41 additions and 0 deletions

30
lib/hive/client.js Normal file
View File

@ -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;

11
spec/hiveClient.js Normal file
View File

@ -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 () {
});