mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 12:35:46 +03:00
* 🐛 Fix autocomplete API uri on Clearbit (#1565)
* 🐛 Fix autocomplete API uri * ⚡ Improvements * ⚡ Minor improvements Co-authored-by: dali <servfrdali@yahoo.fr> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
parent
9957c81f13
commit
00e7edea85
@ -1,19 +1,23 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
clearbitApiRequest,
|
||||
} from './GenericFunctions';
|
||||
|
||||
import {
|
||||
companyFields,
|
||||
companyOperations,
|
||||
} from './CompanyDescription';
|
||||
|
||||
import {
|
||||
personFields,
|
||||
personOperations,
|
||||
@ -23,7 +27,7 @@ export class Clearbit implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'Clearbit',
|
||||
name: 'clearbit',
|
||||
icon: 'file:clearbit.png',
|
||||
icon: 'file:clearbit.svg',
|
||||
group: ['output'],
|
||||
version: 1,
|
||||
subtitle: '={{$parameter["operation"] + ":" + $parameter["resource"]}}',
|
||||
@ -109,7 +113,7 @@ export class Clearbit implements INodeType {
|
||||
if (additionalFields.facebook) {
|
||||
qs.facebook = additionalFields.facebook as string;
|
||||
}
|
||||
responseData = await clearbitApiRequest.call(this, 'GET', resource, '/v2/people/find', {}, qs);
|
||||
responseData = await clearbitApiRequest.call(this, 'GET', `${resource}-stream`, '/v2/people/find', {}, qs);
|
||||
}
|
||||
}
|
||||
if (resource === 'company') {
|
||||
@ -129,7 +133,7 @@ export class Clearbit implements INodeType {
|
||||
if (additionalFields.facebook) {
|
||||
qs.facebook = additionalFields.facebook as string;
|
||||
}
|
||||
responseData = await clearbitApiRequest.call(this, 'GET', resource, '/v2/companies/find', {}, qs);
|
||||
responseData = await clearbitApiRequest.call(this, 'GET', `${resource}-stream`, '/v2/companies/find', {}, qs);
|
||||
}
|
||||
if (operation === 'autocomplete') {
|
||||
const name = this.getNodeParameter('name', i) as string;
|
||||
|
@ -13,16 +13,16 @@ export const companyOperations = [
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Enrich',
|
||||
value: 'enrich',
|
||||
description: 'Look up person and company data based on an email or domain',
|
||||
},
|
||||
{
|
||||
name: 'Autocomplete',
|
||||
value: 'autocomplete',
|
||||
description: 'Auto-complete company names and retrieve logo and domain',
|
||||
},
|
||||
{
|
||||
name: 'Enrich',
|
||||
value: 'enrich',
|
||||
description: 'Look up person and company data based on an email or domain',
|
||||
},
|
||||
],
|
||||
default: 'enrich',
|
||||
description: 'The operation to perform.',
|
||||
@ -31,9 +31,9 @@ export const companyOperations = [
|
||||
|
||||
export const companyFields = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* company:enrich */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* company:enrich */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Domain',
|
||||
name: 'domain',
|
||||
@ -99,25 +99,26 @@ export const companyFields = [
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* company:autocomplete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'company',
|
||||
],
|
||||
operation: [
|
||||
'autocomplete',
|
||||
],
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* company:autocomplete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'company',
|
||||
],
|
||||
operation: [
|
||||
'autocomplete',
|
||||
],
|
||||
},
|
||||
},
|
||||
description: 'Name is the partial name of the company.',
|
||||
},
|
||||
description: 'Name is the partial name of the company.',
|
||||
},
|
||||
] as INodeProperties[];
|
||||
|
@ -1,11 +1,17 @@
|
||||
import { OptionsWithUri } from 'request';
|
||||
import {
|
||||
OptionsWithUri,
|
||||
} from 'request';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
IExecuteSingleFunctions,
|
||||
IHookFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IDataObject } from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
export async function clearbitApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, api: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = this.getCredentials('clearbitApi');
|
||||
@ -13,11 +19,11 @@ export async function clearbitApiRequest(this: IHookFunctions | IExecuteFunction
|
||||
throw new Error('No credentials got returned!');
|
||||
}
|
||||
let options: OptionsWithUri = {
|
||||
headers: { Authorization: `Bearer ${credentials.apiKey}`},
|
||||
headers: { Authorization: `Bearer ${credentials.apiKey}` },
|
||||
method,
|
||||
qs,
|
||||
body,
|
||||
uri: uri ||`https://${api}-stream.clearbit.com${resource}`,
|
||||
uri: uri || `https://${api}.clearbit.com${resource}`,
|
||||
json: true,
|
||||
};
|
||||
options = Object.assign({}, options, option);
|
||||
|
@ -26,9 +26,9 @@ export const personOperations = [
|
||||
|
||||
export const personFields = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* person:enrich */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* person:enrich */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Email',
|
||||
name: 'email',
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 634 B |
21
packages/nodes-base/nodes/Clearbit/clearbit.svg
Normal file
21
packages/nodes-base/nodes/Clearbit/clearbit.svg
Normal file
@ -0,0 +1,21 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="72" height="72" viewBox="0 0 72 72">
|
||||
<defs>
|
||||
<linearGradient id="color-a" x1="50%" x2="100%" y1="0%" y2="100%">
|
||||
<stop offset="0%" stop-color="#DEF2FE"/>
|
||||
<stop offset="100%" stop-color="#DBF1FE"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="color-b" x1="0%" x2="50%" y1="0%" y2="100%">
|
||||
<stop offset="0%" stop-color="#57BCFD"/>
|
||||
<stop offset="100%" stop-color="#51B5FD"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="color-c" x1="37.5%" x2="62.5%" y1="0%" y2="100%">
|
||||
<stop offset="0%" stop-color="#1CA7FD"/>
|
||||
<stop offset="100%" stop-color="#148CFC"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<g fill="none" fill-rule="evenodd">
|
||||
<path fill="url(#color-a)" d="M72,36 L72,52.770861 L71.9958819,53.6375008 C71.9369091,59.6728148 71.2457056,61.9905403 69.9965047,64.3263428 C68.6892015,66.7707872 66.7707872,68.6892015 64.3263428,69.9965047 L64.0001583,70.1671829 C61.6579559,71.3643165 59.1600786,72 52.770861,72 L36,72 L36,36 L72,36 Z"/>
|
||||
<path fill="url(#color-b)" d="M64.3263428,2.00349528 C66.7707872,3.31079847 68.6892015,5.22921278 69.9965047,7.67365722 L70.1671829,7.99984171 C71.3643165,10.3420441 72,12.8399214 72,19.229139 L72,36 L36,36 L36,0 L52.770861,0 C59.4572515,0 61.8818983,0.696192084 64.3263428,2.00349528 Z"/>
|
||||
<path fill="url(#color-c)" d="M36,0 L36,72 L19.229139,72 L18.3624992,71.9958819 C12.3271852,71.9369091 10.0094597,71.2457056 7.67365722,69.9965047 C5.22921278,68.6892015 3.31079847,66.7707872 2.00349528,64.3263428 L1.83281705,64.0001583 C0.635683537,61.6579559 0,59.1600786 0,52.770861 L0,19.229139 C0,12.5427485 0.696192084,10.1181017 2.00349528,7.67365722 C3.31079847,5.22921278 5.22921278,3.31079847 7.67365722,2.00349528 L7.99984171,1.83281705 C10.3420441,0.635683537 12.8399214,0 19.229139,0 L36,0 Z"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.8 KiB |
Loading…
Reference in New Issue
Block a user