UNPKG

n8n-nodes-dataforseo

Version:

DataForSEO is an SEO and marketing data provider, empowering businesses with invaluable insights via APIs and databases.

141 lines 6.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DataForSeoBusinessDataApi = void 0; const n8n_workflow_1 = require("n8n-workflow"); const business_listings_1 = require("./resources/business_listings"); const google_1 = require("./resources/google"); const business_listings_2 = require("./execute/business_listings"); const google_2 = require("./execute/google"); const trustpilot_1 = require("./execute/trustpilot"); const tripadvisor_1 = require("./execute/tripadvisor"); const social_media_1 = require("./execute/social_media"); const trustpilot_2 = require("./resources/trustpilot"); const tripadvisor_2 = require("./resources/tripadvisor"); const social_media_2 = require("./resources/social_media"); class DataForSeoBusinessDataApi { constructor() { this.description = { displayName: 'DataForSEO Business Data API', name: 'dataForSeoBusinessDataApi', icon: 'file:dataforseo.svg', group: ['transform'], version: 1, subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', description: 'DataForSEO', defaults: { name: 'DataForSeo Business Data API', }, inputs: ["main"], outputs: ["main"], credentials: [ { name: 'dataForSeoApi', required: true, }, ], requestDefaults: { method: 'POST', baseURL: 'https://api.dataforseo.com/v3', headers: { 'Content-Type': 'application/json', }, }, properties: [ { displayName: 'Resource', name: 'resource', type: 'options', noDataExpression: true, options: [ { name: 'Business Listings', value: 'business_listings', }, { name: 'Google', value: 'google', }, { name: 'Trustpilot', value: 'trustpilot', }, { name: 'Tripadvisor', value: 'tripadvisor', }, { name: 'Social Media', value: 'social_media', } ], default: 'business_listings', }, ...business_listings_1.BusinessListingsOperations, ...google_1.GoogleOperations, ...trustpilot_2.TrustpilotOperations, ...tripadvisor_2.TripAdvisorOperations, ...social_media_2.SocialMediaOperations ], }; } async execute() { let responseData = []; const resource = this.getNodeParameter('resource', 0); const operation = this.getNodeParameter('operation', 0); const mapping = { 'business_listings': { 'get-business-listings': business_listings_2.getBusinessListings, 'get-categories-aggregation': business_listings_2.getCategoriesAggregation }, 'google': { 'get-google-business-info-live': google_2.getGoogleBusinessInfoLive, 'get-google-business-info': google_2.getGoogleBusinessInfo, 'get-google-business-updates': google_2.getGoogleBusinessUpdates, 'get-google-hotel-searches-live': google_2.getGoogleHotelSearchesLive, 'get-google-hotel-searches': google_2.getGoogleHotelSearches, 'get-google-hotel-info-advanced-live': google_2.getLiveGoogleHotelInfoAdvanced, 'get-google-hotel-info-html-live': google_2.getLiveGoogleHotelInfoHtml, 'get-google-hotel-info-advanced': google_2.getGoogleHotelInfoAdvanced, 'get-google-hotel-info-html': google_2.getGoogleHotelInfoHtml, 'get-google-reviews': google_2.getGoogleReviews, 'get-extended-google-reviews': google_2.getExtendedGoogleReviews, 'get-business-questions-and-answers-live': google_2.getLiveBusinessQuestionsAndAnswers, 'get-business-questions-and-answers': google_2.getBusinessQuestionsAndAnswers }, 'trustpilot': { 'search-trustpilot-business-info': trustpilot_1.searchTrustpilotBusinessInfo, 'get-trustpilot-reviews': trustpilot_1.getTrustpilotReviews }, 'tripadvisor': { 'search-tripadvisor-business-data': tripadvisor_1.searchTripadvisorBusinessData, 'get-tripadvisor-reviews': tripadvisor_1.getTripadvisorReviews }, 'social_media': { 'get-pinterest-data': social_media_1.getPinterestData, 'get-facebook-data': social_media_1.getFacebookData, 'get-reddit-data': social_media_1.getRedditData } }; const fn = mapping[resource][operation]; if (!fn) { throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Something went wrong"); } try { const items = this.getInputData(); for (let i = 0; i < items.length; i++) { responseData.push(await fn(this, i)); } } catch (e) { if (e instanceof n8n_workflow_1.NodeOperationError) { throw e; } else { throw new n8n_workflow_1.NodeOperationError(this.getNode(), "Something went wrong"); } } return [this.helpers.returnJsonArray(responseData)]; } } exports.DataForSeoBusinessDataApi = DataForSeoBusinessDataApi; //# sourceMappingURL=DataForSeoBusinessDataApi.node.js.map