@pipedream/brevo 0.1.1 → 0.1.2

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.
@@ -4,7 +4,7 @@ export default {
4
4
  key: "brevo-add-or-update-contact",
5
5
  name: "Add or Update a contact",
6
6
  description: "Add or Update a contact",
7
- version: "0.0.2",
7
+ version: "0.0.3",
8
8
  type: "action",
9
9
  props: {
10
10
  brevo,
@@ -56,9 +56,8 @@ export default {
56
56
  let contact = null;
57
57
  if (identifier) {
58
58
  try {
59
- contact = await this.brevo.existingContactByIdentifier(
60
- encodeURIComponent(identifier),
61
- );
59
+ contact = await this.brevo.existingContactByIdentifier($,
60
+ identifier);
62
61
  } catch (e) {
63
62
  contact = null;
64
63
  }
@@ -76,16 +75,25 @@ export default {
76
75
  $.export("Defined attributes", attributes);
77
76
 
78
77
  if (contact) {
79
- identifier = contact.id;
80
- const unlinkListIds = contact.listIds.filter((el) => !listIds.includes(el));
81
- await this.brevo.updateContact(
82
- $,
83
- identifier,
84
- attributes,
85
- listIds,
86
- unlinkListIds,
87
- );
88
- $.export("$summary", `Successfully updated contact "${identifier}"`);
78
+ try {
79
+ identifier = contact.id;
80
+ const unlinkListIds = contact.listIds.filter((el) => !listIds.includes(el));
81
+ await this.brevo.updateContact(
82
+ $,
83
+ identifier,
84
+ attributes,
85
+ listIds,
86
+ unlinkListIds,
87
+ );
88
+
89
+ $.export("$summary", `Successfully updated contact "${identifier}"`);
90
+ } catch ({ response: { data } }) {
91
+ let errorMessage = data.message;
92
+ if (data.message === "Contact already exist") {
93
+ errorMessage = `A contact with email ${this.email} already exists!`;
94
+ }
95
+ throw new Error(errorMessage);
96
+ }
89
97
  } else {
90
98
  const inserted = await this.brevo.addContact(
91
99
  $,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/brevo",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Pipedream Brevo Components",
5
5
  "main": "brevo.app.mjs",
6
6
  "keywords": [
@@ -13,6 +13,6 @@
13
13
  "access": "public"
14
14
  },
15
15
  "dependencies": {
16
- "@pipedream/platform": "^1.5.1"
16
+ "@pipedream/platform": "^3.0.0"
17
17
  }
18
18
  }