mirror of https://github.com/ENSL/ensl_gathers.git
Added hive client
This commit is contained in:
parent
87e0ad99b4
commit
ecd3702085
|
@ -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;
|
|
@ -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 () {
|
||||||
|
|
||||||
|
});
|
Loading…
Reference in New Issue