mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
🔀 Small improvements on Hunter-Node
This commit is contained in:
parent
eab4df1afd
commit
756d27e902
|
@ -45,7 +45,7 @@ export async function hunterApiRequestAllItems(this: IHookFunctions | IExecuteFu
|
||||||
|
|
||||||
do {
|
do {
|
||||||
responseData = await hunterApiRequest.call(this, method, resource, body, query);
|
responseData = await hunterApiRequest.call(this, method, resource, body, query);
|
||||||
returnData.push.apply(returnData, responseData[propertyName]);
|
returnData.push(responseData[propertyName]);
|
||||||
query.offset += query.limit;
|
query.offset += query.limit;
|
||||||
} while (
|
} while (
|
||||||
responseData.meta !== undefined &&
|
responseData.meta !== undefined &&
|
||||||
|
|
|
@ -67,15 +67,26 @@ export class Hunter implements INodeType {
|
||||||
operation: [
|
operation: [
|
||||||
'domainSearch',
|
'domainSearch',
|
||||||
],
|
],
|
||||||
returnAll: [
|
|
||||||
false,
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
default: '',
|
default: '',
|
||||||
required: true,
|
required: true,
|
||||||
description: 'Domain name from which you want to find the email addresses. For example, "stripe.com".',
|
description: 'Domain name from which you want to find the email addresses. For example, "stripe.com".',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Only Emails',
|
||||||
|
name: 'onlyEmails',
|
||||||
|
type: 'boolean',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
operation: [
|
||||||
|
'domainSearch',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: true,
|
||||||
|
description: 'Return only the the found emails.',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Return All',
|
displayName: 'Return All',
|
||||||
name: 'returnAll',
|
name: 'returnAll',
|
||||||
|
@ -108,7 +119,7 @@ export class Hunter implements INodeType {
|
||||||
minValue: 1,
|
minValue: 1,
|
||||||
maxValue: 100,
|
maxValue: 100,
|
||||||
},
|
},
|
||||||
default: 50,
|
default: 100,
|
||||||
description: 'How many results to return.',
|
description: 'How many results to return.',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -219,7 +230,7 @@ export class Hunter implements INodeType {
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
operation: [
|
operation: [
|
||||||
'emailFinder'
|
'emailFinder',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -233,13 +244,13 @@ export class Hunter implements INodeType {
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
operation: [
|
operation: [
|
||||||
'emailFinder'
|
'emailFinder',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
default: '',
|
default: '',
|
||||||
required: true,
|
required: true,
|
||||||
description: `The person's first name. It doesn't need to be in lowercase..`,
|
description: `The person's first name. It doesn't need to be in lowercase.`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Last Name',
|
displayName: 'Last Name',
|
||||||
|
@ -248,13 +259,13 @@ export class Hunter implements INodeType {
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
operation: [
|
operation: [
|
||||||
'emailFinder'
|
'emailFinder',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
default: '',
|
default: '',
|
||||||
required: true,
|
required: true,
|
||||||
description: `The person's last name. It doesn't need to be in lowercase..`,
|
description: `The person's last name. It doesn't need to be in lowercase.`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Email',
|
displayName: 'Email',
|
||||||
|
@ -263,13 +274,13 @@ export class Hunter implements INodeType {
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
operation: [
|
operation: [
|
||||||
'emailVerifier'
|
'emailVerifier',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
default: '',
|
default: '',
|
||||||
required: true,
|
required: true,
|
||||||
description: 'The email address you want to verify',
|
description: 'The email address you want to verify.',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
@ -287,6 +298,8 @@ export class Hunter implements INodeType {
|
||||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||||
const filters = this.getNodeParameter('filters', i) as IDataObject;
|
const filters = this.getNodeParameter('filters', i) as IDataObject;
|
||||||
const domain = this.getNodeParameter('domain', i) as string;
|
const domain = this.getNodeParameter('domain', i) as string;
|
||||||
|
const onlyEmails = this.getNodeParameter('onlyEmails', i, false) as boolean;
|
||||||
|
|
||||||
qs.domain = domain;
|
qs.domain = domain;
|
||||||
if (filters.type){
|
if (filters.type){
|
||||||
qs.type = filters.type;
|
qs.type = filters.type;
|
||||||
|
@ -299,12 +312,42 @@ export class Hunter implements INodeType {
|
||||||
}
|
}
|
||||||
if (returnAll) {
|
if (returnAll) {
|
||||||
responseData = await hunterApiRequestAllItems.call(this, 'data', 'GET', '/domain-search', {}, qs);
|
responseData = await hunterApiRequestAllItems.call(this, 'data', 'GET', '/domain-search', {}, qs);
|
||||||
|
|
||||||
|
// Make sure that the company information is there only once and
|
||||||
|
// the emails are combined underneath it.
|
||||||
|
if (onlyEmails === false) {
|
||||||
|
let tempReturnData: IDataObject = {};
|
||||||
|
|
||||||
|
for (let i = 0; i < responseData.length; i++) {
|
||||||
|
if (i === 0) {
|
||||||
|
tempReturnData = responseData[i];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
((tempReturnData as IDataObject).emails as IDataObject[]).push.apply(tempReturnData.emails, responseData[i].emails);
|
||||||
|
}
|
||||||
|
|
||||||
|
responseData = tempReturnData;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
const limit = this.getNodeParameter('limit', i) as number;
|
const limit = this.getNodeParameter('limit', i) as number;
|
||||||
qs.limit = limit;
|
qs.limit = limit;
|
||||||
responseData = await hunterApiRequest.call(this, 'GET', '/domain-search', {}, qs);
|
responseData = await hunterApiRequest.call(this, 'GET', '/domain-search', {}, qs);
|
||||||
responseData = responseData.data;
|
responseData = responseData.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (onlyEmails === true) {
|
||||||
|
let tempReturnData: IDataObject[] = [];
|
||||||
|
|
||||||
|
if (Array.isArray(responseData)) {
|
||||||
|
for (const data of responseData) {
|
||||||
|
tempReturnData.push.apply(tempReturnData, data.emails);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tempReturnData = responseData.emails;
|
||||||
|
}
|
||||||
|
|
||||||
|
responseData = tempReturnData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//https://hunter.io/api-documentation/v2#email-finder
|
//https://hunter.io/api-documentation/v2#email-finder
|
||||||
if (operation === 'emailFinder') {
|
if (operation === 'emailFinder') {
|
||||||
|
|
Loading…
Reference in a new issue