mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-12 05:17:28 -08:00
⚡ Minor improvements to Clearbit-Node
This commit is contained in:
parent
5784df637d
commit
cb6a1924d2
|
@ -16,7 +16,7 @@ import {
|
|||
} from './CompanyDescription';
|
||||
import {
|
||||
personOperations,
|
||||
personFields,
|
||||
personFields,
|
||||
} from './PersonDescription';
|
||||
|
||||
export class Clearbit implements INodeType {
|
||||
|
@ -82,9 +82,6 @@ export class Clearbit implements INodeType {
|
|||
const email = this.getNodeParameter('email', i) as string;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
qs.email = email;
|
||||
if (additionalFields.webhookUrl) {
|
||||
qs.webhook_url = additionalFields.webhookUrl as string;
|
||||
}
|
||||
if (additionalFields.givenName) {
|
||||
qs.given_name = additionalFields.givenName as string;
|
||||
}
|
||||
|
@ -103,8 +100,8 @@ export class Clearbit implements INodeType {
|
|||
if (additionalFields.companyDomain) {
|
||||
qs.company_domain = additionalFields.companyDomain as string;
|
||||
}
|
||||
if (additionalFields.linkedin) {
|
||||
qs.linkedin = additionalFields.linkedin as string;
|
||||
if (additionalFields.linkedIn) {
|
||||
qs.linkedin = additionalFields.linkedIn as string;
|
||||
}
|
||||
if (additionalFields.twitter) {
|
||||
qs.twitter = additionalFields.twitter as string;
|
||||
|
@ -120,9 +117,6 @@ export class Clearbit implements INodeType {
|
|||
const domain = this.getNodeParameter('domain', i) as string;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
qs.domain = domain;
|
||||
if (additionalFields.webhookUrl) {
|
||||
qs.webhook_url = additionalFields.webhookUrl as string;
|
||||
}
|
||||
if (additionalFields.companyName) {
|
||||
qs.company_name = additionalFields.companyName as string;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ export const companyOperations = [
|
|||
{
|
||||
name: 'Autocomplete',
|
||||
value: 'autocomplete',
|
||||
description: 'lets you auto-complete company names and retreive logo and domain',
|
||||
description: 'Lets you auto-complete company names and retreive logo and domain',
|
||||
},
|
||||
],
|
||||
default: 'enrich',
|
||||
|
@ -69,13 +69,6 @@ export const companyFields = [
|
|||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Webhook URL',
|
||||
name: 'webhookUrl',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'A webhook URL that results will be sent to.',
|
||||
},
|
||||
{
|
||||
displayName: 'Company Name',
|
||||
name: 'companyName',
|
||||
|
@ -83,6 +76,13 @@ export const companyFields = [
|
|||
default: '',
|
||||
description: 'The name of the company.',
|
||||
},
|
||||
{
|
||||
displayName: 'Facebook',
|
||||
name: 'facebook',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The Facebook URL for the company.',
|
||||
},
|
||||
{
|
||||
displayName: 'Linkedin',
|
||||
name: 'linkedin',
|
||||
|
@ -97,13 +97,6 @@ export const companyFields = [
|
|||
default: '',
|
||||
description: 'The Twitter handle for the company.',
|
||||
},
|
||||
{
|
||||
displayName: 'Facebook',
|
||||
name: 'facebook',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The Facebook URL for the company.',
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
|
|
@ -17,7 +17,7 @@ export async function clearbitApiRequest(this: IHookFunctions | IExecuteFunction
|
|||
method,
|
||||
qs,
|
||||
body,
|
||||
uri: uri ||`https://${api}.clearbit.com${resource}`,
|
||||
uri: uri ||`https://${api}-stream.clearbit.com${resource}`,
|
||||
json: true
|
||||
};
|
||||
options = Object.assign({}, options, option);
|
||||
|
@ -26,7 +26,18 @@ export async function clearbitApiRequest(this: IHookFunctions | IExecuteFunction
|
|||
}
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (err) {
|
||||
throw new Error(err);
|
||||
} catch (error) {
|
||||
if (error.statusCode === 401) {
|
||||
// Return a clear error
|
||||
throw new Error('The Clearbit credentials are not valid!');
|
||||
}
|
||||
|
||||
if (error.response.body && error.response.body.error && error.response.body.error.message) {
|
||||
// Try to return the error prettier
|
||||
throw new Error(`Clearbit Error [${error.statusCode}]: ${error.response.body.error.message}`);
|
||||
}
|
||||
|
||||
// If that data does not exist for some reason return the actual error
|
||||
throw new Error('Clearbit Error: ' + error.message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,18 +65,25 @@ export const personFields = [
|
|||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Webhook URL',
|
||||
name: 'webhookUrl',
|
||||
displayName: 'Company',
|
||||
name: 'company',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'A webhook URL that results will be sent to.',
|
||||
description: 'The name of the person’s employer.',
|
||||
},
|
||||
{
|
||||
displayName: 'Given Name',
|
||||
name: 'givenName',
|
||||
displayName: 'Company Domain',
|
||||
name: 'companyDomain',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'First name of person.',
|
||||
description: 'The domain for the person’s employer.',
|
||||
},
|
||||
{
|
||||
displayName: 'Facebook',
|
||||
name: 'facebook',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The Facebook URL for the person.',
|
||||
},
|
||||
{
|
||||
displayName: 'Family Name',
|
||||
|
@ -85,6 +92,13 @@ export const personFields = [
|
|||
default: '',
|
||||
description: 'Last name of person. If you have this, passing this is strongly recommended to improve match rates.',
|
||||
},
|
||||
{
|
||||
displayName: 'Given Name',
|
||||
name: 'givenName',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'First name of person.',
|
||||
},
|
||||
{
|
||||
displayName: 'IP Address',
|
||||
name: 'ipAddress',
|
||||
|
@ -100,22 +114,8 @@ export const personFields = [
|
|||
description: 'The city or country where the person resides.',
|
||||
},
|
||||
{
|
||||
displayName: 'Company',
|
||||
name: 'company',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The name of the person’s employer.',
|
||||
},
|
||||
{
|
||||
displayName: 'Company Domain',
|
||||
name: 'companyDomain',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The domain for the person’s employer.',
|
||||
},
|
||||
{
|
||||
displayName: 'Linkedin',
|
||||
name: 'linkedin',
|
||||
displayName: 'LinkedIn',
|
||||
name: 'linkedIn',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The LinkedIn URL for the person.',
|
||||
|
@ -127,13 +127,6 @@ export const personFields = [
|
|||
default: '',
|
||||
description: 'The Twitter handle for the person.',
|
||||
},
|
||||
{
|
||||
displayName: 'Facebook',
|
||||
name: 'facebook',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The Facebook URL for the person.',
|
||||
},
|
||||
],
|
||||
},
|
||||
] as INodeProperties[];
|
||||
|
|
|
@ -35,10 +35,10 @@
|
|||
"dist/credentials/BitbucketApi.credentials.js",
|
||||
"dist/credentials/BitlyApi.credentials.js",
|
||||
"dist/credentials/ChargebeeApi.credentials.js",
|
||||
"dist/credentials/ClearbitApi.credentials.js",
|
||||
"dist/credentials/ClickUpApi.credentials.js",
|
||||
"dist/credentials/CodaApi.credentials.js",
|
||||
"dist/credentials/CopperApi.credentials.js",
|
||||
"dist/credentials/ClearbitApi.credentials.js",
|
||||
"dist/credentials/DisqusApi.credentials.js",
|
||||
"dist/credentials/DropboxApi.credentials.js",
|
||||
"dist/credentials/EventbriteApi.credentials.js",
|
||||
|
@ -109,11 +109,11 @@
|
|||
"dist/nodes/Bitly/Bitly.node.js",
|
||||
"dist/nodes/Chargebee/Chargebee.node.js",
|
||||
"dist/nodes/Chargebee/ChargebeeTrigger.node.js",
|
||||
"dist/nodes/Clearbit/Clearbit.node.js",
|
||||
"dist/nodes/ClickUp/ClickUp.node.js",
|
||||
"dist/nodes/ClickUp/ClickUpTrigger.node.js",
|
||||
"dist/nodes/Coda/Coda.node.js",
|
||||
"dist/nodes/Copper/CopperTrigger.node.js",
|
||||
"dist/nodes/Clearbit/Clearbit.node.js",
|
||||
"dist/nodes/Cron.node.js",
|
||||
"dist/nodes/Discord/Discord.node.js",
|
||||
"dist/nodes/Disqus/Disqus.node.js",
|
||||
|
|
Loading…
Reference in a new issue