mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
Merge pull request #1142 from RicardoE105/feature/hubspot-extended
Feature/hubspot extended
This commit is contained in:
commit
2cc6f6c218
|
@ -100,39 +100,12 @@ export const dealFields = [
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
options: [
|
options: [
|
||||||
{
|
|
||||||
displayName: 'Deal Name',
|
|
||||||
name: 'dealName',
|
|
||||||
type: 'string',
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
displayName: 'Pipeline',
|
|
||||||
name: 'pipeline',
|
|
||||||
type: 'string',
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
displayName: 'Close Date',
|
|
||||||
name: 'closeDate',
|
|
||||||
type: 'dateTime',
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
displayName: 'Amount',
|
displayName: 'Amount',
|
||||||
name: 'amount',
|
name: 'amount',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
displayName: 'Deal Type',
|
|
||||||
name: 'dealType',
|
|
||||||
type: 'options',
|
|
||||||
typeOptions: {
|
|
||||||
loadOptionsMethod: 'getDealTypes',
|
|
||||||
},
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
displayName: 'Associated Company',
|
displayName: 'Associated Company',
|
||||||
name: 'associatedCompany',
|
name: 'associatedCompany',
|
||||||
|
@ -151,6 +124,68 @@ export const dealFields = [
|
||||||
},
|
},
|
||||||
default: [],
|
default: [],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Close Date',
|
||||||
|
name: 'closeDate',
|
||||||
|
type: 'dateTime',
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Custom Properties',
|
||||||
|
name: 'customPropertiesUi',
|
||||||
|
placeholder: 'Add Custom Property',
|
||||||
|
type: 'fixedCollection',
|
||||||
|
typeOptions: {
|
||||||
|
multipleValues: true,
|
||||||
|
},
|
||||||
|
default: {},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'customPropertiesValues',
|
||||||
|
displayName: 'Custom Property',
|
||||||
|
values: [
|
||||||
|
{
|
||||||
|
displayName: 'Property',
|
||||||
|
name: 'property',
|
||||||
|
type: 'options',
|
||||||
|
typeOptions: {
|
||||||
|
loadOptionsMethod: 'getDealCustomProperties',
|
||||||
|
},
|
||||||
|
default: '',
|
||||||
|
description: 'Name of the property.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Value',
|
||||||
|
name: 'value',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
description: 'Value of the property',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Deal Name',
|
||||||
|
name: 'dealName',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Deal Type',
|
||||||
|
name: 'dealType',
|
||||||
|
type: 'options',
|
||||||
|
typeOptions: {
|
||||||
|
loadOptionsMethod: 'getDealTypes',
|
||||||
|
},
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Pipeline',
|
||||||
|
name: 'pipeline',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
@ -191,6 +226,53 @@ export const dealFields = [
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
options: [
|
options: [
|
||||||
|
{
|
||||||
|
displayName: 'Amount',
|
||||||
|
name: 'amount',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Close Date',
|
||||||
|
name: 'closeDate',
|
||||||
|
type: 'dateTime',
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Custom Properties',
|
||||||
|
name: 'customPropertiesUi',
|
||||||
|
placeholder: 'Add Custom Property',
|
||||||
|
type: 'fixedCollection',
|
||||||
|
typeOptions: {
|
||||||
|
multipleValues: true,
|
||||||
|
},
|
||||||
|
default: {},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'customPropertiesValues',
|
||||||
|
displayName: 'Custom Property',
|
||||||
|
values: [
|
||||||
|
{
|
||||||
|
displayName: 'Property',
|
||||||
|
name: 'property',
|
||||||
|
type: 'options',
|
||||||
|
typeOptions: {
|
||||||
|
loadOptionsMethod: 'getDealCustomProperties',
|
||||||
|
},
|
||||||
|
default: '',
|
||||||
|
description: 'Name of the property.',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Value',
|
||||||
|
name: 'value',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
description: 'Value of the property',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Deal Name',
|
displayName: 'Deal Name',
|
||||||
name: 'dealName',
|
name: 'dealName',
|
||||||
|
@ -208,24 +290,6 @@ export const dealFields = [
|
||||||
default: '',
|
default: '',
|
||||||
description: 'The dealstage is required when creating a deal. See the CRM Pipelines API for details on managing pipelines and stages.',
|
description: 'The dealstage is required when creating a deal. See the CRM Pipelines API for details on managing pipelines and stages.',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
displayName: 'Pipeline',
|
|
||||||
name: 'pipeline',
|
|
||||||
type: 'string',
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
displayName: 'Close Date',
|
|
||||||
name: 'closeDate',
|
|
||||||
type: 'dateTime',
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
displayName: 'Amount',
|
|
||||||
name: 'amount',
|
|
||||||
type: 'string',
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
displayName: 'Deal Type',
|
displayName: 'Deal Type',
|
||||||
name: 'dealType',
|
name: 'dealType',
|
||||||
|
@ -235,6 +299,12 @@ export const dealFields = [
|
||||||
},
|
},
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Pipeline',
|
||||||
|
name: 'pipeline',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
|
@ -552,6 +552,25 @@ export class Hubspot implements INodeType {
|
||||||
}
|
}
|
||||||
return returnData;
|
return returnData;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Get all the deal properties to display them to user so that he can
|
||||||
|
// select them easily
|
||||||
|
async getDealCustomProperties(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||||
|
const returnData: INodePropertyOptions[] = [];
|
||||||
|
const endpoint = '/properties/v2/deals/properties';
|
||||||
|
const properties = await hubspotApiRequest.call(this, 'GET', endpoint, {});
|
||||||
|
for (const property of properties) {
|
||||||
|
if (property.hubspotDefined === null) {
|
||||||
|
const propertyName = property.label;
|
||||||
|
const propertyId = property.name;
|
||||||
|
returnData.push({
|
||||||
|
name: propertyName,
|
||||||
|
value: propertyId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnData;
|
||||||
|
},
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* FORM */
|
/* FORM */
|
||||||
|
@ -1801,6 +1820,17 @@ export class Hubspot implements INodeType {
|
||||||
value: additionalFields.pipeline as string,
|
value: additionalFields.pipeline as string,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (additionalFields.customPropertiesUi) {
|
||||||
|
const customProperties = (additionalFields.customPropertiesUi as IDataObject).customPropertiesValues as IDataObject[];
|
||||||
|
if (customProperties) {
|
||||||
|
for (const customProperty of customProperties) {
|
||||||
|
body.properties.push({
|
||||||
|
name: customProperty.property,
|
||||||
|
value: customProperty.value,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
body.associations = association;
|
body.associations = association;
|
||||||
const endpoint = '/deals/v1/deal';
|
const endpoint = '/deals/v1/deal';
|
||||||
responseData = await hubspotApiRequest.call(this, 'POST', endpoint, body);
|
responseData = await hubspotApiRequest.call(this, 'POST', endpoint, body);
|
||||||
|
@ -1846,6 +1876,17 @@ export class Hubspot implements INodeType {
|
||||||
value: updateFields.pipeline as string,
|
value: updateFields.pipeline as string,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (updateFields.customPropertiesUi) {
|
||||||
|
const customProperties = (updateFields.customPropertiesUi as IDataObject).customPropertiesValues as IDataObject[];
|
||||||
|
if (customProperties) {
|
||||||
|
for (const customProperty of customProperties) {
|
||||||
|
body.properties.push({
|
||||||
|
name: customProperty.property,
|
||||||
|
value: customProperty.value,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
const endpoint = `/deals/v1/deal/${dealId}`;
|
const endpoint = `/deals/v1/deal/${dealId}`;
|
||||||
responseData = await hubspotApiRequest.call(this, 'PUT', endpoint, body);
|
responseData = await hubspotApiRequest.call(this, 'PUT', endpoint, body);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue