mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
✨ Add Mailcheck Node (#1690)
* Add Mailcheck integration
* compress logo
* Add mailcheck node info
* ⚡ Improvements
Co-authored-by: bugagashenkj <bugagashenkj@gmail.com>
Co-authored-by: Nosov Konstantin <nosov@nodeart.io>
This commit is contained in:
parent
66d4fe4911
commit
d57ae97669
18
packages/nodes-base/credentials/MailcheckApi.credentials.ts
Normal file
18
packages/nodes-base/credentials/MailcheckApi.credentials.ts
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
import {
|
||||||
|
ICredentialType,
|
||||||
|
NodePropertyTypes,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
|
export class MailcheckApi implements ICredentialType {
|
||||||
|
name = 'mailcheckApi';
|
||||||
|
displayName = 'Mailcheck API';
|
||||||
|
documentationUrl = 'mailcheck';
|
||||||
|
properties = [
|
||||||
|
{
|
||||||
|
displayName: 'API Key',
|
||||||
|
name: 'apiKey',
|
||||||
|
type: 'string' as NodePropertyTypes,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
47
packages/nodes-base/nodes/Mailcheck/GenericFunctions.ts
Normal file
47
packages/nodes-base/nodes/Mailcheck/GenericFunctions.ts
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
import {
|
||||||
|
OptionsWithUri,
|
||||||
|
} from 'request';
|
||||||
|
|
||||||
|
import {
|
||||||
|
IExecuteFunctions,
|
||||||
|
IHookFunctions,
|
||||||
|
ILoadOptionsFunctions,
|
||||||
|
IWebhookFunctions,
|
||||||
|
} from 'n8n-core';
|
||||||
|
|
||||||
|
import {
|
||||||
|
IDataObject
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
|
export async function mailCheckApiRequest(this: IWebhookFunctions | IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||||
|
const credentials = this.getCredentials('mailcheckApi') as IDataObject;
|
||||||
|
|
||||||
|
let options: OptionsWithUri = {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Authorization': `Bearer ${credentials.apiKey}`,
|
||||||
|
},
|
||||||
|
method,
|
||||||
|
body,
|
||||||
|
qs,
|
||||||
|
uri: uri || `https://api.mailcheck.co/v1${resource}`,
|
||||||
|
json: true,
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
options = Object.assign({}, options, option);
|
||||||
|
if (Object.keys(headers).length !== 0) {
|
||||||
|
options.headers = Object.assign({}, options.headers, headers);
|
||||||
|
}
|
||||||
|
if (Object.keys(body).length === 0) {
|
||||||
|
delete options.body;
|
||||||
|
}
|
||||||
|
//@ts-ignore
|
||||||
|
return await this.helpers.request.call(this, options);
|
||||||
|
} catch (error) {
|
||||||
|
if (error.response && error.response.body && error.response.body.message) {
|
||||||
|
// Try to return the error prettier
|
||||||
|
throw new Error(`Mailcheck error response [${error.statusCode}]: ${error.response.body.message}`);
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
15
packages/nodes-base/nodes/Mailcheck/Mailcheck.node.json
Normal file
15
packages/nodes-base/nodes/Mailcheck/Mailcheck.node.json
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"node": "n8n-nodes-base.mailcheck",
|
||||||
|
"nodeVersion": "1.0",
|
||||||
|
"codexVersion": "1.0",
|
||||||
|
"categories": [
|
||||||
|
"Utility"
|
||||||
|
],
|
||||||
|
"resources": {
|
||||||
|
"credentialDocumentation": [
|
||||||
|
{
|
||||||
|
"url": "https://docs.n8n.io/credentials/mailcheck"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
112
packages/nodes-base/nodes/Mailcheck/Mailcheck.node.ts
Normal file
112
packages/nodes-base/nodes/Mailcheck/Mailcheck.node.ts
Normal file
|
@ -0,0 +1,112 @@
|
||||||
|
import {
|
||||||
|
IExecuteFunctions,
|
||||||
|
} from 'n8n-core';
|
||||||
|
|
||||||
|
import {
|
||||||
|
IDataObject,
|
||||||
|
INodeExecutionData,
|
||||||
|
INodeType,
|
||||||
|
INodeTypeDescription,
|
||||||
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
|
import {
|
||||||
|
mailCheckApiRequest,
|
||||||
|
} from './GenericFunctions';
|
||||||
|
|
||||||
|
export class Mailcheck implements INodeType {
|
||||||
|
description: INodeTypeDescription = {
|
||||||
|
displayName: 'Mailcheck',
|
||||||
|
name: 'mailcheck',
|
||||||
|
icon: 'file:mailcheck.svg',
|
||||||
|
group: ['transform'],
|
||||||
|
version: 1,
|
||||||
|
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
||||||
|
description: 'Consume Mailcheck API',
|
||||||
|
defaults: {
|
||||||
|
name: 'Mailcheck',
|
||||||
|
color: '#4f44d7',
|
||||||
|
},
|
||||||
|
inputs: ['main'],
|
||||||
|
outputs: ['main'],
|
||||||
|
credentials: [
|
||||||
|
{
|
||||||
|
name: 'mailcheckApi',
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
properties: [
|
||||||
|
{
|
||||||
|
displayName: 'Resource',
|
||||||
|
name: 'resource',
|
||||||
|
type: 'options',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'Email',
|
||||||
|
value: 'email',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
default: 'email',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Operation',
|
||||||
|
name: 'operation',
|
||||||
|
type: 'options',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'email',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'Check',
|
||||||
|
value: 'check',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
default: 'check',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Email',
|
||||||
|
name: 'email',
|
||||||
|
type: 'string',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'email',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'check',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: '',
|
||||||
|
description: 'Email address to check.',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||||
|
const items = this.getInputData();
|
||||||
|
const returnData: IDataObject[] = [];
|
||||||
|
const length = items.length as unknown as number;
|
||||||
|
let responseData;
|
||||||
|
|
||||||
|
const resource = this.getNodeParameter('resource', 0) as string;
|
||||||
|
const operation = this.getNodeParameter('operation', 0) as string;
|
||||||
|
for (let i = 0; i < length; i++) {
|
||||||
|
if (resource === 'email') {
|
||||||
|
if (operation === 'check') {
|
||||||
|
const email = this.getNodeParameter('email', i) as string;
|
||||||
|
responseData = await mailCheckApiRequest.call(this, 'POST', '/singleEmail:check', { email });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (Array.isArray(responseData)) {
|
||||||
|
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||||
|
} else {
|
||||||
|
returnData.push(responseData as IDataObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [this.helpers.returnJsonArray(returnData)];
|
||||||
|
}
|
||||||
|
}
|
1
packages/nodes-base/nodes/Mailcheck/mailcheck.svg
Normal file
1
packages/nodes-base/nodes/Mailcheck/mailcheck.svg
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<svg width="60" height="60" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="60" height="60" rx="8" fill="url(#a)"/><path fill-rule="evenodd" clip-rule="evenodd" d="m9.524 25 1.175-7.483L13.753 25h1.41l3.217-7.483L19.555 25h3.524l-2.314-13H17.26l-2.71 6.931L11.818 12H8.313L6 25h3.524zm20.025-4.828 1.59-4.327 1.59 4.327h-3.18zM34.483 25h3.777l-5.187-13h-3.868L24.02 25h3.777l.813-2.259h5.06L34.483 25zm5.331-13v13h3.542V12h-3.542zm6.397 0v13H54v-2.862h-4.247V12H46.21zM13.968 37.539a7.359 7.359 0 0 0-1.265-.41 5.792 5.792 0 0 0-1.22-.129c-.727 0-1.423.135-2.086.406a5.447 5.447 0 0 0-2.947 2.86A5.312 5.312 0 0 0 6 42.473c0 .802.152 1.543.456 2.22a5.683 5.683 0 0 0 1.21 1.755A5.416 5.416 0 0 0 11.47 48a5.4 5.4 0 0 0 1.063-.105 8.472 8.472 0 0 0 1.16-.323l.276-.097v-3.206c-.69.738-1.469 1.105-2.333 1.105a2.769 2.769 0 0 1-2.59-1.74 2.997 2.997 0 0 1-.216-1.148c0-.406.072-.782.215-1.133.144-.351.337-.652.586-.907.248-.254.544-.453.89-.602.344-.147.72-.221 1.126-.221.92 0 1.693.381 2.32 1.147v-3.231zm4.419-.249H15.68v10.42h2.707v-4.298h3.908v4.298H25V37.29h-2.706v4.022h-3.908V37.29zm14.72 0h-5.924v10.42h5.924v-2.294H29.89v-1.797h3.038v-2.294H29.89v-1.74h3.217V37.29zm9.445.249a7.41 7.41 0 0 0-1.262-.41A5.857 5.857 0 0 0 40.067 37c-.727 0-1.423.135-2.085.406-.663.271-1.246.65-1.749 1.133a5.446 5.446 0 0 0-1.201 1.728 5.341 5.341 0 0 0-.447 2.203c0 .801.151 1.542.455 2.219a5.684 5.684 0 0 0 1.21 1.755 5.42 5.42 0 0 0 4.866 1.448c.36-.069.746-.177 1.16-.323l.276-.097V44.27c-.69.738-1.469 1.105-2.333 1.105a2.769 2.769 0 0 1-2.59-1.74 2.997 2.997 0 0 1-.216-1.148c0-.406.072-.782.215-1.133.144-.351.337-.652.586-.907.248-.254.544-.453.889-.602.345-.147.72-.221 1.127-.221.92 0 1.693.381 2.32 1.147v-3.231h.002zm4.42-.249h-2.707v10.42h2.706V43.19l3.522 4.519H54l-4.516-5.486 4.13-4.934h-3.342l-3.3 4.298V37.29zM54 29.5H6v3h48v-3z" fill="#fff"/><defs><linearGradient id="a" x1="0" y1="-1" x2="60" y2="60" gradientUnits="userSpaceOnUse"><stop stop-color="#4849C2"/><stop offset="1" stop-color="#2327A5"/></linearGradient></defs></svg>
|
After Width: | Height: | Size: 2 KiB |
|
@ -138,6 +138,7 @@
|
||||||
"dist/credentials/LingvaNexApi.credentials.js",
|
"dist/credentials/LingvaNexApi.credentials.js",
|
||||||
"dist/credentials/LinkedInOAuth2Api.credentials.js",
|
"dist/credentials/LinkedInOAuth2Api.credentials.js",
|
||||||
"dist/credentials/MailerLiteApi.credentials.js",
|
"dist/credentials/MailerLiteApi.credentials.js",
|
||||||
|
"dist/credentials/MailcheckApi.credentials.js",
|
||||||
"dist/credentials/MailchimpApi.credentials.js",
|
"dist/credentials/MailchimpApi.credentials.js",
|
||||||
"dist/credentials/MailchimpOAuth2Api.credentials.js",
|
"dist/credentials/MailchimpOAuth2Api.credentials.js",
|
||||||
"dist/credentials/MailgunApi.credentials.js",
|
"dist/credentials/MailgunApi.credentials.js",
|
||||||
|
@ -413,6 +414,7 @@
|
||||||
"dist/nodes/LinkedIn/LinkedIn.node.js",
|
"dist/nodes/LinkedIn/LinkedIn.node.js",
|
||||||
"dist/nodes/MailerLite/MailerLite.node.js",
|
"dist/nodes/MailerLite/MailerLite.node.js",
|
||||||
"dist/nodes/MailerLite/MailerLiteTrigger.node.js",
|
"dist/nodes/MailerLite/MailerLiteTrigger.node.js",
|
||||||
|
"dist/nodes/Mailcheck/Mailcheck.node.js",
|
||||||
"dist/nodes/Mailchimp/Mailchimp.node.js",
|
"dist/nodes/Mailchimp/Mailchimp.node.js",
|
||||||
"dist/nodes/Mailchimp/MailchimpTrigger.node.js",
|
"dist/nodes/Mailchimp/MailchimpTrigger.node.js",
|
||||||
"dist/nodes/Mailgun/Mailgun.node.js",
|
"dist/nodes/Mailgun/Mailgun.node.js",
|
||||||
|
|
Loading…
Reference in a new issue