-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathbasicdriver.js
More file actions
37 lines (33 loc) · 879 Bytes
/
basicdriver.js
File metadata and controls
37 lines (33 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const Driver = require('../models/driver');
const request = require('../lib/request');
const Ticker = require('../models/ticker');
/**
* Example of a minimal driver.
*
* @memberof Driver
* @augments Driver
*/
class BasicDriver extends Driver {
/**
* @augments Driver.fetchTickers
* @returns {Promise.Array<Ticker>} Returns a promise of an array with tickers.
*/
async fetchTickers() {
// Perform an API request to get the data of the exchange.
const data = await request('http://...');
// Return the data mapped to instances of the Ticker model, the exact way will differ for every
// exchange.
return data.map((item) => {
const {
base, quote, close, baseVolume,
} = item;
return new Ticker({
base,
quote,
close,
baseVolume,
});
});
}
}
module.exports = BasicDriver;