n8n-nodes-mailchimp-cmdesign 0.3.2 → 0.3.4
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.
@@ -3,28 +3,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createUpdateSubscriber = void 0;
|
4
4
|
const n8n_workflow_1 = require("n8n-workflow");
|
5
5
|
async function createUpdateSubscriber(apiUrl, apiKey) {
|
6
|
-
var _a;
|
7
6
|
const listId = this.getNodeParameter('listId', 0);
|
8
|
-
const email = this.getNodeParameter('email', 0);
|
9
7
|
const mapping = this.getNodeParameter('subscriberFieldMapping', 0);
|
10
8
|
const items = this.getInputData();
|
11
|
-
const
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
9
|
+
const members = items.map((item) => {
|
10
|
+
var _a;
|
11
|
+
const email = this.getNodeParameter('email', 0, item.index);
|
12
|
+
const mergeFields = {};
|
13
|
+
if (((_a = mapping === null || mapping === void 0 ? void 0 : mapping.subscriberFields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
14
|
+
for (const field of mapping.subscriberFields) {
|
15
|
+
const value = item.json[field.subscriberIncomingKey];
|
16
|
+
if (value !== undefined && value !== null && String(value).trim() !== '') {
|
17
|
+
mergeFields[field.mailChimpField] = String(value);
|
18
|
+
}
|
17
19
|
}
|
18
20
|
}
|
19
|
-
|
21
|
+
return {
|
22
|
+
email_address: email,
|
23
|
+
status: 'subscribed',
|
24
|
+
merge_fields: mergeFields,
|
25
|
+
};
|
26
|
+
});
|
20
27
|
const body = {
|
21
|
-
members
|
22
|
-
{
|
23
|
-
email_address: email,
|
24
|
-
status: 'subscribed',
|
25
|
-
merge_fields: mergeFields,
|
26
|
-
},
|
27
|
-
],
|
28
|
+
members,
|
28
29
|
update_existing: true,
|
29
30
|
};
|
30
31
|
try {
|
@@ -41,7 +42,7 @@ async function createUpdateSubscriber(apiUrl, apiKey) {
|
|
41
42
|
}
|
42
43
|
catch (error) {
|
43
44
|
throw new n8n_workflow_1.NodeApiError(this.getNode(), error, {
|
44
|
-
message: 'Hiba történt az
|
45
|
+
message: 'Hiba történt az előfizetők létrehozása/frissítése közben.',
|
45
46
|
});
|
46
47
|
}
|
47
48
|
}
|