-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d24385a
commit eebd3a1
Showing
7 changed files
with
124 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |