n8n-nodes-base
Version:
Base nodes of n8n
112 lines • 3.67 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Mailcheck = void 0;
const n8n_workflow_1 = require("n8n-workflow");
const GenericFunctions_1 = require("./GenericFunctions");
class Mailcheck {
description = {
displayName: 'Mailcheck',
name: 'mailcheck',
icon: 'file:mailcheck.svg',
group: ['transform'],
version: 1,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
description: 'Consume Mailcheck API',
defaults: {
name: 'Mailcheck',
},
usableAsTool: true,
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
credentials: [
{
name: 'mailcheckApi',
required: true,
},
],
properties: [
{
displayName: 'Resource',
name: 'resource',
type: 'options',
noDataExpression: true,
options: [
{
name: 'Email',
value: 'email',
},
],
default: 'email',
},
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: ['email'],
},
},
options: [
{
name: 'Check',
value: 'check',
action: 'Check an email',
},
],
default: 'check',
},
{
displayName: 'Email',
name: 'email',
type: 'string',
placeholder: 'name@email.com',
displayOptions: {
show: {
resource: ['email'],
operation: ['check'],
},
},
default: '',
description: 'Email address to check',
},
],
};
async execute() {
const items = this.getInputData();
const returnData = [];
const length = items.length;
let responseData;
const resource = this.getNodeParameter('resource', 0);
const operation = this.getNodeParameter('operation', 0);
for (let i = 0; i < length; i++) {
try {
if (resource === 'email') {
if (operation === 'check') {
const email = this.getNodeParameter('email', i);
responseData = await GenericFunctions_1.mailCheckApiRequest.call(this, 'POST', '/singleEmail:check', {
email,
});
}
}
}
catch (error) {
if (this.continueOnFail()) {
returnData.push({ error: error.message });
continue;
}
throw error;
}
if (Array.isArray(responseData)) {
returnData.push.apply(returnData, responseData);
}
else {
returnData.push(responseData);
}
}
return [this.helpers.returnJsonArray(returnData)];
}
}
exports.Mailcheck = Mailcheck;
//# sourceMappingURL=Mailcheck.node.js.map