n8n-nodes-mailchimp-cmdesign 0.3.1 → 0.3.3

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,25 +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
- const mergeFields = {};
11
- if (((_a = mapping === null || mapping === void 0 ? void 0 : mapping.subscriberFields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
12
- for (const field of mapping.subscriberFields) {
13
- const value = this.evaluateExpression(field.subscriberIncomingKey, 0);
14
- mergeFields[field.mailChimpField] = String(value !== null && value !== void 0 ? value : '');
8
+ const items = this.getInputData();
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
+ }
19
+ }
15
20
  }
16
- }
21
+ return {
22
+ email_address: email,
23
+ status: 'subscribed',
24
+ merge_fields: mergeFields,
25
+ };
26
+ });
17
27
  const body = {
18
- members: [
19
- {
20
- email_address: email,
21
- status: 'subscribed',
22
- merge_fields: mergeFields,
23
- },
24
- ],
28
+ members,
25
29
  update_existing: true,
26
30
  };
27
31
  try {
@@ -38,7 +42,7 @@ async function createUpdateSubscriber(apiUrl, apiKey) {
38
42
  }
39
43
  catch (error) {
40
44
  throw new n8n_workflow_1.NodeApiError(this.getNode(), error, {
41
- message: 'Hiba történt az előfizető létrehozása/frissítése közben.',
45
+ message: 'Hiba történt az előfizetők létrehozása/frissítése közben.',
42
46
  });
43
47
  }
44
48
  }
@@ -33,7 +33,7 @@ const subscriberInputs = [
33
33
  },
34
34
  {
35
35
  displayName: 'MailchimpCm Field Name or ID',
36
- name: 'mailAirField',
36
+ name: 'mailChimpField',
37
37
  type: 'options',
38
38
  description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
39
39
  typeOptions: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-mailchimp-cmdesign",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "n8n node to interact with Mailchimp API",
5
5
  "main": "index.js",
6
6
  "scripts": {