n8n-nodes-mautic-advanced 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/nodes/MauticAdvanced/CompanyDescription.js +20 -0
- package/dist/nodes/MauticAdvanced/ContactDescription.js +14 -8
- package/dist/nodes/MauticAdvanced/MauticAdvanced.node.js +7 -9
- package/dist/nodes/MauticAdvanced/operations/CompanyOperations.js +18 -7
- package/dist/nodes/MauticAdvanced/operations/ContactOperations.js +1 -1
- package/dist/nodes/MauticAdvanced/utils/DataHelpers.js +6 -1
- package/package.json +1 -1
|
@@ -226,6 +226,16 @@ exports.companyFields = [
|
|
|
226
226
|
type: 'number',
|
|
227
227
|
default: 0,
|
|
228
228
|
},
|
|
229
|
+
{
|
|
230
|
+
displayName: 'Owner Name or ID',
|
|
231
|
+
name: 'owner',
|
|
232
|
+
type: 'options',
|
|
233
|
+
description: 'User to assign as company owner. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
|
234
|
+
typeOptions: {
|
|
235
|
+
loadOptionsMethod: 'getOwners',
|
|
236
|
+
},
|
|
237
|
+
default: '',
|
|
238
|
+
},
|
|
229
239
|
{
|
|
230
240
|
displayName: 'Overwrite With Blank',
|
|
231
241
|
name: 'overwriteWithBlank',
|
|
@@ -431,6 +441,16 @@ exports.companyFields = [
|
|
|
431
441
|
type: 'number',
|
|
432
442
|
default: 0,
|
|
433
443
|
},
|
|
444
|
+
{
|
|
445
|
+
displayName: 'Owner Name or ID',
|
|
446
|
+
name: 'owner',
|
|
447
|
+
type: 'options',
|
|
448
|
+
description: 'User to assign as company owner. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
|
449
|
+
typeOptions: {
|
|
450
|
+
loadOptionsMethod: 'getOwners',
|
|
451
|
+
},
|
|
452
|
+
default: '',
|
|
453
|
+
},
|
|
434
454
|
{
|
|
435
455
|
displayName: 'Overwrite With Blank',
|
|
436
456
|
name: 'overwriteWithBlank',
|
|
@@ -446,11 +446,14 @@ exports.contactFields = [
|
|
|
446
446
|
default: '',
|
|
447
447
|
},
|
|
448
448
|
{
|
|
449
|
-
displayName: 'Owner ID',
|
|
450
|
-
name: '
|
|
451
|
-
type: '
|
|
449
|
+
displayName: 'Owner Name or ID',
|
|
450
|
+
name: 'owner',
|
|
451
|
+
type: 'options',
|
|
452
|
+
description: 'User to assign as contact owner. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
|
453
|
+
typeOptions: {
|
|
454
|
+
loadOptionsMethod: 'getOwners',
|
|
455
|
+
},
|
|
452
456
|
default: '',
|
|
453
|
-
description: 'ID of a Mautic user to assign this contact to',
|
|
454
457
|
},
|
|
455
458
|
{
|
|
456
459
|
displayName: 'Phone',
|
|
@@ -1002,16 +1005,19 @@ exports.contactFields = [
|
|
|
1002
1005
|
default: '',
|
|
1003
1006
|
},
|
|
1004
1007
|
{
|
|
1005
|
-
displayName: 'Owner ID',
|
|
1006
|
-
name: '
|
|
1007
|
-
type: '
|
|
1008
|
+
displayName: 'Owner Name or ID',
|
|
1009
|
+
name: 'owner',
|
|
1010
|
+
type: 'options',
|
|
1011
|
+
description: 'User to assign as contact owner. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
|
1012
|
+
typeOptions: {
|
|
1013
|
+
loadOptionsMethod: 'getOwners',
|
|
1014
|
+
},
|
|
1008
1015
|
displayOptions: {
|
|
1009
1016
|
show: {
|
|
1010
1017
|
'/jsonParameters': [false],
|
|
1011
1018
|
},
|
|
1012
1019
|
},
|
|
1013
1020
|
default: '',
|
|
1014
|
-
description: 'ID of a Mautic user to assign this contact to',
|
|
1015
1021
|
},
|
|
1016
1022
|
{
|
|
1017
1023
|
displayName: 'Phone',
|
|
@@ -390,15 +390,13 @@ class MauticAdvanced {
|
|
|
390
390
|
// Get all the available owners (users) for filtering
|
|
391
391
|
async getOwners() {
|
|
392
392
|
const returnData = [];
|
|
393
|
-
const response = await GenericFunctions_1.mauticApiRequest.call(this, 'GET', '/
|
|
394
|
-
const
|
|
395
|
-
for (const
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
value: owner.id,
|
|
401
|
-
});
|
|
393
|
+
const response = await GenericFunctions_1.mauticApiRequest.call(this, 'GET', '/users');
|
|
394
|
+
const users = response?.users ? Object.values(response.users) : [];
|
|
395
|
+
for (const user of users) {
|
|
396
|
+
const fullName = `${user.firstName || ''} ${user.lastName || ''}`.trim();
|
|
397
|
+
const display = fullName || user.username || `User ${user.id}`;
|
|
398
|
+
const label = user.email ? `${display} (${user.email})` : display;
|
|
399
|
+
returnData.push({ name: label, value: user.id });
|
|
402
400
|
}
|
|
403
401
|
return returnData;
|
|
404
402
|
},
|
|
@@ -38,7 +38,7 @@ async function createCompany(context, itemIndex) {
|
|
|
38
38
|
const name = (0, ApiHelpers_1.getRequiredParam)(context, 'name', itemIndex);
|
|
39
39
|
const body = { companyname: name };
|
|
40
40
|
const additionalFields = (0, ApiHelpers_1.getOptionalParam)(context, 'additionalFields', itemIndex, {});
|
|
41
|
-
const { addressUi, customFieldsUi, companyEmail, fax, industry, numberOfEmployees, phone, website, annualRevenue, description, ...rest } = additionalFields;
|
|
41
|
+
const { addressUi, customFieldsUi, companyEmail, fax, industry, numberOfEmployees, owner, phone, website, annualRevenue, description, ...rest } = additionalFields;
|
|
42
42
|
if (addressUi?.addressValues) {
|
|
43
43
|
const { addressValues } = addressUi;
|
|
44
44
|
body.companyaddress1 = addressValues.address1;
|
|
@@ -56,6 +56,8 @@ async function createCompany(context, itemIndex) {
|
|
|
56
56
|
body.companyindustry = industry;
|
|
57
57
|
if (numberOfEmployees)
|
|
58
58
|
body.companynumber_of_employees = numberOfEmployees;
|
|
59
|
+
if (owner)
|
|
60
|
+
body.owner = owner;
|
|
59
61
|
if (phone)
|
|
60
62
|
body.companyphone = phone;
|
|
61
63
|
if (website)
|
|
@@ -73,7 +75,7 @@ async function createCompany(context, itemIndex) {
|
|
|
73
75
|
const response = await (0, ApiHelpers_1.makeApiRequest)(context, 'POST', '/companies/new', body);
|
|
74
76
|
let result = response.company;
|
|
75
77
|
if (simple) {
|
|
76
|
-
result = result
|
|
78
|
+
result = toSimpleCompany(result);
|
|
77
79
|
}
|
|
78
80
|
return result;
|
|
79
81
|
}
|
|
@@ -82,7 +84,7 @@ async function updateCompany(context, itemIndex) {
|
|
|
82
84
|
const simple = (0, ApiHelpers_1.getOptionalParam)(context, 'simple', itemIndex, false);
|
|
83
85
|
const body = {};
|
|
84
86
|
const updateFields = (0, ApiHelpers_1.getOptionalParam)(context, 'updateFields', itemIndex, {});
|
|
85
|
-
const { addressUi, customFieldsUi, companyEmail, name, fax, industry, numberOfEmployees, phone, website, annualRevenue, description, ...rest } = updateFields;
|
|
87
|
+
const { addressUi, customFieldsUi, companyEmail, name, fax, industry, numberOfEmployees, owner, phone, website, annualRevenue, description, ...rest } = updateFields;
|
|
86
88
|
if (addressUi?.addressValues) {
|
|
87
89
|
const { addressValues } = addressUi;
|
|
88
90
|
body.companyaddress1 = addressValues.address1;
|
|
@@ -102,6 +104,8 @@ async function updateCompany(context, itemIndex) {
|
|
|
102
104
|
body.companyindustry = industry;
|
|
103
105
|
if (numberOfEmployees)
|
|
104
106
|
body.companynumber_of_employees = numberOfEmployees;
|
|
107
|
+
if (owner)
|
|
108
|
+
body.owner = owner;
|
|
105
109
|
if (phone)
|
|
106
110
|
body.companyphone = phone;
|
|
107
111
|
if (website)
|
|
@@ -119,7 +123,7 @@ async function updateCompany(context, itemIndex) {
|
|
|
119
123
|
const response = await (0, ApiHelpers_1.makeApiRequest)(context, 'PATCH', `/companies/${companyId}/edit`, body);
|
|
120
124
|
let result = response.company;
|
|
121
125
|
if (simple) {
|
|
122
|
-
result = result
|
|
126
|
+
result = toSimpleCompany(result);
|
|
123
127
|
}
|
|
124
128
|
return result;
|
|
125
129
|
}
|
|
@@ -129,7 +133,7 @@ async function getCompany(context, itemIndex) {
|
|
|
129
133
|
const response = await (0, ApiHelpers_1.makeApiRequest)(context, 'GET', `/companies/${companyId}`);
|
|
130
134
|
let result = response.company;
|
|
131
135
|
if (simple) {
|
|
132
|
-
result = result
|
|
136
|
+
result = toSimpleCompany(result);
|
|
133
137
|
}
|
|
134
138
|
return (0, DataHelpers_1.convertNumericStrings)(result);
|
|
135
139
|
}
|
|
@@ -154,7 +158,7 @@ async function getAllCompanies(context, itemIndex) {
|
|
|
154
158
|
responseData = (response.companies ? Object.values(response.companies) : []);
|
|
155
159
|
}
|
|
156
160
|
if (simple) {
|
|
157
|
-
responseData = responseData.map((item) => item
|
|
161
|
+
responseData = responseData.map((item) => toSimpleCompany(item));
|
|
158
162
|
}
|
|
159
163
|
return (0, DataHelpers_1.convertNumericStrings)(responseData);
|
|
160
164
|
}
|
|
@@ -164,7 +168,14 @@ async function deleteCompany(context, itemIndex) {
|
|
|
164
168
|
const response = await (0, ApiHelpers_1.makeApiRequest)(context, 'DELETE', `/companies/${companyId}/delete`);
|
|
165
169
|
let result = response.company;
|
|
166
170
|
if (simple) {
|
|
167
|
-
result = result
|
|
171
|
+
result = toSimpleCompany(result);
|
|
168
172
|
}
|
|
169
173
|
return result;
|
|
170
174
|
}
|
|
175
|
+
function toSimpleCompany(company) {
|
|
176
|
+
return {
|
|
177
|
+
id: company.id,
|
|
178
|
+
owner: company.owner ?? null,
|
|
179
|
+
...company.fields.all,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
@@ -660,7 +660,7 @@ async function getContactsWithDncFilter(context, qs, options, limit) {
|
|
|
660
660
|
return contacts;
|
|
661
661
|
}
|
|
662
662
|
async function getContactOwners(context) {
|
|
663
|
-
const response = await (0, ApiHelpers_1.makeApiRequest)(context, 'GET', '/
|
|
663
|
+
const response = await (0, ApiHelpers_1.makeApiRequest)(context, 'GET', '/users');
|
|
664
664
|
return (0, DataHelpers_1.convertNumericStrings)(response);
|
|
665
665
|
}
|
|
666
666
|
async function getContactFields(context) {
|
|
@@ -33,7 +33,12 @@ function processContactFields(responseData, options, fieldsToReturn) {
|
|
|
33
33
|
}
|
|
34
34
|
return sourceData;
|
|
35
35
|
}
|
|
36
|
-
const processedData = sourceData.map((item) =>
|
|
36
|
+
const processedData = sourceData.map((item) => {
|
|
37
|
+
const all = item.fields?.all;
|
|
38
|
+
if (!all)
|
|
39
|
+
return item;
|
|
40
|
+
return { id: item.id, owner: item.owner ?? null, ...all };
|
|
41
|
+
});
|
|
37
42
|
if (Array.isArray(filterFields) && filterFields.length > 0) {
|
|
38
43
|
return processedData.map((item, index) => filterContactFields(item, sourceData[index], filterFields));
|
|
39
44
|
}
|
package/package.json
CHANGED