Skip to content

Commit 9a2c399

Browse files
committed
[Components] bloomerang #16081
Sources - New Donation - New Constituent - New Interaction Actions - Create Donation - Create Constituent - Add Interaction
1 parent d9f205f commit 9a2c399

File tree

13 files changed

+1214
-513
lines changed

13 files changed

+1214
-513
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import bloomerang from "../../bloomerang.app.mjs";
2-
import { axios } from "@pipedream/platform";
2+
import {
3+
CHANNEL_OPTIONS, PURPOSE_OPTIONS,
4+
} from "../../common/constants.mjs";
35

46
export default {
57
key: "bloomerang-add-interaction",
68
name: "Add Interaction",
7-
description: "Adds an interaction to an existing constituent in Bloomerang. [See the documentation](https://bloomerang.co/product/integrations-data-management/api/rest-api/)",
9+
description: "Adds an interaction to an existing constituent in Bloomerang. [See the documentation](https://bloomerang.co/product/integrations-data-management/api/rest-api/#/Interactions/post_interaction)",
810
version: "0.0.1",
911
type: "action",
1012
props: {
@@ -15,43 +17,56 @@ export default {
1517
"constituentId",
1618
],
1719
},
18-
interactionType: {
19-
propDefinition: [
20-
bloomerang,
21-
"interactionType",
22-
],
20+
date: {
21+
type: "string",
22+
label: "Date",
23+
description: "The date of the interaction",
2324
},
24-
interactionDate: {
25-
propDefinition: [
26-
bloomerang,
27-
"interactionDate",
28-
],
25+
subject: {
26+
type: "string",
27+
label: "Subject",
28+
description: "The subject od the interation",
2929
},
30-
notes: {
31-
propDefinition: [
32-
bloomerang,
33-
"notes",
34-
],
30+
channel: {
31+
type: "string",
32+
label: "Channel",
33+
description: "The channel of the interation",
34+
options: CHANNEL_OPTIONS,
35+
},
36+
purpose: {
37+
type: "string",
38+
label: "Purpose",
39+
description: "The purpose of the interation",
40+
options: PURPOSE_OPTIONS,
41+
},
42+
note: {
43+
type: "string",
44+
label: "Note",
45+
description: "Note for the interaction",
3546
optional: true,
3647
},
37-
campaignId: {
38-
propDefinition: [
39-
bloomerang,
40-
"campaignId",
41-
],
48+
isInbound: {
49+
type: "boolean",
50+
label: "Is Inbound",
51+
description: "Was the interaction initiated by constituent?",
4252
optional: true,
4353
},
4454
},
4555
async run({ $ }) {
4656
const response = await this.bloomerang.createInteraction({
47-
constituentId: this.constituentId,
48-
interactionType: this.interactionType,
49-
interactionDate: this.interactionDate,
50-
notes: this.notes,
51-
campaignId: this.campaignId,
57+
$,
58+
data: {
59+
AccountId: this.constituentId,
60+
Date: this.date,
61+
Subject: this.subject,
62+
Channel: this.channel,
63+
Purpose: this.purpose,
64+
note: this.note,
65+
IsInbound: this.isInbound,
66+
},
5267
});
5368

54-
$.export("$summary", `Successfully added interaction with ID ${response.id}`);
69+
$.export("$summary", `Successfully added interaction with ID ${response.Id}`);
5570
return response;
5671
},
5772
};
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,162 @@
11
import bloomerang from "../../bloomerang.app.mjs";
2-
import { axios } from "@pipedream/platform";
2+
import {
3+
COMMUNICATION_CHANNEL_OPTIONS,
4+
CONSTITUENT_GENDER_OPTIONS,
5+
CONSTITUENT_PREFIX_OPTIONS,
6+
CONSTITUENT_STATUS_OPTIONS,
7+
CONSTITUENT_SUFFIX_OPTIONS,
8+
CONSTITUENT_TYPE_OPTIONS,
9+
} from "../../common/constants.mjs";
310

411
export default {
512
key: "bloomerang-create-constituent",
613
name: "Create Constituent",
7-
description: "Creates a new constituent in Bloomerang. [See the documentation](https://bloomerang.co/product/integrations-data-management/api/rest-api/)",
8-
version: "0.0.{{ts}}",
14+
description: "Creates a new constituent in Bloomerang. [See the documentation](https://bloomerang.co/product/integrations-data-management/api/rest-api/#/Constituents/post_constituent)",
15+
version: "0.0.1",
916
type: "action",
1017
props: {
1118
bloomerang,
12-
constituentType: {
13-
propDefinition: [
14-
bloomerang,
15-
"constituentType",
16-
],
19+
type: {
20+
type: "string",
21+
label: "Constituent Type",
22+
description: "Filter constituents by type",
23+
options: CONSTITUENT_TYPE_OPTIONS,
24+
reloadProps: true,
25+
},
26+
status: {
27+
type: "string",
28+
label: "Status",
29+
description: "The status of the constituent",
30+
options: CONSTITUENT_STATUS_OPTIONS,
31+
optional: true,
32+
},
33+
fullName: {
34+
type: "string",
35+
label: "Organization Name",
36+
description: "The organization's name of the constituent",
37+
hidden: true,
1738
},
18-
name: {
39+
firstName: {
1940
type: "string",
20-
label: "Name",
21-
description: "The name of the constituent",
41+
label: "First Name",
42+
description: "The first name of the constituent",
43+
hidden: true,
2244
},
23-
contactDetails: {
45+
lastName: {
2446
type: "string",
25-
label: "Contact Details",
26-
description: "Contact details of the constituent in JSON format",
47+
label: "Last Name",
48+
description: "The last name of the constituent",
49+
hidden: true,
2750
},
28-
address: {
51+
middleName: {
2952
type: "string",
30-
label: "Address",
31-
description: "Address of the constituent",
53+
label: "Middle Name",
54+
description: "The middle name of the constituent",
3255
optional: true,
3356
},
34-
tags: {
35-
type: "string[]",
36-
label: "Tags",
37-
description: "Tags for the constituent",
57+
prefix: {
58+
type: "string",
59+
label: "Title",
60+
description: "The prefix of the constituent",
61+
options: CONSTITUENT_PREFIX_OPTIONS,
3862
optional: true,
3963
},
40-
customFields: {
41-
type: "string[]",
42-
label: "Custom Fields",
43-
description: "Custom fields for the constituent in JSON format",
64+
suffix: {
65+
type: "string",
66+
label: "Suffix",
67+
description: "The suffix of the constituent",
68+
options: CONSTITUENT_SUFFIX_OPTIONS,
69+
optional: true,
70+
},
71+
jobTitle: {
72+
type: "string",
73+
label: "Job Title",
74+
description: "The job title of the constituent",
75+
optional: true,
76+
},
77+
gender: {
78+
type: "string",
79+
label: "Gender",
80+
description: "The gender of the constituent",
81+
options: CONSTITUENT_GENDER_OPTIONS,
82+
optional: true,
83+
},
84+
birthdate: {
85+
type: "string",
86+
label: "Birthdate",
87+
description: "The birth date of the constituent",
88+
optional: true,
89+
},
90+
employer: {
91+
type: "string",
92+
label: "Employer",
93+
description: "The employer of the constituent",
94+
optional: true,
95+
},
96+
website: {
97+
type: "string",
98+
label: "Website",
99+
description: "An website of the constituent",
100+
optional: true,
101+
},
102+
facebookId: {
103+
type: "string",
104+
label: "Facebook",
105+
description: "The constituent's facebook page",
106+
optional: true,
107+
},
108+
twitterId: {
109+
type: "string",
110+
label: "Twitter ID",
111+
description: "The constituent's twitter ID",
112+
optional: true,
113+
},
114+
linkedInId: {
115+
type: "string",
116+
label: "LinkedIn",
117+
description: "The constituent's linkedIn page",
118+
optional: true,
119+
},
120+
preferredCommunicationChannel: {
121+
type: "string",
122+
label: "Preferred Communication Channel",
123+
description: "The preferred comunication channel of the constituent",
124+
options: COMMUNICATION_CHANNEL_OPTIONS,
44125
optional: true,
45126
},
46127
},
128+
async additionalProps(props) {
129+
const isIndividual = this.type === "Individual";
130+
props.firstName.hidden = !isIndividual;
131+
props.lastName.hidden = !isIndividual;
132+
props.fullName.hidden = isIndividual;
133+
return {};
134+
},
47135
async run({ $ }) {
48-
const data = {
49-
constituentType: this.constituentType,
50-
name: this.name,
51-
contactDetails: JSON.parse(this.contactDetails),
52-
address: this.address
53-
? JSON.parse(this.address)
54-
: undefined,
55-
tags: this.tags,
56-
customFields: this.customFields
57-
? this.customFields.map(JSON.parse)
58-
: undefined,
59-
};
60-
61-
const response = await axios($, {
62-
method: "POST",
63-
url: `${this.bloomerang._baseUrl()}/constituents`,
64-
headers: {
65-
Authorization: `Bearer ${this.bloomerang.$auth.api_key}`,
136+
const response = await this.bloomerang.createConstituent({
137+
$,
138+
data: {
139+
Type: this.type,
140+
Status: this.status,
141+
FullName: this.fullName,
142+
FirstName: this.firstName,
143+
LastName: this.lastName,
144+
MiddleName: this.middleName,
145+
Prefix: this.prefix,
146+
Suffix: this.suffix,
147+
JobTitle: this.jobTitle,
148+
Gender: this.gender,
149+
Birthdate: this.birthdate,
150+
Employer: this.employer,
151+
Website: this.website,
152+
FacebookId: this.facebookId,
153+
TwitterId: this.twitterId,
154+
LinkedInId: this.linkedInId,
155+
PreferredCommunicationChannel: this.preferredCommunicationChannel,
66156
},
67-
data,
68157
});
69158

70-
$.export("$summary", `Successfully created constituent with ID ${response.id}`);
159+
$.export("$summary", `Successfully created constituent with ID ${response.Id}`);
71160
return response;
72161
},
73162
};

0 commit comments

Comments
 (0)