Skip to content

Commit db6687e

Browse files
New Components - benchmarkone (#15668)
* benchmarkone init * [Components] benchmarkone #15631 Sources - New Webhook Automation Event (Instant) Actions - Add Note - Add Tag - Create Contact - Update Contact * pnpm update * pnpm update * Update components/benchmarkone/sources/new-webhook-automation-event-instant/new-webhook-automation-event-instant.mjs * some adjusts --------- Co-authored-by: Leo Vu <[email protected]>
1 parent 915a70a commit db6687e

File tree

10 files changed

+834
-6
lines changed

10 files changed

+834
-6
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import benchmarkone from "../../benchmarkone.app.mjs";
3+
4+
export default {
5+
key: "benchmarkone-add-note",
6+
name: "Add Note to Contact",
7+
description: "Adds a note to a BenchmarkONE contact. [See the documentation](https://sandbox.hatchbuck.com/api/dist/#!/Notes/post_contact_email_address_or_contact_ID_notes).",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
benchmarkone,
12+
contactId: {
13+
propDefinition: [
14+
benchmarkone,
15+
"contactId",
16+
],
17+
},
18+
subject: {
19+
type: "string",
20+
label: "Subject",
21+
description: "Subject line for the note.",
22+
},
23+
body: {
24+
type: "string",
25+
label: "Body",
26+
description: "Body of the note.",
27+
},
28+
copyToCompany: {
29+
type: "boolean",
30+
label: "Copy To Company",
31+
description: "Copy this note to the contact's associated company record.",
32+
optional: true,
33+
},
34+
},
35+
async run({ $ }) {
36+
try {
37+
const response = await this.benchmarkone.addNoteToContact({
38+
$,
39+
contactId: this.contactId,
40+
data: {
41+
subject: this.subject,
42+
body: this.body,
43+
copyToCompany: this.copyToCompany,
44+
},
45+
});
46+
47+
$.export("$summary", `Added note to contact with ID ${this.contactId}`);
48+
49+
return response;
50+
} catch (error) {
51+
throw new ConfigurationError(error.message);
52+
}
53+
},
54+
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import benchmarkone from "../../benchmarkone.app.mjs";
2+
import { parseObject } from "../../common/utils.mjs";
3+
4+
export default {
5+
key: "benchmarkone-add-tag",
6+
name: "Add Tag to Contact",
7+
description: "Adds tags to a contact. If the contact does not exist, it will be created first. [See the documentation](https://sandbox.hatchbuck.com/api/dist/#/Tags).",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
benchmarkone,
12+
contactId: {
13+
propDefinition: [
14+
benchmarkone,
15+
"contactId",
16+
],
17+
},
18+
tags: {
19+
type: "string[]",
20+
label: "Tags",
21+
description: "A list of tags to add to the contact.",
22+
},
23+
},
24+
async run({ $ }) {
25+
const response = await this.benchmarkone.addTagToContact({
26+
contactId: this.contactId,
27+
data: parseObject(this.tags)?.map((item) => ({
28+
name: item,
29+
})),
30+
});
31+
32+
$.export("$summary", `Succcessfully added tags to contact ID ${this.contactId}`);
33+
return response;
34+
},
35+
};
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import benchmarkone from "../../benchmarkone.app.mjs";
3+
import { parseObject } from "../../common/utils.mjs";
4+
5+
export default {
6+
key: "benchmarkone-create-contact",
7+
name: "Create Contact",
8+
description: "Creates a new contact in BenchmarkONE. [See the documentation](https://sandbox.hatchbuck.com/api/dist/#!/Contacts/post_contact)",
9+
version: "0.0.1",
10+
type: "action",
11+
props: {
12+
benchmarkone,
13+
firstName: {
14+
propDefinition: [
15+
benchmarkone,
16+
"firstName",
17+
],
18+
optional: true,
19+
},
20+
lastName: {
21+
propDefinition: [
22+
benchmarkone,
23+
"lastName",
24+
],
25+
optional: true,
26+
},
27+
title: {
28+
propDefinition: [
29+
benchmarkone,
30+
"title",
31+
],
32+
optional: true,
33+
},
34+
company: {
35+
propDefinition: [
36+
benchmarkone,
37+
"company",
38+
],
39+
optional: true,
40+
},
41+
workEmail: {
42+
propDefinition: [
43+
benchmarkone,
44+
"workEmail",
45+
],
46+
optional: true,
47+
},
48+
homeEmail: {
49+
propDefinition: [
50+
benchmarkone,
51+
"homeEmail",
52+
],
53+
optional: true,
54+
},
55+
workPhone: {
56+
propDefinition: [
57+
benchmarkone,
58+
"workPhone",
59+
],
60+
optional: true,
61+
},
62+
homePhone: {
63+
propDefinition: [
64+
benchmarkone,
65+
"homePhone",
66+
],
67+
optional: true,
68+
},
69+
workAddress: {
70+
propDefinition: [
71+
benchmarkone,
72+
"workAddress",
73+
],
74+
optional: true,
75+
},
76+
homeAddress: {
77+
propDefinition: [
78+
benchmarkone,
79+
"homeAddress",
80+
],
81+
optional: true,
82+
},
83+
status: {
84+
propDefinition: [
85+
benchmarkone,
86+
"status",
87+
],
88+
},
89+
temperature: {
90+
propDefinition: [
91+
benchmarkone,
92+
"temperature",
93+
],
94+
optional: true,
95+
},
96+
website: {
97+
propDefinition: [
98+
benchmarkone,
99+
"website",
100+
],
101+
optional: true,
102+
},
103+
},
104+
async run({ $ }) {
105+
try {
106+
const emails = [];
107+
if (this.workEmail) {
108+
emails.push({
109+
address: this.workEmail,
110+
type: "Work",
111+
});
112+
}
113+
if (this.homeEmail) {
114+
emails.push({
115+
address: this.homeEmail,
116+
type: "Home",
117+
});
118+
}
119+
const phones = [];
120+
if (this.workPhone) {
121+
phones.push({
122+
number: this.workPhone,
123+
type: "Work",
124+
});
125+
}
126+
if (this.homePhone) {
127+
phones.push({
128+
number: this.homePhone,
129+
type: "Home",
130+
});
131+
}
132+
const addresses = [];
133+
if (this.workAddress) {
134+
addresses.push({
135+
...parseObject(this.workAddress),
136+
type: "Work",
137+
});
138+
}
139+
if (this.homeAddress) {
140+
addresses.push({
141+
...parseObject(this.homeAddress),
142+
type: "Home",
143+
});
144+
}
145+
146+
const data = {
147+
contactId: this.contactId,
148+
firstName: this.firstName,
149+
lastName: this.lastName,
150+
emails,
151+
phones,
152+
addresses,
153+
};
154+
if (this.status) {
155+
data.status = {
156+
name: this.status.label,
157+
id: this.status.value,
158+
};
159+
}
160+
if (this.temperature) {
161+
data.temperature = {
162+
name: this.temperature.label,
163+
id: this.temperature.value,
164+
};
165+
}
166+
if (this.website) {
167+
data.website = [
168+
{
169+
websiteUrl: this.website,
170+
},
171+
];
172+
}
173+
const response = await this.benchmarkone.createContact({
174+
$,
175+
data,
176+
});
177+
$.export("$summary", `Created contact with ID: ${response.contactId}`);
178+
return response;
179+
} catch (error) {
180+
throw new ConfigurationError(`Failed to create contact: ${error.message}`);
181+
}
182+
},
183+
};

0 commit comments

Comments
 (0)