refactor: Format nodes-base package (A-F) (#3800)
* 🔨 prettier formated nodes - A * 🔨 prettier formated nodes - B * ⚡ prettier formated nodes - C * ⚡ prettier formated nodes - D * ⚡ prettier formated nodes - E-F * 🎨 Adjust nodes-base formatting command (#3805) * Format additional files in nodes A-F (#3811) * ⚡ fixes * 🎨 Add Mindee to ignored dirs Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const coinOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const coinOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'coin',
|
||||
],
|
||||
resource: ['coin'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -43,19 +39,22 @@ export const coinOperations: INodeProperties[] = [
|
||||
{
|
||||
name: 'Market',
|
||||
value: 'market',
|
||||
description: 'Get prices and market related data for all trading pairs that match the selected currency',
|
||||
description:
|
||||
'Get prices and market related data for all trading pairs that match the selected currency',
|
||||
action: 'Get market prices for a coin',
|
||||
},
|
||||
{
|
||||
name: 'Market Chart',
|
||||
value: 'marketChart',
|
||||
description: 'Get historical market data include price, market cap, and 24h volume (granularity auto)',
|
||||
description:
|
||||
'Get historical market data include price, market cap, and 24h volume (granularity auto)',
|
||||
action: 'Get market chart for a coin',
|
||||
},
|
||||
{
|
||||
name: 'Price',
|
||||
value: 'price',
|
||||
description: 'Get the current price of any cryptocurrencies in any other supported currencies that you need',
|
||||
description:
|
||||
'Get the current price of any cryptocurrencies in any other supported currencies that you need',
|
||||
action: 'Get the price for a coin',
|
||||
},
|
||||
{
|
||||
@@ -87,14 +86,8 @@ export const coinFields: INodeProperties[] = [
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'get',
|
||||
'marketChart',
|
||||
'price',
|
||||
],
|
||||
resource: [
|
||||
'coin',
|
||||
],
|
||||
operation: ['get', 'marketChart', 'price'],
|
||||
resource: ['coin'],
|
||||
},
|
||||
},
|
||||
default: 'coinId',
|
||||
@@ -105,18 +98,15 @@ export const coinFields: INodeProperties[] = [
|
||||
name: 'coinId',
|
||||
required: true,
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getCoins',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
resource: [
|
||||
'coin',
|
||||
],
|
||||
operation: ['get'],
|
||||
resource: ['coin'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -132,17 +122,13 @@ export const coinFields: INodeProperties[] = [
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
|
||||
operation: [
|
||||
'candlestick',
|
||||
],
|
||||
resource: [
|
||||
'coin',
|
||||
],
|
||||
operation: ['candlestick'],
|
||||
resource: ['coin'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The first currency in the pair. For BTC:ETH this is BTC. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'The first currency in the pair. For BTC:ETH this is BTC. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Base Currency Name or ID',
|
||||
@@ -154,36 +140,28 @@ export const coinFields: INodeProperties[] = [
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
|
||||
operation: [
|
||||
'market',
|
||||
],
|
||||
resource: [
|
||||
'coin',
|
||||
],
|
||||
operation: ['market'],
|
||||
resource: ['coin'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The first currency in the pair. For BTC:ETH this is BTC. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'The first currency in the pair. For BTC:ETH this is BTC. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Coin Name or ID',
|
||||
name: 'coinId',
|
||||
required: true,
|
||||
type: 'options',
|
||||
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getCoins',
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'ticker',
|
||||
'history',
|
||||
],
|
||||
resource: [
|
||||
'coin',
|
||||
],
|
||||
operation: ['ticker', 'history'],
|
||||
resource: ['coin'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -199,20 +177,15 @@ export const coinFields: INodeProperties[] = [
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'price',
|
||||
],
|
||||
resource: [
|
||||
'coin',
|
||||
],
|
||||
searchBy: [
|
||||
'coinId',
|
||||
],
|
||||
operation: ['price'],
|
||||
resource: ['coin'],
|
||||
searchBy: ['coinId'],
|
||||
},
|
||||
},
|
||||
default: [],
|
||||
placeholder: 'bitcoin',
|
||||
description: 'The first currency in the pair. For BTC:ETH this is BTC. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'The first currency in the pair. For BTC:ETH this is BTC. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Platform ID',
|
||||
@@ -220,17 +193,9 @@ export const coinFields: INodeProperties[] = [
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'get',
|
||||
'marketChart',
|
||||
'price',
|
||||
],
|
||||
resource: [
|
||||
'coin',
|
||||
],
|
||||
searchBy: [
|
||||
'contractAddress',
|
||||
],
|
||||
operation: ['get', 'marketChart', 'price'],
|
||||
resource: ['coin'],
|
||||
searchBy: ['contractAddress'],
|
||||
},
|
||||
},
|
||||
type: 'options',
|
||||
@@ -251,19 +216,12 @@ export const coinFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'get',
|
||||
'marketChart',
|
||||
],
|
||||
resource: [
|
||||
'coin',
|
||||
],
|
||||
searchBy: [
|
||||
'contractAddress',
|
||||
],
|
||||
operation: ['get', 'marketChart'],
|
||||
resource: ['coin'],
|
||||
searchBy: ['contractAddress'],
|
||||
},
|
||||
},
|
||||
description: 'Token\'s contract address',
|
||||
description: "Token's contract address",
|
||||
},
|
||||
{
|
||||
displayName: 'Contract Addresses',
|
||||
@@ -273,15 +231,9 @@ export const coinFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'price',
|
||||
],
|
||||
resource: [
|
||||
'coin',
|
||||
],
|
||||
searchBy: [
|
||||
'contractAddress',
|
||||
],
|
||||
operation: ['price'],
|
||||
resource: ['coin'],
|
||||
searchBy: ['contractAddress'],
|
||||
},
|
||||
},
|
||||
description: 'The contract address of tokens, comma-separated',
|
||||
@@ -296,24 +248,17 @@ export const coinFields: INodeProperties[] = [
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'marketChart',
|
||||
],
|
||||
resource: [
|
||||
'coin',
|
||||
],
|
||||
searchBy: [
|
||||
'coinId',
|
||||
],
|
||||
operation: ['marketChart'],
|
||||
resource: ['coin'],
|
||||
searchBy: ['coinId'],
|
||||
},
|
||||
hide: {
|
||||
searchBy: [
|
||||
'contractAddress',
|
||||
],
|
||||
searchBy: ['contractAddress'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The first currency in the pair. For BTC:ETH this is BTC. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'The first currency in the pair. For BTC:ETH this is BTC. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Quote Currency Name or ID',
|
||||
@@ -325,17 +270,13 @@ export const coinFields: INodeProperties[] = [
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'candlestick',
|
||||
'marketChart',
|
||||
],
|
||||
resource: [
|
||||
'coin',
|
||||
],
|
||||
operation: ['candlestick', 'marketChart'],
|
||||
resource: ['coin'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The second currency in the pair. For BTC:ETH this is ETH. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'The second currency in the pair. For BTC:ETH this is ETH. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Quote Currency Names or IDs',
|
||||
@@ -347,16 +288,13 @@ export const coinFields: INodeProperties[] = [
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'price',
|
||||
],
|
||||
resource: [
|
||||
'coin',
|
||||
],
|
||||
operation: ['price'],
|
||||
resource: ['coin'],
|
||||
},
|
||||
},
|
||||
default: [],
|
||||
description: 'The second currency in the pair. For BTC:ETH this is ETH. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'The second currency in the pair. For BTC:ETH this is ETH. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Range (Days)',
|
||||
@@ -400,13 +338,8 @@ export const coinFields: INodeProperties[] = [
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'marketChart',
|
||||
'candlestick',
|
||||
],
|
||||
resource: [
|
||||
'coin',
|
||||
],
|
||||
operation: ['marketChart', 'candlestick'],
|
||||
resource: ['coin'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -419,12 +352,8 @@ export const coinFields: INodeProperties[] = [
|
||||
type: 'dateTime',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'history',
|
||||
],
|
||||
resource: [
|
||||
'coin',
|
||||
],
|
||||
operation: ['history'],
|
||||
resource: ['coin'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -436,14 +365,8 @@ export const coinFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
'market',
|
||||
'ticker',
|
||||
],
|
||||
resource: [
|
||||
'coin',
|
||||
],
|
||||
operation: ['getAll', 'market', 'ticker'],
|
||||
resource: ['coin'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -455,17 +378,9 @@ export const coinFields: INodeProperties[] = [
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
'market',
|
||||
'ticker',
|
||||
],
|
||||
resource: [
|
||||
'coin',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
operation: ['getAll', 'market', 'ticker'],
|
||||
resource: ['coin'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
@@ -483,12 +398,8 @@ export const coinFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'coin',
|
||||
],
|
||||
operation: [
|
||||
'market',
|
||||
],
|
||||
resource: ['coin'],
|
||||
operation: ['market'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -609,12 +520,8 @@ export const coinFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'coin',
|
||||
],
|
||||
operation: [
|
||||
'price',
|
||||
],
|
||||
resource: ['coin'],
|
||||
operation: ['price'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -652,12 +559,8 @@ export const coinFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'coin',
|
||||
],
|
||||
operation: [
|
||||
'ticker',
|
||||
],
|
||||
resource: ['coin'],
|
||||
operation: ['ticker'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -669,7 +572,8 @@ export const coinFields: INodeProperties[] = [
|
||||
loadOptionsMethod: 'getExchanges',
|
||||
},
|
||||
default: [],
|
||||
description: 'Filter results by exchange IDs. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'Filter results by exchange IDs. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Include Exchange Logo',
|
||||
@@ -708,12 +612,8 @@ export const coinFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'coin',
|
||||
],
|
||||
operation: [
|
||||
'history',
|
||||
],
|
||||
resource: ['coin'],
|
||||
operation: ['history'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -734,12 +634,8 @@ export const coinFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'get',
|
||||
],
|
||||
resource: [
|
||||
'coin',
|
||||
],
|
||||
operation: ['get'],
|
||||
resource: ['coin'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
@@ -11,20 +9,11 @@ import {
|
||||
INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
coinFields,
|
||||
coinOperations,
|
||||
} from './CoinDescription';
|
||||
import { coinFields, coinOperations } from './CoinDescription';
|
||||
|
||||
import {
|
||||
eventFields,
|
||||
eventOperations,
|
||||
} from './EventDescription';
|
||||
import { eventFields, eventOperations } from './EventDescription';
|
||||
|
||||
import {
|
||||
coinGeckoApiRequest,
|
||||
coinGeckoRequestAllItems,
|
||||
} from './GenericFunctions';
|
||||
import { coinGeckoApiRequest, coinGeckoRequestAllItems } from './GenericFunctions';
|
||||
|
||||
import moment from 'moment-timezone';
|
||||
|
||||
@@ -88,11 +77,7 @@ export class CoinGecko implements INodeType {
|
||||
|
||||
async getCoins(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const coins = await coinGeckoApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'/coins/list',
|
||||
);
|
||||
const coins = await coinGeckoApiRequest.call(this, 'GET', '/coins/list');
|
||||
for (const coin of coins) {
|
||||
returnData.push({
|
||||
name: coin.symbol.toUpperCase(),
|
||||
@@ -100,8 +85,12 @@ export class CoinGecko implements INodeType {
|
||||
});
|
||||
}
|
||||
returnData.sort((a, b) => {
|
||||
if (a.name < b.name) { return -1; }
|
||||
if (a.name > b.name) { return 1; }
|
||||
if (a.name < b.name) {
|
||||
return -1;
|
||||
}
|
||||
if (a.name > b.name) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
return returnData;
|
||||
@@ -109,11 +98,7 @@ export class CoinGecko implements INodeType {
|
||||
|
||||
async getExchanges(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const exchanges = await coinGeckoApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'/exchanges/list',
|
||||
);
|
||||
const exchanges = await coinGeckoApiRequest.call(this, 'GET', '/exchanges/list');
|
||||
for (const exchange of exchanges) {
|
||||
returnData.push({
|
||||
name: exchange.name,
|
||||
@@ -125,11 +110,7 @@ export class CoinGecko implements INodeType {
|
||||
|
||||
async getEventCountryCodes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const countryCodes = await coinGeckoApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'/events/countries',
|
||||
);
|
||||
const countryCodes = await coinGeckoApiRequest.call(this, 'GET', '/events/countries');
|
||||
for (const code of countryCodes.data) {
|
||||
if (!code.code) {
|
||||
continue;
|
||||
@@ -144,11 +125,7 @@ export class CoinGecko implements INodeType {
|
||||
|
||||
async getEventTypes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const eventTypes = await coinGeckoApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'/events/types',
|
||||
);
|
||||
const eventTypes = await coinGeckoApiRequest.call(this, 'GET', '/events/types');
|
||||
for (const type of eventTypes.data) {
|
||||
returnData.push({
|
||||
name: type,
|
||||
@@ -174,7 +151,6 @@ export class CoinGecko implements INodeType {
|
||||
//https://www.coingecko.com/api/documentations/v3#/coins/get_coins__id_
|
||||
//https://www.coingecko.com/api/documentations/v3#/contract/get_coins__id__contract__contract_address_
|
||||
if (operation === 'get') {
|
||||
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
|
||||
qs.community_data = false;
|
||||
@@ -215,18 +191,11 @@ export class CoinGecko implements INodeType {
|
||||
}
|
||||
//https://www.coingecko.com/api/documentations/v3#/coins/get_coins_list
|
||||
if (operation === 'getAll') {
|
||||
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
|
||||
let limit;
|
||||
|
||||
responseData = await coinGeckoApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'/coins/list',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
responseData = await coinGeckoApiRequest.call(this, 'GET', '/coins/list', {}, qs);
|
||||
|
||||
if (returnAll === false) {
|
||||
limit = this.getNodeParameter('limit', i) as number;
|
||||
@@ -236,7 +205,6 @@ export class CoinGecko implements INodeType {
|
||||
|
||||
//https://www.coingecko.com/api/documentations/v3#/coins/get_coins_list
|
||||
if (operation === 'market') {
|
||||
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
const baseCurrency = this.getNodeParameter('baseCurrency', i) as string;
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
@@ -263,20 +231,13 @@ export class CoinGecko implements INodeType {
|
||||
|
||||
qs.per_page = limit;
|
||||
|
||||
responseData = await coinGeckoApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/coins/markets`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
responseData = await coinGeckoApiRequest.call(this, 'GET', `/coins/markets`, {}, qs);
|
||||
}
|
||||
}
|
||||
|
||||
//https://www.coingecko.com/api/documentations/v3#/simple/get_simple_price
|
||||
//https://www.coingecko.com/api/documentations/v3#/simple/get_simple_token_price__id_
|
||||
if (operation === 'price') {
|
||||
|
||||
const searchBy = this.getNodeParameter('searchBy', i) as string;
|
||||
const quoteCurrencies = this.getNodeParameter('quoteCurrencies', i) as string[];
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
@@ -290,13 +251,7 @@ export class CoinGecko implements INodeType {
|
||||
|
||||
qs.ids = baseCurrencies.join(',');
|
||||
|
||||
responseData = await coinGeckoApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'/simple/price',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
responseData = await coinGeckoApiRequest.call(this, 'GET', '/simple/price', {}, qs);
|
||||
}
|
||||
|
||||
if (searchBy === 'contractAddress') {
|
||||
@@ -317,7 +272,6 @@ export class CoinGecko implements INodeType {
|
||||
|
||||
//https://www.coingecko.com/api/documentations/v3#/coins/get_coins__id__tickers
|
||||
if (operation === 'ticker') {
|
||||
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
const coinId = this.getNodeParameter('coinId', i) as string;
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
@@ -329,7 +283,6 @@ export class CoinGecko implements INodeType {
|
||||
}
|
||||
|
||||
if (returnAll) {
|
||||
|
||||
responseData = await coinGeckoRequestAllItems.call(
|
||||
this,
|
||||
'tickers',
|
||||
@@ -356,7 +309,6 @@ export class CoinGecko implements INodeType {
|
||||
|
||||
//https://www.coingecko.com/api/documentations/v3#/coins/get_coins__id__history
|
||||
if (operation === 'history') {
|
||||
|
||||
const coinId = this.getNodeParameter('coinId', i) as string;
|
||||
const date = this.getNodeParameter('date', i) as string;
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
@@ -377,7 +329,6 @@ export class CoinGecko implements INodeType {
|
||||
//https://www.coingecko.com/api/documentations/v3#/coins/get_coins__id__market_chart
|
||||
//https://www.coingecko.com/api/documentations/v3#/contract/get_coins__id__contract__contract_address__market_chart_
|
||||
if (operation === 'marketChart') {
|
||||
|
||||
let respData;
|
||||
|
||||
const searchBy = this.getNodeParameter('searchBy', i) as string;
|
||||
@@ -417,13 +368,17 @@ export class CoinGecko implements INodeType {
|
||||
const [time, price] = respData.prices[idx];
|
||||
const marketCaps = respData.market_caps[idx][1];
|
||||
const totalVolume = respData.total_volumes[idx][1];
|
||||
responseData.push({ time: moment(time).toISOString(), price, marketCaps, totalVolume } as IDataObject);
|
||||
responseData.push({
|
||||
time: moment(time).toISOString(),
|
||||
price,
|
||||
marketCaps,
|
||||
totalVolume,
|
||||
} as IDataObject);
|
||||
}
|
||||
}
|
||||
|
||||
//https://www.coingecko.com/api/documentations/v3#/coins/get_coins__id__ohlc
|
||||
if (operation === 'candlestick') {
|
||||
|
||||
const baseCurrency = this.getNodeParameter('baseCurrency', i) as string;
|
||||
const quoteCurrency = this.getNodeParameter('quoteCurrency', i) as string;
|
||||
const days = this.getNodeParameter('days', i) as string;
|
||||
@@ -441,7 +396,13 @@ export class CoinGecko implements INodeType {
|
||||
|
||||
for (let idx = 0; idx < responseData.length; idx++) {
|
||||
const [time, open, high, low, close] = responseData[idx];
|
||||
responseData[idx] = { time: moment(time).toISOString(), open, high, low, close } as IDataObject;
|
||||
responseData[idx] = {
|
||||
time: moment(time).toISOString(),
|
||||
open,
|
||||
high,
|
||||
low,
|
||||
close,
|
||||
} as IDataObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -449,7 +410,6 @@ export class CoinGecko implements INodeType {
|
||||
if (resource === 'event') {
|
||||
//https://www.coingecko.com/api/documentations/v3#/events/get_events
|
||||
if (operation === 'getAll') {
|
||||
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
|
||||
@@ -469,13 +429,7 @@ export class CoinGecko implements INodeType {
|
||||
|
||||
qs.per_page = limit;
|
||||
|
||||
responseData = await coinGeckoApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'/events',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
responseData = await coinGeckoApiRequest.call(this, 'GET', '/events', {}, qs);
|
||||
responseData = responseData.data;
|
||||
}
|
||||
}
|
||||
@@ -484,28 +438,19 @@ export class CoinGecko implements INodeType {
|
||||
if (resource === 'simple') {
|
||||
//https://www.coingecko.com/api/documentations/v3#/simple/get_simple_price
|
||||
if (operation === 'price') {
|
||||
|
||||
const ids = this.getNodeParameter('ids', i) as string;
|
||||
const currencies = this.getNodeParameter('currencies', i) as string[];
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
|
||||
qs.ids = ids,
|
||||
qs.vs_currencies = currencies.join(',');
|
||||
(qs.ids = ids), (qs.vs_currencies = currencies.join(','));
|
||||
|
||||
Object.assign(qs, options);
|
||||
|
||||
responseData = await coinGeckoApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'/simple/price',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
responseData = await coinGeckoApiRequest.call(this, 'GET', '/simple/price', {}, qs);
|
||||
}
|
||||
|
||||
//https://www.coingecko.com/api/documentations/v3#/simple/get_simple_token_price__id_
|
||||
if (operation === 'tokenPrice') {
|
||||
|
||||
const id = this.getNodeParameter('id', i) as string;
|
||||
const contractAddresses = this.getNodeParameter('contractAddresses', i) as string;
|
||||
const currencies = this.getNodeParameter('currencies', i) as string[];
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const eventOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const eventOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'event',
|
||||
],
|
||||
resource: ['event'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -34,12 +30,8 @@ export const eventFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'event',
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['event'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -51,15 +43,9 @@ export const eventFields: INodeProperties[] = [
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'event',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['event'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
@@ -77,12 +63,8 @@ export const eventFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'event',
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['event'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -95,7 +77,8 @@ export const eventFields: INodeProperties[] = [
|
||||
loadOptionsMethod: 'getEventCountryCodes',
|
||||
},
|
||||
default: '',
|
||||
description: 'Country code of event. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'Country code of event. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'From Date',
|
||||
@@ -119,7 +102,8 @@ export const eventFields: INodeProperties[] = [
|
||||
loadOptionsMethod: 'getEventTypes',
|
||||
},
|
||||
default: '',
|
||||
description: 'Type of event. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'Type of event. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Upcoming Events Only',
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
import {
|
||||
OptionsWithUri,
|
||||
} from 'request';
|
||||
import { OptionsWithUri } from 'request';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
IExecuteSingleFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject, NodeApiError,
|
||||
} from 'n8n-workflow';
|
||||
import { IDataObject, NodeApiError } from 'n8n-workflow';
|
||||
|
||||
export async function coinGeckoApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string,
|
||||
endpoint: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
export async function coinGeckoApiRequest(
|
||||
this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions,
|
||||
method: string,
|
||||
endpoint: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
qs: IDataObject = {},
|
||||
uri?: string,
|
||||
option: IDataObject = {},
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
let options: OptionsWithUri = {
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
method,
|
||||
@@ -35,14 +36,21 @@ export async function coinGeckoApiRequest(this: IExecuteFunctions | IExecuteSing
|
||||
|
||||
//@ts-ignore
|
||||
return await this.helpers.request.call(this, options);
|
||||
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
}
|
||||
|
||||
export async function coinGeckoRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
export async function coinGeckoRequestAllItems(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
propertyName: string,
|
||||
method: string,
|
||||
endpoint: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
body: any = {},
|
||||
query: IDataObject = {},
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
@@ -58,9 +66,7 @@ export async function coinGeckoRequestAllItems(this: IExecuteFunctions | ILoadOp
|
||||
respData = responseData[propertyName];
|
||||
}
|
||||
returnData.push.apply(returnData, respData);
|
||||
} while (
|
||||
respData.length !== 0
|
||||
);
|
||||
} while (respData.length !== 0);
|
||||
|
||||
return returnData;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user