update lead done

This commit is contained in:
Ricardo Espinoza
2019-11-20 09:45:58 -05:00
parent b281eb511a
commit 503baf82f7
3 changed files with 90 additions and 5 deletions

View File

@@ -97,9 +97,9 @@ export class Intercom implements INodeType {
let responseData;
for (let i = 0; i < length; i++) {
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 (opeation === 'create') {
if (operation === 'create' || operation === 'update') {
const email = this.getNodeParameter('email', i) as string;
const options = this.getNodeParameter('options', i) as IDataObject;
const jsonActive = this.getNodeParameter('jsonParameters', i) as boolean;
@@ -144,6 +144,16 @@ export class Intercom implements INodeType {
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 {
responseData = await intercomApiRequest.call(this, '/contacts', 'POST', body);
} catch (err) {