UNPKG

n8n-ikaue-nodes

Version:

IKAUE nodes for N8N, such as a custom BigQuery node or a Google Search Console node.

172 lines 6.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GoogleSearchConsole = void 0; const GenericFunctions_1 = require("./GenericFunctions"); class GoogleSearchConsole { constructor() { this.description = { displayName: 'Google Search Console ', name: 'googleSearchConsole', icon: 'file:googleSearchConsole.svg', group: ['input', 'output'], version: 1, subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', description: 'Get stuff from google search console', defaults: { name: 'Google Search Console', color: '#0aa55c', }, inputs: ['main'], outputs: ['main'], credentials: [ { name: 'googleApi', required: true, displayOptions: { show: { authentication: [ 'serviceAccount', ], }, }, testedBy: 'googleApiCredentialTest', }, { name: 'googleSearchConsoleOAuth2Api', required: true, displayOptions: { show: { authentication: [ 'oAuth2', ], }, }, }, ], properties: [ { displayName: 'Authentication', name: 'authentication', type: 'options', options: [ { name: 'Service Account', value: 'serviceAccount', }, { name: 'OAuth2', value: 'oAuth2', }, ], default: 'serviceAccount', }, { displayName: 'Resource', name: 'resource', type: 'options', options: [ { name: 'Search Analytics', value: 'searchAnalytics', }, { name: 'Sitemaps', value: 'sitemaps', }, ], default: 'searchAnalytics', description: 'The resource to perform operation on.', }, { displayName: 'Operation', name: 'operation', type: 'options', displayOptions: { show: { resource: [ 'searchAnalytics', ], }, }, options: [ { name: 'Post', value: 'post', description: 'Post query', }, ], default: 'post', description: 'The operation to perform.', }, { displayName: 'Site URL', name: 'siteUrl', type: 'string', displayOptions: { show: { resource: [ 'searchAnalytics', ], }, }, default: '', required: true, description: 'The site URL (e.g. https://blog.ikhuerta.com/)', }, { displayName: 'Start date', name: 'startDate', type: 'string', displayOptions: { show: { resource: [ 'searchAnalytics', ], }, }, default: '', required: true, description: 'Start date of the extraction (YYYY-MM-DD format)', }, { displayName: 'End date', name: 'endDate', type: 'string', displayOptions: { show: { resource: [ 'searchAnalytics', ], }, }, default: '', required: true, description: 'End date of the extraction (YYYY-MM-DD format)', }, ], }; } async execute() { let responseData; const resource = this.getNodeParameter('resource', 0); const operation = this.getNodeParameter('operation', 0); if (resource === 'searchAnalytics') { if (operation === 'post') { const url = this.getNodeParameter('siteUrl', 0); const startDate = this.getNodeParameter('startDate', 0); const endDate = this.getNodeParameter('endDate', 0); const additionalFields = { startDate, endDate, dimensions: 'page' }; const data = {}; Object.assign(data, additionalFields); responseData = await GenericFunctions_1.googleApiRequest.call(this, 'POST', encodeURIComponent(url), data); } } return [this.helpers.returnJsonArray(responseData)]; } } exports.GoogleSearchConsole = GoogleSearchConsole; //# sourceMappingURL=GoogleSearchConsole.node.js.map