mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 14:44:05 -08:00
✨ update lead done
This commit is contained in:
parent
b281eb511a
commit
503baf82f7
|
@ -97,9 +97,9 @@ export class Intercom implements INodeType {
|
||||||
let responseData;
|
let responseData;
|
||||||
for (let i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) {
|
||||||
const resource = this.getNodeParameter('resource', 0) as string;
|
const resource = this.getNodeParameter('resource', 0) as string;
|
||||||
const opeation = this.getNodeParameter('operation', 0) as string;
|
const operation = this.getNodeParameter('operation', 0) as string;
|
||||||
if (resource === 'lead') {
|
if (resource === 'lead') {
|
||||||
if (opeation === 'create') {
|
if (operation === 'create' || operation === 'update') {
|
||||||
const email = this.getNodeParameter('email', i) as string;
|
const email = this.getNodeParameter('email', i) as string;
|
||||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||||
const jsonActive = this.getNodeParameter('jsonParameters', i) as boolean;
|
const jsonActive = this.getNodeParameter('jsonParameters', i) as boolean;
|
||||||
|
@ -144,6 +144,16 @@ export class Intercom implements INodeType {
|
||||||
body.custom_attributes = customAttributesJson;
|
body.custom_attributes = customAttributesJson;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (operation === 'update') {
|
||||||
|
const updateBy = this.getNodeParameter('updateBy', 0) as string;
|
||||||
|
const value = this.getNodeParameter('value', i) as string;
|
||||||
|
if (updateBy === 'userId') {
|
||||||
|
body.user_id = value;
|
||||||
|
}
|
||||||
|
if (updateBy === 'id') {
|
||||||
|
body.id = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
responseData = await intercomApiRequest.call(this, '/contacts', 'POST', body);
|
responseData = await intercomApiRequest.call(this, '/contacts', 'POST', body);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
@ -18,6 +18,11 @@ export const leadOpeations = [
|
||||||
value: 'create',
|
value: 'create',
|
||||||
description: 'Create a new lead',
|
description: 'Create a new lead',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'Update',
|
||||||
|
value: 'update',
|
||||||
|
description: 'Update a new lead',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
default: '',
|
default: '',
|
||||||
description: 'The operation to perform.',
|
description: 'The operation to perform.',
|
||||||
|
@ -25,6 +30,55 @@ export const leadOpeations = [
|
||||||
] as INodeProperties[];
|
] as INodeProperties[];
|
||||||
|
|
||||||
export const leadFields = [
|
export const leadFields = [
|
||||||
|
{
|
||||||
|
displayName: 'Update By',
|
||||||
|
name: 'updateBy',
|
||||||
|
type: 'options',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'lead',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'update',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'User Id',
|
||||||
|
value: 'userId',
|
||||||
|
default: '',
|
||||||
|
description: 'Automatically generated identifier for the Lead',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Id',
|
||||||
|
value: 'id',
|
||||||
|
default: '',
|
||||||
|
description: 'The Intercom defined id representing the Lead',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
default: '',
|
||||||
|
description: 'Update by',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Value',
|
||||||
|
name: 'value',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
required: true,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'lead',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'update',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: 'Update by value',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Email',
|
displayName: 'Email',
|
||||||
name: 'email',
|
name: 'email',
|
||||||
|
@ -43,6 +97,24 @@ export const leadFields = [
|
||||||
},
|
},
|
||||||
description: 'The email of the user.',
|
description: 'The email of the user.',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Email',
|
||||||
|
name: 'email',
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
required: false,
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: [
|
||||||
|
'lead',
|
||||||
|
],
|
||||||
|
operation: [
|
||||||
|
'update',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
description: 'The email of the user.',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
displayName: 'JSON Parameters',
|
displayName: 'JSON Parameters',
|
||||||
name: 'jsonParameters',
|
name: 'jsonParameters',
|
||||||
|
@ -53,6 +125,7 @@ export const leadFields = [
|
||||||
show: {
|
show: {
|
||||||
operation: [
|
operation: [
|
||||||
'create',
|
'create',
|
||||||
|
'update',
|
||||||
],
|
],
|
||||||
resource: [
|
resource: [
|
||||||
'lead'
|
'lead'
|
||||||
|
@ -70,6 +143,7 @@ export const leadFields = [
|
||||||
show: {
|
show: {
|
||||||
operation: [
|
operation: [
|
||||||
'create',
|
'create',
|
||||||
|
'update',
|
||||||
],
|
],
|
||||||
resource: [
|
resource: [
|
||||||
'lead'
|
'lead'
|
||||||
|
@ -82,7 +156,6 @@ export const leadFields = [
|
||||||
name: 'phone',
|
name: 'phone',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: '',
|
default: '',
|
||||||
required: false,
|
|
||||||
description: 'The phone number of the user',
|
description: 'The phone number of the user',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -107,7 +180,6 @@ export const leadFields = [
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: false,
|
default: false,
|
||||||
options: [],
|
options: [],
|
||||||
required: false,
|
|
||||||
description: `A boolean value, which if true, instructs Intercom to update the users' last_request_at value to the current API service time in UTC. default value if not sent is false.`,
|
description: `A boolean value, which if true, instructs Intercom to update the users' last_request_at value to the current API service time in UTC. default value if not sent is false.`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -118,7 +190,6 @@ export const leadFields = [
|
||||||
loadOptionsMethod: 'getCompanies',
|
loadOptionsMethod: 'getCompanies',
|
||||||
},
|
},
|
||||||
default: [],
|
default: [],
|
||||||
required: false,
|
|
||||||
description: 'Identifies the companies this user belongs to.',
|
description: 'Identifies the companies this user belongs to.',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
@ -138,6 +209,7 @@ export const leadFields = [
|
||||||
],
|
],
|
||||||
operation: [
|
operation: [
|
||||||
'create',
|
'create',
|
||||||
|
'update',
|
||||||
],
|
],
|
||||||
jsonParameters: [
|
jsonParameters: [
|
||||||
true,
|
true,
|
||||||
|
@ -164,6 +236,7 @@ export const leadFields = [
|
||||||
],
|
],
|
||||||
operation: [
|
operation: [
|
||||||
'create',
|
'create',
|
||||||
|
'update',
|
||||||
],
|
],
|
||||||
jsonParameters: [
|
jsonParameters: [
|
||||||
false,
|
false,
|
||||||
|
|
|
@ -5,6 +5,8 @@ export interface ILeadCompany {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ILead {
|
export interface ILead {
|
||||||
|
user_id?: string;
|
||||||
|
id?: string;
|
||||||
email: string;
|
email: string;
|
||||||
phone?: string;
|
phone?: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
|
|
Loading…
Reference in a new issue