ensl_gathers/lib/hive/client.js

27 lines
674 B
JavaScript
Raw Normal View History

2015-08-31 14:30:33 +00:00
"use strict";
2016-11-14 15:08:16 +00:00
const path = require("path");
const request = require("request");
const logger = require("winston");
const querystring = require('querystring');
const config = require(path.join(__dirname, "../../config/config"));
2015-08-31 14:30:33 +00:00
function HiveClient (options) {
if (!(this instanceof HiveClient)) {
return new HiveClient(options);
}
this.baseUrl = config.hive_url;
}
2015-09-25 21:23:30 +00:00
HiveClient.prototype.getUserStats = function (user, callback) {
2015-08-31 14:30:33 +00:00
if (!user || !user.hive.id) {
return callback(new Error("Invalid user instance supplied"));
}
return request({
2016-11-14 15:08:16 +00:00
url: `${this.baseUrl}api/get/playerData/${user.hive.id}`,
2015-08-31 14:30:33 +00:00
json: true
}, callback);
};
module.exports = HiveClient;