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 {
|
||||
responseData = await hunterApiRequest.call(this, method, resource, body, query);
|
||||
returnData.push.apply(returnData, responseData[propertyName]);
|
||||
returnData.push(responseData[propertyName]);
|
||||
query.offset += query.limit;
|
||||
} while (
|
||||
responseData.meta !== undefined &&
|
||||
|
|
|
@ -67,15 +67,26 @@ export class Hunter implements INodeType {
|
|||
operation: [
|
||||
'domainSearch',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
required: true,
|
||||
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',
|
||||
name: 'returnAll',
|
||||
|
@ -108,7 +119,7 @@ export class Hunter implements INodeType {
|
|||
minValue: 1,
|
||||
maxValue: 100,
|
||||
},
|
||||
default: 50,
|
||||
default: 100,
|
||||
description: 'How many results to return.',
|
||||
},
|
||||
{
|
||||
|
@ -219,7 +230,7 @@ export class Hunter implements INodeType {
|
|||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'emailFinder'
|
||||
'emailFinder',
|
||||
],
|
||||
},
|
||||
},
|
||||
|
@ -233,13 +244,13 @@ export class Hunter implements INodeType {
|
|||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'emailFinder'
|
||||
'emailFinder',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
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',
|
||||
|
@ -248,13 +259,13 @@ export class Hunter implements INodeType {
|
|||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'emailFinder'
|
||||
'emailFinder',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
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',
|
||||
|
@ -263,13 +274,13 @@ export class Hunter implements INodeType {
|
|||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'emailVerifier'
|
||||
'emailVerifier',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
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 filters = this.getNodeParameter('filters', i) as IDataObject;
|
||||
const domain = this.getNodeParameter('domain', i) as string;
|
||||
const onlyEmails = this.getNodeParameter('onlyEmails', i, false) as boolean;
|
||||
|
||||
qs.domain = domain;
|
||||
if (filters.type){
|
||||
qs.type = filters.type;
|
||||
|
@ -299,12 +312,42 @@ export class Hunter implements INodeType {
|
|||
}
|
||||
if (returnAll) {
|
||||
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 {
|
||||
const limit = this.getNodeParameter('limit', i) as number;
|
||||
qs.limit = limit;
|
||||
responseData = await hunterApiRequest.call(this, 'GET', '/domain-search', {}, qs);
|
||||
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
|
||||
if (operation === 'emailFinder') {
|
||||
|
|
Loading…
Reference in a new issue