mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
feat(Mautic Node): add get contact by email
Many workflows have the user email but not the unique mautic ID, allow looking up the user by email.
This commit is contained in:
parent
c08d23c00f
commit
705d5d90b2
|
@ -42,6 +42,12 @@ export const contactOperations: INodeProperties[] = [
|
||||||
description: 'Get data of a contact',
|
description: 'Get data of a contact',
|
||||||
action: 'Get a contact',
|
action: 'Get a contact',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'Get By Email',
|
||||||
|
value: 'getByEmail',
|
||||||
|
description: 'Get data of a contact via email key',
|
||||||
|
action: 'Get a contact via email key',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'Get Many',
|
name: 'Get Many',
|
||||||
value: 'getAll',
|
value: 'getAll',
|
||||||
|
@ -473,6 +479,7 @@ export const contactFields: INodeProperties[] = [
|
||||||
},
|
},
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
displayName: 'JSON Parameters',
|
displayName: 'JSON Parameters',
|
||||||
name: 'jsonParameters',
|
name: 'jsonParameters',
|
||||||
|
@ -1111,7 +1118,21 @@ export const contactFields: INodeProperties[] = [
|
||||||
},
|
},
|
||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
/* contact:getByEmail */
|
||||||
|
/* -------------------------------------------------------------------------- */
|
||||||
|
{
|
||||||
|
displayName: 'Contact Email',
|
||||||
|
name: 'contactEmail',
|
||||||
|
type: 'string',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
operation: ['getByEmail'],
|
||||||
|
resource: ['contact'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* contact:getAll */
|
/* contact:getAll */
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
|
@ -828,6 +828,28 @@ export class Mautic implements INodeType {
|
||||||
responseData = responseData.map((item) => item.fields.all);
|
responseData = responseData.map((item) => item.fields.all);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//https://developer.mautic.org/?php#get-contact
|
||||||
|
if (operation === 'getByEmail') {
|
||||||
|
const options = this.getNodeParameter('options', i);
|
||||||
|
const email = this.getNodeParameter('contactEmail', i) as string;
|
||||||
|
const qs = {
|
||||||
|
'where[0][col]': 'email',
|
||||||
|
'where[0][expr]': 'eq',
|
||||||
|
'where[0][val]': email,
|
||||||
|
};
|
||||||
|
// const query = `where[0][col]=email&where[0][expr]=eq&where[0][val]=${email}&minimal=0`;
|
||||||
|
responseData = await mauticApiRequest.call(this, 'GET', '/contacts', {}, qs);
|
||||||
|
let result;
|
||||||
|
for (const key in responseData.contacts) {
|
||||||
|
result = responseData.contacts[key];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
responseData = [result];
|
||||||
|
if (options.rawData === false) {
|
||||||
|
responseData = responseData.map((item) => item.fields.all);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//https://developer.mautic.org/?php#list-contacts
|
//https://developer.mautic.org/?php#list-contacts
|
||||||
if (operation === 'getAll') {
|
if (operation === 'getAll') {
|
||||||
const returnAll = this.getNodeParameter('returnAll', i);
|
const returnAll = this.getNodeParameter('returnAll', i);
|
||||||
|
|
Loading…
Reference in a new issue