From c493f9e73c712cde07caac45d1032df8fe791f83 Mon Sep 17 00:00:00 2001 From: Momchil Date: Tue, 18 Feb 2020 16:34:51 +0200 Subject: [PATCH] #noticket exchange-rates missing method impl --- package-lock.json | 2 +- package.json | 2 +- .../crypto-market-data/exchange-rates.js | 44 +++++++++++++++++-- 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2e650d7..39ee481 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { "name": "cryptoapis.io", - "version": "4.2.2", + "version": "4.2.3", "lockfileVersion": 1 } diff --git a/package.json b/package.json index 482c938..f45b1a1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cryptoapis.io", - "version": "4.2.2", + "version": "4.2.3", "description": "Crypto APIs SDK", "main": "src/index.js", "scripts": { diff --git a/src/rest-apis/crypto-market-data/exchange-rates.js b/src/rest-apis/crypto-market-data/exchange-rates.js index 3e3b144..04a8b4a 100644 --- a/src/rest-apis/crypto-market-data/exchange-rates.js +++ b/src/rest-apis/crypto-market-data/exchange-rates.js @@ -27,7 +27,7 @@ class ExchangeRates extends BaseAuth { * Get All Current Rates * * @async - * @desc + * @desc Get the current exchange rate between requested asset and all other assets. * * @param {string} baseAssetId - Our identifier (UID) of the base asset. (_id attribute from assets endpoint). * @param {object} [queryParams] - Additional query parameters. @@ -45,12 +45,48 @@ class ExchangeRates extends BaseAuth { return this.request.get('/exchange-rates/' + baseAssetId, combinedQueryParams); } - getSpecificRateInSpecificExchange() { + /** + * Get Specific Rate in a specific Exchange + * + * @async + * @desc Get exchange rates between pair of requested assets pointing at a specific or current time in a specific Exchange. + * + * @param {string} exchangeId - Our exchange identifier. + * @param {string} baseAssetId - Our identifier (UID) of the base asset. (_id attribute from assets endpoint). + * @param {string} quoteAssetId - Our identifier (UID) of the quote asset. (_id attribute from assets endpoint). + * @param {object} [queryParams] - Additional query parameters. + * + * @returns {*} + */ + getSpecificRateInSpecificExchange(exchangeId, baseAssetId, quoteAssetId, queryParams = {}) { + const combinedQueryParams = { + timestamp: null, // Time (in UNIX Timestamp) of the market data used to calculate exchange rate. Optional. Default value is current time. + ...queryParams, + }; + return this.request.get('/exchange-rates/exchange/' + exchangeId + '/' + baseAssetId + '/' + quoteAssetId, combinedQueryParams); } - getAllCurrentRatesInSpecificExchange() { - + /** + * Get All Current Rates in a specific Exchange + * + * @async + * @desc Get the current exchange rate between requested asset and all other assets in a specific Exchange. + * + * @param {string} exchangeId - Our exchange identifier. + * @param {string} baseAssetId - Our identifier (UID) of the base asset. (_id attribute from assets endpoint). + * @param {object} [queryParams] - Additional query parameters. + * + * @returns {*} + */ + getAllCurrentRatesInSpecificExchange(exchangeId, baseAssetId, queryParams = {}) { + const combinedQueryParams = { + timestamp: null, // Time (in UNIX Timestamp) of the market data used to calculate exchange rate. Optional. Default value is current time. + skip: 0, // The offset of items to start from. Useful for paginations. (e.g. skip=100 would show results from 101 item to 150). + limit: 50, // Amount of items to return (optional, default value is 50). + ...queryParams, + }; + return this.request.get('/exchange-rates/exchange/' + exchangeId + '/' + baseAssetId, combinedQueryParams); } }