Skip to content

Commit

Permalink
2.0 preparations
Browse files Browse the repository at this point in the history
  • Loading branch information
anastasov-menasoft committed Jul 25, 2019
1 parent d24385a commit eebd3a1
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 68 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -871,19 +871,19 @@ It will print similar to the following:
### Exchanges - Services/Methods


| ExchangeRatesService | MetadataService | OHLCVService | TradesService |
| -------------------- | ------------------ | -------------- | ------------------------------------------ |
| getSpecificRate | listAllExchanges | listAllPeriods | getLatestData |
| getAllCurrentRates | getExchangeDetails | latestData | getLatestDataBySymbol |
| | listAllAssets | historicalData | getLatestDataByExchange |
| | listAllSymbols | | getLatestDataByAsset |
| | getSymbolDetails | | getLatestDataByAssetsPair |
| | | | getLatestDataByExchangeAssetsPair |
| | | | tradesGetHistoricalData |
| | | | tradesGetHistoricalDataByExchange |
| | | | tradesGetHistoricalDataByAsset |
| | | | tradesGetHistoricalDataByAssetPair |
| | | | tradesGetHistoricalDataByExchangeAssetPair |
| Base | ExchangeRatesService | MetadataService | OHLCVService | TradesService |
| ------------------ | -------------------- | ---------------- | -------------- | ------------------------------------------ |
| listAllExchanges | getSpecificRate | listAllExchanges | listAllPeriods | getLatestData |
| getExchangeDetails | getAllCurrentRates | listAllAssets | latestData | getLatestDataBySymbol |
| listAllAssets | | listAllSymbols | historicalData | getLatestDataByExchange |
| getAssetDetails | | | | getLatestDataByAsset |
| getSymbolDetails | | | | getLatestDataByAssetsPair |
| | | | | getLatestDataByExchangeAssetsPair |
| | | | | tradesGetHistoricalData |
| | | | | tradesGetHistoricalDataByExchange |
| | | | | tradesGetHistoricalDataByAsset |
| | | | | tradesGetHistoricalDataByAssetPair |
| | | | | tradesGetHistoricalDataByExchangeAssetPair |


### Ethereum - Services/Methods
Expand Down
79 changes: 79 additions & 0 deletions src/rest-apis/crypto-market-data/base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
const BaseAuth = require('../../common/base-auth');

class Base extends BaseAuth {

/**
* List All Exchanges
*
* @async
* @desc Get a detailed list of all supported exchanges provided by our system.
*
* @param {number} [skip=0] - The offset of items to start from. Useful for paginations. (e.g. skip=100 would show results from 101 item to 150).
* @param {number} [limit=50] - Amount of items to return (optional, default value is 50).
*
* @returns {*}
*/
listAllExchanges(skip = 0, limit = 50) {
return this.request.get('/exchanges?skip=' + skip + '&limit=' + limit);
}

/**
* Get Exchange details
*
* @async
* @desc Get a detailed information for a single supported exchange provided by our system by ID.
*
* @param {string} exchangeId - Our identifier (UID) of the exchange. (_id attribute from exchanges endpoint).
*
* @returns {*}
*/
getExchangeDetails(exchangeId) {
return this.request.get('/exchanges/' + exchangeId);
}

/**
* List All Assets
*
* @async
* @desc Get detailed list of all associated assets.
*
* @param {number} [skip=0] - The offset of items to start from. Useful for paginations. (e.g. skip=100 would show results from 101 item to 150).
* @param {number} [limit=50] - Amount of items to return (optional, default value is 50).
*
* @returns {*}
*/
listAllAssets(skip = 0, limit = 50) {
return this.request.get('/assets?skip=' + skip + '&limit=' + limit);
}

/**
* Get Asset details
*
* @async
* @desc Get detailed information for a specific asset.
*
* @param {string} assetId - Our identifier (UID) of the asset. (_id attribute from assets endpoint).
*
* @returns {*}
*/
getAssetDetails(assetId) {
return this.request.get('/assets/' + assetId);
}

/**
* Get symbol details
*
* @async
* @desc Get a detailed information for a specific symbol mapping.
*
* @param {string} symbolId - Symbol identifier used to filter response. (_id attribute from symbols endpoint).
*
* @returns {*}
*/
getSymbolDetails(symbolId) {
return this.request.get('/mappings/' + symbolId);
}

}

