Small fixes on CoinGecko-Node

This commit is contained in:
Jan Oberhauser 2020-10-06 10:19:28 +02:00
parent 6cede362e4
commit 4fdf255dc5
2 changed files with 60 additions and 18 deletions

View file

@ -113,6 +113,50 @@ export const coinFields = [
placeholder: 'bitcoin', placeholder: 'bitcoin',
description: 'Coin ID', description: 'Coin ID',
}, },
{
displayName: 'Base Currency',
name: 'baseCurrency',
required: true,
type: 'options',
typeOptions: {
loadOptionsMethod: 'getCoins',
},
displayOptions: {
show: {
operation: [
'candlestick',
],
resource: [
'coin',
],
},
},
default: '',
description: 'The first currency in the pair. For BTC:ETH this is BTC.',
},
{
displayName: 'Base Currency',
name: 'baseCurrency',
required: true,
type: 'options',
typeOptions: {
loadOptionsMethod: 'getCurrencies',
},
displayOptions: {
show: {
operation: [
'market',
],
resource: [
'coin',
],
},
},
default: '',
description: 'The first currency in the pair. For BTC:ETH this is BTC.',
},
{ {
displayName: 'Coin ID', displayName: 'Coin ID',
name: 'coinId', name: 'coinId',
@ -126,7 +170,6 @@ export const coinFields = [
operation: [ operation: [
'ticker', 'ticker',
'history', 'history',
'candlestick',
], ],
resource: [ resource: [
'coin', 'coin',
@ -138,8 +181,8 @@ export const coinFields = [
description: 'Coin ID', description: 'Coin ID',
}, },
{ {
displayName: 'Coin IDs', displayName: 'Base Currencies',
name: 'coinIds', name: 'baseCurrencies',
required: true, required: true,
type: 'multiOptions', type: 'multiOptions',
typeOptions: { typeOptions: {
@ -160,7 +203,7 @@ export const coinFields = [
}, },
default: [], default: [],
placeholder: 'bitcoin', placeholder: 'bitcoin',
description: 'ID of coins, comma-separated. Refers to Coin / GetAll.', description: 'The first currency in the pair. For BTC:ETH this is BTC.',
}, },
{ {
displayName: 'Platform ID', displayName: 'Platform ID',
@ -272,9 +315,8 @@ export const coinFields = [
displayOptions: { displayOptions: {
show: { show: {
operation: [ operation: [
'market',
'marketChart',
'candlestick', 'candlestick',
'marketChart',
], ],
resource: [ resource: [
'coin', 'coin',
@ -285,8 +327,8 @@ export const coinFields = [
description: 'The second currency in the pair. For BTC:ETH this is ETH.', description: 'The second currency in the pair. For BTC:ETH this is ETH.',
}, },
{ {
displayName: 'Currencies', displayName: 'Quote Currencies',
name: 'currencies', name: 'quoteCurrencies',
type: 'multiOptions', type: 'multiOptions',
typeOptions: { typeOptions: {
loadOptionsMethod: 'getCurrencies', loadOptionsMethod: 'getCurrencies',
@ -303,10 +345,10 @@ export const coinFields = [
}, },
}, },
default: [], default: [],
description: 'Currencies of coin.', description: 'The second currency in the pair. For BTC:ETH this is ETH.',
}, },
{ {
displayName: 'Historical Range (days)', displayName: 'Range (days)',
name: 'days', name: 'days',
required: true, required: true,
type: 'options', type: 'options',

View file

@ -238,10 +238,10 @@ export class CoinGecko implements INodeType {
if (operation === 'market') { if (operation === 'market') {
const returnAll = this.getNodeParameter('returnAll', i) as boolean; const returnAll = this.getNodeParameter('returnAll', i) as boolean;
const quoteCurrency = this.getNodeParameter('quoteCurrency', i) as string; const baseCurrency = this.getNodeParameter('baseCurrency', i) as string;
const options = this.getNodeParameter('options', i) as IDataObject; const options = this.getNodeParameter('options', i) as IDataObject;
qs.vs_currency = quoteCurrency; qs.vs_currency = baseCurrency;
Object.assign(qs, options); Object.assign(qs, options);
@ -278,17 +278,17 @@ export class CoinGecko implements INodeType {
if (operation === 'price') { if (operation === 'price') {
const searchBy = this.getNodeParameter('searchBy', i) as string; const searchBy = this.getNodeParameter('searchBy', i) as string;
const currencies = this.getNodeParameter('currencies', i) as string[]; const quoteCurrencies = this.getNodeParameter('quoteCurrencies', i) as string[];
const options = this.getNodeParameter('options', i) as IDataObject; const options = this.getNodeParameter('options', i) as IDataObject;
qs.vs_currencies = currencies.join(','); qs.vs_currencies = quoteCurrencies.join(',');
Object.assign(qs, options); Object.assign(qs, options);
if (searchBy === 'coinId') { if (searchBy === 'coinId') {
const coinIds = this.getNodeParameter('coinIds', i) as string[]; const baseCurrencies = this.getNodeParameter('baseCurrencies', i) as string[];
qs.ids = coinIds.join(','); qs.ids = baseCurrencies.join(',');
responseData = await coinGeckoApiRequest.call( responseData = await coinGeckoApiRequest.call(
this, this,
@ -424,7 +424,7 @@ export class CoinGecko implements INodeType {
//https://www.coingecko.com/api/documentations/v3#/coins/get_coins__id__ohlc //https://www.coingecko.com/api/documentations/v3#/coins/get_coins__id__ohlc
if (operation === 'candlestick') { if (operation === 'candlestick') {
const coinId = this.getNodeParameter('coinId', i) as string; const baseCurrency = this.getNodeParameter('baseCurrency', i) as string;
const quoteCurrency = this.getNodeParameter('quoteCurrency', i) as string; const quoteCurrency = this.getNodeParameter('quoteCurrency', i) as string;
const days = this.getNodeParameter('days', i) as string; const days = this.getNodeParameter('days', i) as string;
@ -434,7 +434,7 @@ export class CoinGecko implements INodeType {
responseData = await coinGeckoApiRequest.call( responseData = await coinGeckoApiRequest.call(
this, this,
'GET', 'GET',
`/coins/${coinId}/ohlc`, `/coins/${baseCurrency}/ohlc`,
{}, {},
qs qs
); );