Add email field to Mautic-Node

This commit is contained in:
Jan Oberhauser 2020-01-30 11:45:50 -08:00
parent fb6c939e8d
commit 2f6bab36b2
2 changed files with 43 additions and 10 deletions

View file

@ -66,6 +66,26 @@ export const contactFields = [
},
},
},
{
displayName: 'Email',
name: 'email',
type: 'string',
displayOptions: {
show: {
resource: [
'contact',
],
operation: [
'create',
],
jsonParameters: [
false,
]
},
},
default: '',
description: 'Email address of the contact.',
},
{
displayName: 'First Name',
name: 'firstName',
@ -298,6 +318,20 @@ export const contactFields = [
default: '',
description: 'Contact parameters',
},
{
displayName: 'Email',
name: 'email',
type: 'string',
displayOptions: {
show: {
'/jsonParameters': [
false,
],
},
},
default: '',
description: 'Email address of the contact.',
},
{
displayName: 'First Name',
name: 'firstName',

View file

@ -106,16 +106,12 @@ export class Mautic implements INodeType {
const jsonActive = this.getNodeParameter('jsonParameters', i) as boolean;
let body: IDataObject = {};
if (!jsonActive) {
const firstName = this.getNodeParameter('firstName', i) as string;
const lastName = this.getNodeParameter('lastName', i) as string;
const company = this.getNodeParameter('company', i) as string;
const position = this.getNodeParameter('position', i) as string;
const title = this.getNodeParameter('title', i) as string;
body.firstname = firstName;
body.lastname = lastName;
body.company = company;
body.position = position;
body.title = title;
body.email = this.getNodeParameter('email', i) as string;
body.firstname = this.getNodeParameter('firstName', i) as string;
body.lastname = this.getNodeParameter('lastName', i) as string;
body.company = this.getNodeParameter('company', i) as string;
body.position = this.getNodeParameter('position', i) as string;
body.title = this.getNodeParameter('title', i) as string;
} else {
const json = validateJSON(this.getNodeParameter('bodyJson', i) as string);
if (json !== undefined) {
@ -145,6 +141,9 @@ export class Mautic implements INodeType {
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
const contactId = this.getNodeParameter('contactId', i) as string;
let body: IDataObject = {};
if (updateFields.email) {
body.email = updateFields.email as string;
}
if (updateFields.firstName) {
body.firstname = updateFields.firstName as string;
}