module.exports = Base;
2 changes: 2 additions & 0 deletions src/rest-apis/crypto-market-data/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
var Base = require('./base');
var ExchangeRates = require('./exchange-rates');
var Meta = require('./meta');
var OHLCV = require('./ohlcv');
Expand All @@ -6,6 +7,7 @@ var Trades = require('./trades');
class CryptoMarketData {

constructor(...props) {
this.base = new Base(...props);
this.exchangeRates = new ExchangeRates(...props);
this.meta = new Meta(...props);
this.OHLCV = new OHLCV(...props);
Expand Down
46 changes: 2 additions & 44 deletions src/rest-apis/crypto-market-data/meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,7 @@ class Meta extends BaseAuth {
* @returns {*}
*/
listAllExchanges(skip = 0, limit = 50) {
return this.request.get('/exchanges?skip=' + skip + '&limit=' + limit);
}

/**
* Get Exchange details
*
* @async
* @desc Get a detailed information for a single supported exchange provided by our system by ID.
*
* @param {string} exchangeId - Our identifier (UID) of the exchange. (_id attribute from exchanges endpoint).
*
* @returns {*}
*/
getExchangeDetails(exchangeId) {
return this.request.get('/exchanges/' + exchangeId);
return this.request.get('/exchanges/meta?skip=' + skip + '&limit=' + limit);
}

/**
Expand All @@ -43,21 +29,7 @@ class Meta extends BaseAuth {
* @returns {*}
*/
listAllAssets(skip = 0, limit = 50) {
return this.request.get('/assets?skip=' + skip + '&limit=' + limit);
}

/**
* Get Asset details
*
* @async
* @desc Get detailed information for a specific asset.
*
* @param {string} assetId - Our identifier (UID) of the asset. (_id attribute from assets endpoint).
*
* @returns {*}
*/
getAssetDetails(assetId) {
return this.request.get('/assets/' + assetId);
return this.request.get('/assets/meta?skip=' + skip + '&limit=' + limit);
}

/**
Expand All @@ -75,20 +47,6 @@ class Meta extends BaseAuth {
return this.request.get('/mappings?skip=' + skip + '&limit=' + limit);
}

/**
* Get symbol details
*
* @async
* @desc Get a detailed information for a specific symbol mapping.
*
* @param {string} symbolId - Symbol identifier used to filter response. (_id attribute from symbols endpoint).
*
* @returns {*}
*/
getSymbolDetails(symbolId) {
return this.request.get('/mappings/' + symbolId);
}

}

module.exports = Meta;
23 changes: 23 additions & 0 deletions tests/rest-apis/crypto-market-data/base.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
async function Base(caClient) {
console.log('\n::CMD Base');

const exchanges = await caClient.CMD.base.listAllExchanges().then(response => response.payload);
if (exchanges && exchanges.length) {
const exchangeId = exchanges[0]._id;
await caClient.CMD.base.getExchangeDetails(exchangeId);
}

const assets = await caClient.CMD.base.listAllAssets().then(response => response.payload);
if (assets && assets.length) {
const assetsId = assets[0]._id;
await caClient.CMD.base.getAssetDetails(assetsId);
}

const symbols = await caClient.CMD.meta.listAllSymbols().then(response => response.payload); // Duplicated in meta but needed for scenario
if (symbols && symbols.length) {
const symbolId = symbols[0]._id;
await caClient.CMD.base.getSymbolDetails(symbolId);
}
}

module.exports = Base;
2 changes: 2 additions & 0 deletions tests/rest-apis/crypto-market-data/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const Base = require('./base.test');
const Meta = require('./meta.test');
const OHLCV = require('./ohlcv.test');
const Trades = require('./trades.test');

async function CMD(caClient) {
console.log('\n::Crypto market data');

await Base(caClient);
await Meta(caClient);
await OHLCV(caClient);
await Trades(caClient);
Expand Down
14 changes: 3 additions & 11 deletions tests/rest-apis/crypto-market-data/meta.test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
async function Meta(caClient) {
console.log('\n::CMD Meta');

const exchanges = await caClient.CMD.meta.listAllExchanges().then(response => response.payload);
const exchangeId = exchanges[0]._id;
await caClient.CMD.meta.getExchangeDetails(exchangeId);

const assets = await caClient.CMD.meta.listAllAssets().then(response => response.payload);
const assetsId = assets[0]._id;
await caClient.CMD.meta.getAssetDetails(assetsId);

const symbols = await caClient.CMD.meta.listAllSymbols().then(response => response.payload);
const symbolId = symbols[0]._id;
await caClient.CMD.meta.getSymbolDetails(symbolId);
await caClient.CMD.meta.listAllExchanges().then(response => response.payload);
await caClient.CMD.meta.listAllAssets().then(response => response.payload);
await caClient.CMD.meta.listAllSymbols().then(response => response.payload);
}

module.exports = Meta;

0 comments on commit eebd3a1

Please sign in to comment.