n8n/packages/nodes-base/nodes/OneSimpleApi/OneSimpleApi.node.ts

945 lines
20 KiB
TypeScript
Raw Normal View History

import {
IExecuteFunctions,
} from 'n8n-core';
import {
IDataObject,
INodeExecutionData,
INodeType,
INodeTypeDescription,
} from 'n8n-workflow';
import {
oneSimpleApiRequest,
} from './GenericFunctions';
export class OneSimpleApi implements INodeType {
description: INodeTypeDescription = {
displayName: 'One Simple API',
name: 'oneSimpleApi',
icon: 'file:onesimpleapi.svg',
group: ['transform'],
version: 1,
description: 'A toolbox of no-code utilities',
defaults: {
name: 'One Simple API',
},
inputs: ['main'],
outputs: ['main'],
credentials: [
{
name: 'oneSimpleApi',
required: true,
},
],
properties: [
{
displayName: 'Resource',
name: 'resource',
type: 'options',
refactor: Apply more nodelinting rules (#3324) * :pencil2: Alphabetize lint rules * :fire: Remove duplicates * :zap: Update `lintfix` script * :shirt: Apply `node-param-operation-without-no-data-expression` (#3329) * :shirt: Apply `node-param-operation-without-no-data-expression` * :shirt: Add exceptions * :shirt: Apply `node-param-description-weak` (#3328) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-option-value-duplicate` (#3331) * :shirt: Apply `node-param-description-miscased-json` (#3337) * :shirt: Apply `node-param-display-name-excess-inner-whitespace` (#3335) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-type-options-missing-from-limit` (#3336) * Rule workig as intended * :pencil2: Uncomment rules Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-option-name-duplicate` (#3338) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-description-wrong-for-simplify` (#3334) * :zap: fix * :zap: exceptions * :zap: changed rule ignoring from file to line * :shirt: Apply `node-param-resource-without-no-data-expression` (#3339) * :shirt: Apply `node-param-display-name-untrimmed` (#3341) * :shirt: Apply `node-param-display-name-miscased-id` (#3340) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-resource-with-plural-option` (#3342) * :shirt: Apply `node-param-description-wrong-for-upsert` (#3333) * :zap: fix * :zap: replaced record with contact in description * :zap: fix Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-option-description-identical-to-name` (#3343) * :shirt: Apply `node-param-option-name-containing-star` (#3347) * :shirt: Apply `node-param-display-name-wrong-for-update-fields` (#3348) * :shirt: Apply `node-param-option-name-wrong-for-get-all` (#3345) * :zap: fix * :zap: exceptions * :shirt: Apply node-param-display-name-wrong-for-simplify (#3344) * Rule working as intended * Uncomented other rules * :shirt: Undo and add exceptions Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :zap: Alphabetize lint rules * :zap: Restore `lintfix` script Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com> Co-authored-by: agobrech <45268029+agobrech@users.noreply.github.com>
2022-05-20 14:47:24 -07:00
noDataExpression: true,
options: [
{
name: 'Information',
value: 'information',
},
{
name: 'Social Profile',
value: 'socialProfile',
},
{
name: 'Utility',
value: 'utility',
},
{
name: 'Website',
value: 'website',
},
],
default: 'website',
required: true,
},
// website
{
displayName: 'Operation',
name: 'operation',
type: 'options',
refactor: Apply more nodelinting rules (#3324) * :pencil2: Alphabetize lint rules * :fire: Remove duplicates * :zap: Update `lintfix` script * :shirt: Apply `node-param-operation-without-no-data-expression` (#3329) * :shirt: Apply `node-param-operation-without-no-data-expression` * :shirt: Add exceptions * :shirt: Apply `node-param-description-weak` (#3328) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-option-value-duplicate` (#3331) * :shirt: Apply `node-param-description-miscased-json` (#3337) * :shirt: Apply `node-param-display-name-excess-inner-whitespace` (#3335) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-type-options-missing-from-limit` (#3336) * Rule workig as intended * :pencil2: Uncomment rules Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-option-name-duplicate` (#3338) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-description-wrong-for-simplify` (#3334) * :zap: fix * :zap: exceptions * :zap: changed rule ignoring from file to line * :shirt: Apply `node-param-resource-without-no-data-expression` (#3339) * :shirt: Apply `node-param-display-name-untrimmed` (#3341) * :shirt: Apply `node-param-display-name-miscased-id` (#3340) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-resource-with-plural-option` (#3342) * :shirt: Apply `node-param-description-wrong-for-upsert` (#3333) * :zap: fix * :zap: replaced record with contact in description * :zap: fix Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-option-description-identical-to-name` (#3343) * :shirt: Apply `node-param-option-name-containing-star` (#3347) * :shirt: Apply `node-param-display-name-wrong-for-update-fields` (#3348) * :shirt: Apply `node-param-option-name-wrong-for-get-all` (#3345) * :zap: fix * :zap: exceptions * :shirt: Apply node-param-display-name-wrong-for-simplify (#3344) * Rule working as intended * Uncomented other rules * :shirt: Undo and add exceptions Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :zap: Alphabetize lint rules * :zap: Restore `lintfix` script Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com> Co-authored-by: agobrech <45268029+agobrech@users.noreply.github.com>
2022-05-20 14:47:24 -07:00
noDataExpression: true,
displayOptions: {
show: {
resource: [
'website',
],
},
},
options: [
{
name: 'Generate PDF',
value: 'pdf',
description: 'Generate a PDF from a webpage',
},
{
name: 'Get SEO Data',
value: 'seo',
description: 'Get SEO information from website',
},
{
name: 'Take Screenshot',
value: 'screenshot',
description: 'Create a screenshot from a webpage',
},
],
default: 'pdf',
},
// socialProfile
{
displayName: 'Operation',
name: 'operation',
type: 'options',
refactor: Apply more nodelinting rules (#3324) * :pencil2: Alphabetize lint rules * :fire: Remove duplicates * :zap: Update `lintfix` script * :shirt: Apply `node-param-operation-without-no-data-expression` (#3329) * :shirt: Apply `node-param-operation-without-no-data-expression` * :shirt: Add exceptions * :shirt: Apply `node-param-description-weak` (#3328) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-option-value-duplicate` (#3331) * :shirt: Apply `node-param-description-miscased-json` (#3337) * :shirt: Apply `node-param-display-name-excess-inner-whitespace` (#3335) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-type-options-missing-from-limit` (#3336) * Rule workig as intended * :pencil2: Uncomment rules Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-option-name-duplicate` (#3338) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-description-wrong-for-simplify` (#3334) * :zap: fix * :zap: exceptions * :zap: changed rule ignoring from file to line * :shirt: Apply `node-param-resource-without-no-data-expression` (#3339) * :shirt: Apply `node-param-display-name-untrimmed` (#3341) * :shirt: Apply `node-param-display-name-miscased-id` (#3340) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-resource-with-plural-option` (#3342) * :shirt: Apply `node-param-description-wrong-for-upsert` (#3333) * :zap: fix * :zap: replaced record with contact in description * :zap: fix Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-option-description-identical-to-name` (#3343) * :shirt: Apply `node-param-option-name-containing-star` (#3347) * :shirt: Apply `node-param-display-name-wrong-for-update-fields` (#3348) * :shirt: Apply `node-param-option-name-wrong-for-get-all` (#3345) * :zap: fix * :zap: exceptions * :shirt: Apply node-param-display-name-wrong-for-simplify (#3344) * Rule working as intended * Uncomented other rules * :shirt: Undo and add exceptions Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :zap: Alphabetize lint rules * :zap: Restore `lintfix` script Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com> Co-authored-by: agobrech <45268029+agobrech@users.noreply.github.com>
2022-05-20 14:47:24 -07:00
noDataExpression: true,
displayOptions: {
show: {
resource: [
'socialProfile',
],
},
},
options: [
{
name: 'Instagram',
value: 'instagramProfile',
description: 'Get details about an Instagram profile',
},
{
name: 'Spotify',
value: 'spotifyArtistProfile',
description: 'Get details about a Spotify Artist',
},
],
default: 'instagramProfile',
},
// Information
{
displayName: 'Operation',
name: 'operation',
type: 'options',
refactor: Apply more nodelinting rules (#3324) * :pencil2: Alphabetize lint rules * :fire: Remove duplicates * :zap: Update `lintfix` script * :shirt: Apply `node-param-operation-without-no-data-expression` (#3329) * :shirt: Apply `node-param-operation-without-no-data-expression` * :shirt: Add exceptions * :shirt: Apply `node-param-description-weak` (#3328) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-option-value-duplicate` (#3331) * :shirt: Apply `node-param-description-miscased-json` (#3337) * :shirt: Apply `node-param-display-name-excess-inner-whitespace` (#3335) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-type-options-missing-from-limit` (#3336) * Rule workig as intended * :pencil2: Uncomment rules Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-option-name-duplicate` (#3338) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-description-wrong-for-simplify` (#3334) * :zap: fix * :zap: exceptions * :zap: changed rule ignoring from file to line * :shirt: Apply `node-param-resource-without-no-data-expression` (#3339) * :shirt: Apply `node-param-display-name-untrimmed` (#3341) * :shirt: Apply `node-param-display-name-miscased-id` (#3340) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-resource-with-plural-option` (#3342) * :shirt: Apply `node-param-description-wrong-for-upsert` (#3333) * :zap: fix * :zap: replaced record with contact in description * :zap: fix Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-option-description-identical-to-name` (#3343) * :shirt: Apply `node-param-option-name-containing-star` (#3347) * :shirt: Apply `node-param-display-name-wrong-for-update-fields` (#3348) * :shirt: Apply `node-param-option-name-wrong-for-get-all` (#3345) * :zap: fix * :zap: exceptions * :shirt: Apply node-param-display-name-wrong-for-simplify (#3344) * Rule working as intended * Uncomented other rules * :shirt: Undo and add exceptions Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :zap: Alphabetize lint rules * :zap: Restore `lintfix` script Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com> Co-authored-by: agobrech <45268029+agobrech@users.noreply.github.com>
2022-05-20 14:47:24 -07:00
noDataExpression: true,
displayOptions: {
show: {
resource: [
'information',
],
},
},
options: [
{
name: 'Exchange Rate',
value: 'exchangeRate',
description: 'Convert a value between currencies',
},
{
name: 'Image Metadata',
value: 'imageMetadata',
description: 'Retrieve image metadata from a URL',
},
],
default: 'exchangeRate',
},
// Utility
{
displayName: 'Operation',
name: 'operation',
type: 'options',
refactor: Apply more nodelinting rules (#3324) * :pencil2: Alphabetize lint rules * :fire: Remove duplicates * :zap: Update `lintfix` script * :shirt: Apply `node-param-operation-without-no-data-expression` (#3329) * :shirt: Apply `node-param-operation-without-no-data-expression` * :shirt: Add exceptions * :shirt: Apply `node-param-description-weak` (#3328) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-option-value-duplicate` (#3331) * :shirt: Apply `node-param-description-miscased-json` (#3337) * :shirt: Apply `node-param-display-name-excess-inner-whitespace` (#3335) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-type-options-missing-from-limit` (#3336) * Rule workig as intended * :pencil2: Uncomment rules Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-option-name-duplicate` (#3338) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-description-wrong-for-simplify` (#3334) * :zap: fix * :zap: exceptions * :zap: changed rule ignoring from file to line * :shirt: Apply `node-param-resource-without-no-data-expression` (#3339) * :shirt: Apply `node-param-display-name-untrimmed` (#3341) * :shirt: Apply `node-param-display-name-miscased-id` (#3340) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-resource-with-plural-option` (#3342) * :shirt: Apply `node-param-description-wrong-for-upsert` (#3333) * :zap: fix * :zap: replaced record with contact in description * :zap: fix Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-option-description-identical-to-name` (#3343) * :shirt: Apply `node-param-option-name-containing-star` (#3347) * :shirt: Apply `node-param-display-name-wrong-for-update-fields` (#3348) * :shirt: Apply `node-param-option-name-wrong-for-get-all` (#3345) * :zap: fix * :zap: exceptions * :shirt: Apply node-param-display-name-wrong-for-simplify (#3344) * Rule working as intended * Uncomented other rules * :shirt: Undo and add exceptions Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :zap: Alphabetize lint rules * :zap: Restore `lintfix` script Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com> Co-authored-by: agobrech <45268029+agobrech@users.noreply.github.com>
2022-05-20 14:47:24 -07:00
noDataExpression: true,
displayOptions: {
show: {
resource: [
'utility',
],
},
},
options: [
{
name: 'Expand URL',
value: 'expandURL',
refactor: Apply more `eslint-plugin-n8n-nodes-base` autofixable rules (#3432) * :zap: Update `lintfix` script * :shirt: Remove unneeded lint exceptions * :shirt: Run baseline `lintfix` * :shirt: Apply `node-param-description-miscased-url` (#3441) * :shirt: Apply `rule node-param-placeholder-miscased-id` (#3443) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-option-name-wrong-for-upsert` (#3446) * :shirt: Apply `node-param-min-value-wrong-for-limit` (#3442) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * Apply `node-param-display-name-wrong-for-dynamic-options` (#3454) * :hammer: fix * :zap: Fix `Assigned To` fields Co-authored-by: Michael Kret <michael.k@radency.com> * :shirt: Apply `rule node-param-default-wrong-for-number` (#3453) * :shirt: Apply `node-param-default-wrong-for-string` (#3452) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * Apply `node-param-display-name-miscased` (#3449) * :hammer: fix * :hammer: exceptions * :zap: review fixes * :shirt: Apply `node-param-description-lowercase-first-char` (#3451) * :zap: fix * :zap: review fixes * :zap: fix Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-description-wrong-for-dynamic-options` (#3456) * Rule working as intended * Add rule * :fire: Remove repetitions * :shirt: Add exceptions Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Small fix for `node-param-description-wrong-for-dynamic-options` * :shirt: Apply `node-param-default-wrong-for-fixed-collection` (#3460) * :shirt: Apply `node-param-description-line-break-html-tag` (#3462) * :shirt: Run baseline `lintfix` * :shirt: Apply `node-param-options-type-unsorted-items` (#3459) * :zap: fix * :hammer: exceptions * Add exception for Salesmate and Zoom Co-authored-by: Michael Kret <michael.k@radency.com> Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :zap: Restore `lintfix` command Co-authored-by: Omar Ajoue <krynble@gmail.com> Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com> Co-authored-by: agobrech <45268029+agobrech@users.noreply.github.com> Co-authored-by: Michael Kret <michael.k@radency.com> Co-authored-by: brianinoa <54530642+brianinoa@users.noreply.github.com>
2022-06-03 10:23:49 -07:00
description: 'Expand a shortened URL',
},
{
name: 'Generate QR Code',
value: 'qrCode',
description: 'Generate a QR Code',
},
{
name: 'Validate Email',
value: 'validateEmail',
description: 'Validate an email address',
},
],
default: 'validateEmail',
},
// website: pdf
{
displayName: 'Webpage URL',
name: 'link',
type: 'string',
required: true,
displayOptions: {
show: {
operation: [
'pdf',
],
resource: [
'website',
],
},
},
default: '',
description: 'Link to webpage to convert',
},
{
displayName: 'Download PDF?',
name: 'download',
type: 'boolean',
required: true,
displayOptions: {
show: {
operation: [
'pdf',
],
resource: [
'website',
],
},
},
default: false,
description: 'Whether to download the PDF or return a link to it',
},
{
displayName: 'Put Output In Field',
name: 'output',
type: 'string',
required: true,
displayOptions: {
show: {
operation: [
'pdf',
],
resource: [
'website',
],
download: [
true,
],
},
},
default: 'data',
description: 'The name of the output field to put the binary file data in',
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Option',
default: {},
displayOptions: {
show: {
resource: [
'website',
],
operation: [
'pdf',
],
},
},
options: [
{
displayName: 'Page Size',
name: 'page',
type: 'options',
options: [
{
name: 'A0',
value: 'A0',
},
{
name: 'A1',
value: 'A1',
},
{
name: 'A2',
value: 'A2',
},
{
name: 'A3',
value: 'A3',
},
{
name: 'A4',
value: 'A4',
},
{
name: 'A5',
value: 'A5',
},
{
name: 'A6',
value: 'A6',
},
{
name: 'Ledger',
value: 'Ledger',
},
refactor: Apply more `eslint-plugin-n8n-nodes-base` autofixable rules (#3432) * :zap: Update `lintfix` script * :shirt: Remove unneeded lint exceptions * :shirt: Run baseline `lintfix` * :shirt: Apply `node-param-description-miscased-url` (#3441) * :shirt: Apply `rule node-param-placeholder-miscased-id` (#3443) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-option-name-wrong-for-upsert` (#3446) * :shirt: Apply `node-param-min-value-wrong-for-limit` (#3442) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * Apply `node-param-display-name-wrong-for-dynamic-options` (#3454) * :hammer: fix * :zap: Fix `Assigned To` fields Co-authored-by: Michael Kret <michael.k@radency.com> * :shirt: Apply `rule node-param-default-wrong-for-number` (#3453) * :shirt: Apply `node-param-default-wrong-for-string` (#3452) Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * Apply `node-param-display-name-miscased` (#3449) * :hammer: fix * :hammer: exceptions * :zap: review fixes * :shirt: Apply `node-param-description-lowercase-first-char` (#3451) * :zap: fix * :zap: review fixes * :zap: fix Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Apply `node-param-description-wrong-for-dynamic-options` (#3456) * Rule working as intended * Add rule * :fire: Remove repetitions * :shirt: Add exceptions Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :shirt: Small fix for `node-param-description-wrong-for-dynamic-options` * :shirt: Apply `node-param-default-wrong-for-fixed-collection` (#3460) * :shirt: Apply `node-param-description-line-break-html-tag` (#3462) * :shirt: Run baseline `lintfix` * :shirt: Apply `node-param-options-type-unsorted-items` (#3459) * :zap: fix * :hammer: exceptions * Add exception for Salesmate and Zoom Co-authored-by: Michael Kret <michael.k@radency.com> Co-authored-by: Iván Ovejero <ivov.src@gmail.com> * :zap: Restore `lintfix` command Co-authored-by: Omar Ajoue <krynble@gmail.com> Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com> Co-authored-by: agobrech <45268029+agobrech@users.noreply.github.com> Co-authored-by: Michael Kret <michael.k@radency.com> Co-authored-by: brianinoa <54530642+brianinoa@users.noreply.github.com>
2022-06-03 10:23:49 -07:00
{
name: 'Legal',
value: 'Legal',
},
{
name: 'Letter',
value: 'Letter',
},
{
name: 'Tabloid',
value: 'Tabloid',
},
],
default: '',
},
{
displayName: 'Force Refresh',
name: 'force',
type: 'boolean',
default: false,
description: 'Normally the API will reuse a previously taken screenshot of the URL to give a faster response. This option allows you to retake the screenshot at that exact time, for those times when it\'s necessary.',
},
],
},
// website: qrCode
{
displayName: 'QR Content',
name: 'message',
type: 'string',
required: true,
displayOptions: {
show: {
operation: [
'qrCode',
],
resource: [
'utility',
],
},
},
default: '',
description: 'The text that should be turned into a QR code - like a website URL',
},
{
displayName: 'Download Image?',
name: 'download',
type: 'boolean',
required: true,
displayOptions: {
show: {
operation: [
'qrCode',
],
resource: [
'utility',
],
},
},
default: false,
description: 'Whether to download the QR code or return a link to it',
},
{
displayName: 'Put Output In Field',
name: 'output',
type: 'string',
required: true,
displayOptions: {
show: {
operation: [
'qrCode',
],
resource: [
'utility',
],
download: [
true,
],
},
},
default: 'data',
description: 'The name of the output field to put the binary file data in',
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Option',
default: {},
displayOptions: {
show: {
resource: [
'utility',
],
operation: [
'qrCode',
],
},
},
options: [
{
displayName: 'Size',
name: 'size',
type: 'options',
options: [
{
name: 'Small',
value: 'Small',
},
{
name: 'Medium',
value: 'Medium',
},
{
name: 'Large',
value: 'Large',
},
],
default: 'Small',
description: 'The QR Code size',
},
{
displayName: 'Format',
name: 'format',
type: 'options',
options: [
{
name: 'PNG',
value: 'PNG',
},
{
name: 'SVG',
value: 'SVG',
},
],
default: 'PNG',
description: 'The QR Code format',
},
],
},
// website: screenshot
{
displayName: 'Webpage URL',
name: 'link',
type: 'string',
required: true,
displayOptions: {
show: {
operation: [
'screenshot',
],
resource: [
'website',
],
},
},
default: '',
description: 'Link to webpage to convert',
},
{
displayName: 'Download Screenshot?',
name: 'download',
type: 'boolean',
required: true,
displayOptions: {
show: {
operation: [
'screenshot',
],
resource: [
'website',
],
},
},
default: false,
description: 'Whether to download the screenshot or return a link to it',
},
{
displayName: 'Put Output In Field',
name: 'output',
type: 'string',
required: true,
displayOptions: {
show: {
operation: [
'screenshot',
],
resource: [
'website',
],
download: [
true,
],
},
},
default: 'data',
description: 'The name of the output field to put the binary file data in',
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Option',
default: {},
displayOptions: {
show: {
resource: [
'website',
],
operation: [
'screenshot',
],
},
},
options: [
{
displayName: 'Screen Size',
name: 'screen',
type: 'options',
options: [
{
name: 'Phone',
value: 'phone',
},
{
name: 'Phone Landscape',
value: 'phone-landscape',
},
{
name: 'Retina',
value: 'retina',
},
{
name: 'Tablet',
value: 'tablet',
},
{
name: 'Tablet Landscape',
value: 'tablet-landscape',
},
],
default: '',
},
{
displayName: 'Force Refresh',
name: 'force',
type: 'boolean',
default: false,
description: 'Normally the API will reuse a previously taken screenshot of the URL to give a faster response. This option allows you to retake the screenshot at that exact time, for those times when it\'s necessary.',
},
{
displayName: 'Full Page',
name: 'fullpage',
type: 'boolean',
default: false,
refactor: Apply `eslint-plugin-n8n-nodes-base` autofixable rules (#3174) * :zap: Initial setup * :shirt: Update `.eslintignore` * :shirt: Autofix node-param-default-missing (#3173) * :fire: Remove duplicate key * :shirt: Add exceptions * :package: Update package-lock.json * :shirt: Apply `node-class-description-inputs-wrong-trigger-node` (#3176) * :shirt: Apply `node-class-description-inputs-wrong-regular-node` (#3177) * :shirt: Apply `node-class-description-outputs-wrong` (#3178) * :shirt: Apply `node-execute-block-double-assertion-for-items` (#3179) * :shirt: Apply `node-param-default-wrong-for-collection` (#3180) * :shirt: Apply node-param-default-wrong-for-boolean (#3181) * Autofixed default missing * Autofixed booleans, worked well * :zap: Fix params * :rewind: Undo exempted autofixes * :package: Update package-lock.json * :shirt: Apply node-class-description-missing-subtitle (#3182) * :zap: Fix missing comma * :shirt: Apply `node-param-default-wrong-for-fixed-collection` (#3184) * :shirt: Add exception for `node-class-description-missing-subtitle` * :shirt: Apply `node-param-default-wrong-for-multi-options` (#3185) * :shirt: Apply `node-param-collection-type-unsorted-items` (#3186) * Missing coma * :shirt: Apply `node-param-default-wrong-for-simplify` (#3187) * :shirt: Apply `node-param-description-comma-separated-hyphen` (#3190) * :shirt: Apply `node-param-description-empty-string` (#3189) * :shirt: Apply `node-param-description-excess-inner-whitespace` (#3191) * Rule looks good * Add whitespace rule in eslint config * :zao: fix * :shirt: Apply `node-param-description-identical-to-display-name` (#3193) * :shirt: Apply `node-param-description-missing-for-ignore-ssl-issues` (#3195) * :rewind: Revert ":zao: fix" This reverts commit ef8a76f3dfedffd1bdccf3178af8a8d90cf5a55c. * :shirt: Apply `node-param-description-missing-for-simplify` (#3196) * :shirt: Apply `node-param-description-missing-final-period` (#3194) * Rule working as intended * Add rule to eslint * :shirt: Apply node-param-description-missing-for-return-all (#3197) * :zap: Restore `lintfix` command Co-authored-by: agobrech <45268029+agobrech@users.noreply.github.com> Co-authored-by: Omar Ajoue <krynble@gmail.com> Co-authored-by: agobrech <ael.gobrecht@gmail.com> Co-authored-by: Michael Kret <michael.k@radency.com>
2022-04-22 09:29:51 -07:00
description: 'The API takes a screenshot of the viewable area for the desired screen size. If you need a screenshot of the whole length of the page, use this option.',
},
],
},
// socialProfile: instagramProfile
{
displayName: 'Profile Name',
name: 'profileName',
type: 'string',
required: true,
displayOptions: {
show: {
operation: [
'instagramProfile',
],
resource: [
'socialProfile',
],
},
},
default: '',
description: 'Profile name to get details of',
},
// socialProfile: spotifyArtistProfile
{
displayName: 'Artist Name',
name: 'artistName',
type: 'string',
required: true,
displayOptions: {
show: {
operation: [
'spotifyArtistProfile',
],
resource: [
'socialProfile',
],
},
},
default: '',
description: 'Artist name to get details for',
},
// information: exchangeRate
{
displayName: 'Value',
name: 'value',
type: 'string',
required: true,
displayOptions: {
show: {
operation: [
'exchangeRate',
],
resource: [
'information',
],
},
},
default: '',
description: 'Value to convert',
},
{
displayName: 'From Currency',
name: 'fromCurrency',
type: 'string',
required: true,
placeholder: 'USD',
displayOptions: {
show: {
operation: [
'exchangeRate',
],
resource: [
'information',
],
},
},
default: '',
},
{
displayName: 'To Currency',
name: 'toCurrency',
type: 'string',
placeholder: 'EUR',
required: true,
displayOptions: {
show: {
operation: [
'exchangeRate',
],
resource: [
'information',
],
},
},
default: '',
},
// information: imageMetadata
{
displayName: 'Link To Image',
name: 'link',
type: 'string',
required: true,
displayOptions: {
show: {
operation: [
'imageMetadata',
],
resource: [
'information',
],
},
},
default: '',
description: 'Image to get metadata from',
},
// website: seo
{
displayName: 'Webpage URL',
name: 'link',
type: 'string',
required: true,
displayOptions: {
show: {
operation: [
'seo',
],
resource: [
'website',
],
},
},
default: '',
description: 'Webpage to get SEO information for',
},
{
displayName: 'Options',
name: 'options',
type: 'collection',
placeholder: 'Add Option',
default: {},
displayOptions: {
show: {
resource: [
'website',
],
operation: [
'seo',
],
},
},
options: [
{
displayName: 'Include Headers?',
name: 'headers',
type: 'boolean',
default: false,
},
],
},
// utility: validateEmail
{
displayName: 'Email Address',
name: 'emailAddress',
type: 'string',
required: true,
displayOptions: {
show: {
operation: [
'validateEmail',
],
resource: [
'utility',
],
},
},
default: '',
},
// utility: expandURL
{
displayName: 'URL',
name: 'link',
type: 'string',
required: true,
displayOptions: {
show: {
operation: [
'expandURL',
],
resource: [
'utility',
],
},
},
default: '',
description: 'URL to unshorten',
},
],
};
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
const returnData: IDataObject[] = [];
refactor: Apply `eslint-plugin-n8n-nodes-base` autofixable rules (#3174) * :zap: Initial setup * :shirt: Update `.eslintignore` * :shirt: Autofix node-param-default-missing (#3173) * :fire: Remove duplicate key * :shirt: Add exceptions * :package: Update package-lock.json * :shirt: Apply `node-class-description-inputs-wrong-trigger-node` (#3176) * :shirt: Apply `node-class-description-inputs-wrong-regular-node` (#3177) * :shirt: Apply `node-class-description-outputs-wrong` (#3178) * :shirt: Apply `node-execute-block-double-assertion-for-items` (#3179) * :shirt: Apply `node-param-default-wrong-for-collection` (#3180) * :shirt: Apply node-param-default-wrong-for-boolean (#3181) * Autofixed default missing * Autofixed booleans, worked well * :zap: Fix params * :rewind: Undo exempted autofixes * :package: Update package-lock.json * :shirt: Apply node-class-description-missing-subtitle (#3182) * :zap: Fix missing comma * :shirt: Apply `node-param-default-wrong-for-fixed-collection` (#3184) * :shirt: Add exception for `node-class-description-missing-subtitle` * :shirt: Apply `node-param-default-wrong-for-multi-options` (#3185) * :shirt: Apply `node-param-collection-type-unsorted-items` (#3186) * Missing coma * :shirt: Apply `node-param-default-wrong-for-simplify` (#3187) * :shirt: Apply `node-param-description-comma-separated-hyphen` (#3190) * :shirt: Apply `node-param-description-empty-string` (#3189) * :shirt: Apply `node-param-description-excess-inner-whitespace` (#3191) * Rule looks good * Add whitespace rule in eslint config * :zao: fix * :shirt: Apply `node-param-description-identical-to-display-name` (#3193) * :shirt: Apply `node-param-description-missing-for-ignore-ssl-issues` (#3195) * :rewind: Revert ":zao: fix" This reverts commit ef8a76f3dfedffd1bdccf3178af8a8d90cf5a55c. * :shirt: Apply `node-param-description-missing-for-simplify` (#3196) * :shirt: Apply `node-param-description-missing-final-period` (#3194) * Rule working as intended * Add rule to eslint * :shirt: Apply node-param-description-missing-for-return-all (#3197) * :zap: Restore `lintfix` command Co-authored-by: agobrech <45268029+agobrech@users.noreply.github.com> Co-authored-by: Omar Ajoue <krynble@gmail.com> Co-authored-by: agobrech <ael.gobrecht@gmail.com> Co-authored-by: Michael Kret <michael.k@radency.com>
2022-04-22 09:29:51 -07:00
const length = items.length;
const qs: IDataObject = {};
let responseData;
let download;
for (let i = 0; i < length; i++) {
try {
const resource = this.getNodeParameter('resource', 0) as string;
const operation = this.getNodeParameter('operation', 0) as string;
if (resource === 'website') {
if (operation === 'pdf') {
const link = this.getNodeParameter('link', i) as string;
const options = this.getNodeParameter('options', i) as IDataObject;
download = this.getNodeParameter('download', i) as boolean;
qs.url = link;
if (options.page) {
qs.page = options.page as string;
}
if (options.force) {
qs.force = 'yes';
} else {
qs.force = 'no';
}
const response = await oneSimpleApiRequest.call(this, 'GET', '/pdf', {}, qs);
if (download) {
const output = this.getNodeParameter('output', i) as string;
const buffer = await oneSimpleApiRequest.call(this, 'GET', '', {}, {}, response.url, { json: false, encoding: null }) as Buffer;
responseData = {
json: response,
binary: {
[output]: await this.helpers.prepareBinaryData(buffer),
},
};
} else {
responseData = response;
}
}
if (operation === 'screenshot') {
const link = this.getNodeParameter('link', i) as string;
const options = this.getNodeParameter('options', i) as IDataObject;
download = this.getNodeParameter('download', i) as boolean;
qs.url = link;
if (options.screen) {
qs.screen = options.screen as string;
}
if (options.fullpage) {
qs.fullpage = 'yes';
} else {
qs.fullpage = 'no';
}
if (options.force) {
qs.force = 'yes';
} else {
qs.force = 'no';
}
const response = await oneSimpleApiRequest.call(this, 'GET', '/screenshot', {}, qs);
if (download) {
const output = this.getNodeParameter('output', i) as string;
const buffer = await oneSimpleApiRequest.call(this, 'GET', '', {}, {}, response.url, { json: false, encoding: null }) as Buffer;
responseData = {
json: response,
binary: {
[output]: await this.helpers.prepareBinaryData(buffer),
},
};
} else {
responseData = response;
}
}
if (operation === 'seo') {
const link = this.getNodeParameter('link', i) as string;
const options = this.getNodeParameter('options', i) as IDataObject;
qs.url = link;
if (options.headers) {
qs.headers = 'yes';
}
responseData = await oneSimpleApiRequest.call(this, 'GET', '/page_info', {}, qs);
}
}
if (resource === 'socialProfile') {
if (operation === 'instagramProfile') {
const profileName = this.getNodeParameter('profileName', i) as string;
qs.profile = profileName;
responseData = await oneSimpleApiRequest.call(this, 'GET', '/instagram_profile', {}, qs);
}
if (operation === 'spotifyArtistProfile') {
const artistName = this.getNodeParameter('artistName', i) as string;
qs.profile = artistName;
responseData = await oneSimpleApiRequest.call(this, 'GET', '/spotify_profile', {}, qs);
}
}
if (resource === 'information') {
if (operation === 'exchangeRate') {
const value = this.getNodeParameter('value', i) as string;
const fromCurrency = this.getNodeParameter('fromCurrency', i) as string;
const toCurrency = this.getNodeParameter('toCurrency', i) as string;
qs.from_currency = fromCurrency;
qs.to_currency = toCurrency;
qs.from_value = value;
responseData = await oneSimpleApiRequest.call(this, 'GET', '/exchange_rate', {}, qs);
}
if (operation === 'imageMetadata') {
const link = this.getNodeParameter('link', i) as string;
qs.url = link;
qs.raw = true;
responseData = await oneSimpleApiRequest.call(this, 'GET', '/image_info', {}, qs);
}
}
if (resource === 'utility') {
// validateEmail
if (operation === 'validateEmail') {
const emailAddress = this.getNodeParameter('emailAddress', i) as string;
qs.email = emailAddress;
responseData = await oneSimpleApiRequest.call(this, 'GET', '/email', {}, qs);
}
// expandURL
if (operation === 'expandURL') {
const url = this.getNodeParameter('link', i) as string;
qs.url = url;
responseData = await oneSimpleApiRequest.call(this, 'GET', '/unshorten', {}, qs);
}
if (operation === 'qrCode') {
const message = this.getNodeParameter('message', i) as string;
const options = this.getNodeParameter('options', i) as IDataObject;
download = this.getNodeParameter('download', i) as boolean;
qs.message = message;
if (options.size) {
qs.size = options.size as string;
}
if (options.format) {
qs.format = options.format as string;
}
const response = await oneSimpleApiRequest.call(this, 'GET', '/qr_code', {}, qs);
if (download) {
const output = this.getNodeParameter('output', i) as string;
const buffer = await oneSimpleApiRequest.call(this, 'GET', '', {}, {}, response.url, { json: false, encoding: null }) as Buffer;
responseData = {
json: response,
binary: {
[output]: await this.helpers.prepareBinaryData(buffer),
},
};
} else {
responseData = response;
}
}
}
if (Array.isArray(responseData)) {
returnData.push.apply(returnData, responseData as IDataObject[]);
} else {
returnData.push(responseData as IDataObject);
}
} catch (error) {
if (this.continueOnFail()) {
returnData.push({ error: error.message });
continue;
}
throw error;
}
}
if (download) {
return this.prepareOutputData(returnData as unknown as INodeExecutionData[]);
}
return [this.helpers.returnJsonArray(returnData)];
}
}