Remove the old custom ticker
This commit is contained in:
parent
bce0ca4fcd
commit
cf19be3693
1 changed files with 0 additions and 45 deletions
|
|
@ -1,45 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
// TODO: refactor this with bitpay_ticker.js
|
|
||||||
|
|
||||||
var https = require('https');
|
|
||||||
var _ = require('underscore');
|
|
||||||
|
|
||||||
var CustomTicker = function(config) {
|
|
||||||
this.config = config;
|
|
||||||
};
|
|
||||||
|
|
||||||
CustomTicker.factory = function factory(config) {
|
|
||||||
return new CustomTicker(config);
|
|
||||||
};
|
|
||||||
|
|
||||||
CustomTicker.prototype.ticker = function ticker(currency, cb) {
|
|
||||||
var self = this;
|
|
||||||
https.get(this.config.uri, function(res) {
|
|
||||||
var buf = '';
|
|
||||||
res.setEncoding('utf8');
|
|
||||||
res.on('data', function(chunk) {
|
|
||||||
buf += chunk;
|
|
||||||
})
|
|
||||||
.on('end', function() {
|
|
||||||
var json = null;
|
|
||||||
try {
|
|
||||||
json = JSON.parse(buf);
|
|
||||||
} catch(e) {
|
|
||||||
cb(new Error('Couldn\'t parse JSON response'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var rec = _.findWhere(json, {code: currency});
|
|
||||||
|
|
||||||
if (!rec) {
|
|
||||||
cb(new Error('Currency not listed: ' + currency));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
cb(null, rec.rate);
|
|
||||||
});
|
|
||||||
}).on('error', function(e) {
|
|
||||||
cb(e);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = CustomTicker;
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue