Skip to content

Commit ec2a57e

Browse files
committed
[Components] benchmarkone #15631
Sources - New Webhook Automation Event (Instant) Actions - Add Note - Add Tag - Create Contact - Update Contact
1 parent 4f18977 commit ec2a57e

File tree

11 files changed

+551
-513
lines changed

11 files changed

+551
-513
lines changed
Lines changed: 23 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import { ConfigurationError } from "@pipedream/platform";
12
import benchmarkone from "../../benchmarkone.app.mjs";
2-
import { axios } from "@pipedream/platform";
33

44
export default {
55
key: "benchmarkone-add-note",
66
name: "Add Note to Contact",
7-
description: "Adds a note to a BenchmarkONE contact. [See the documentation]().",
8-
version: "0.0.{{ts}}",
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",
99
type: "action",
1010
props: {
1111
benchmarkone,
@@ -15,84 +15,40 @@ export default {
1515
"contactId",
1616
],
1717
},
18-
contactEmail: {
19-
propDefinition: [
20-
benchmarkone,
21-
"contactEmail",
22-
],
23-
optional: true,
24-
},
25-
noteContent: {
26-
propDefinition: [
27-
benchmarkone,
28-
"noteContent",
29-
],
18+
subject: {
19+
type: "string",
20+
label: "Subject",
21+
description: "Subject line for the note.",
3022
},
31-
firstName: {
32-
propDefinition: [
33-
benchmarkone,
34-
"firstName",
35-
],
36-
optional: true,
23+
body: {
24+
type: "string",
25+
label: "Body",
26+
description: "Body of the note.",
3727
},
38-
lastName: {
39-
propDefinition: [
40-
benchmarkone,
41-
"lastName",
42-
],
43-
optional: true,
44-
},
45-
email: {
46-
propDefinition: [
47-
benchmarkone,
48-
"email",
49-
],
50-
optional: true,
51-
},
52-
phoneNumbers: {
53-
propDefinition: [
54-
benchmarkone,
55-
"phoneNumbers",
56-
],
57-
optional: true,
58-
},
59-
addresses: {
60-
propDefinition: [
61-
benchmarkone,
62-
"addresses",
63-
],
28+
copyToCompany: {
29+
type: "boolean",
30+
label: "Copy To Company",
31+
description: "Copy this note to the contact's associated company record.",
6432
optional: true,
6533
},
6634
},
6735
async run({ $ }) {
6836
try {
69-
if (!this.contactId && !this.contactEmail) {
70-
throw new Error("Either contactId or contactEmail must be provided.");
71-
}
72-
7337
const response = await this.benchmarkone.addNoteToContact({
38+
$,
7439
contactId: this.contactId,
75-
contactEmail: this.contactEmail,
76-
firstName: this.firstName,
77-
lastName: this.lastName,
78-
email: this.email,
79-
phoneNumbers: this.phoneNumbers,
80-
addresses: this.addresses,
81-
noteContent: this.noteContent,
40+
data: {
41+
subject: this.subject,
42+
body: this.body,
43+
copyToCompany: this.copyToCompany,
44+
},
8245
});
8346

84-
if (response && response.contactId) {
85-
$.export("$summary", `Added note to contact with ID ${response.contactId}`);
86-
} else if (this.contactEmail) {
87-
$.export("$summary", `Added note to contact with email ${this.contactEmail}`);
88-
} else {
89-
$.export("$summary", "Added note to contact");
90-
}
47+
$.export("$summary", `Added note to contact with ID ${this.contactId}`);
9148

9249
return response;
9350
} catch (error) {
94-
$.export("$summary", `Failed to add note: ${error.message}`);
95-
throw error;
51+
throw new ConfigurationError(error.message);
9652
}
9753
},
9854
};
Lines changed: 11 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,35 @@
11
import benchmarkone from "../../benchmarkone.app.mjs";
2-
import { axios } from "@pipedream/platform";
2+
import { parseObject } from "../../common/utils.mjs";
33

44
export default {
55
key: "benchmarkone-add-tag",
66
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]().",
8-
version: "0.0.{{ts}}",
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",
99
type: "action",
1010
props: {
1111
benchmarkone,
12-
tagNames: {
13-
propDefinition: [
14-
benchmarkone,
15-
"tagNames",
16-
],
17-
},
18-
email: {
19-
propDefinition: [
20-
benchmarkone,
21-
"email",
22-
],
23-
},
2412
contactId: {
2513
propDefinition: [
2614
benchmarkone,
2715
"contactId",
2816
],
29-
optional: true,
3017
},
31-
contactEmail: {
32-
propDefinition: [
33-
benchmarkone,
34-
"contactEmail",
35-
],
36-
optional: true,
37-
},
38-
firstName: {
39-
propDefinition: [
40-
benchmarkone,
41-
"firstName",
42-
],
43-
optional: true,
44-
},
45-
lastName: {
46-
propDefinition: [
47-
benchmarkone,
48-
"lastName",
49-
],
50-
optional: true,
51-
},
52-
phoneNumbers: {
53-
propDefinition: [
54-
benchmarkone,
55-
"phoneNumbers",
56-
],
57-
optional: true,
58-
},
59-
addresses: {
60-
propDefinition: [
61-
benchmarkone,
62-
"addresses",
63-
],
64-
optional: true,
18+
tags: {
19+
type: "string[]",
20+
label: "Tags",
21+
description: "A list of tags to add to the contact.",
6522
},
6623
},
6724
async run({ $ }) {
6825
const response = await this.benchmarkone.addTagToContact({
6926
contactId: this.contactId,
70-
contactEmail: this.contactEmail,
71-
firstName: this.firstName,
72-
lastName: this.lastName,
73-
email: this.email,
74-
phoneNumbers: this.phoneNumbers,
75-
addresses: this.addresses,
76-
tagNames: this.tagNames,
27+
data: parseObject(this.tags)?.map((item) => ({
28+
name: item,
29+
})),
7730
});
7831

79-
const contactId = response.contactId;
80-
const addedTags = this.tagNames.join(", ");
81-
$.export("$summary", `Added tags [${addedTags}] to contact ID ${contactId}`);
32+
$.export("$summary", `Succcessfully added tags to contact ID ${this.contactId}`);
8233
return response;
8334
},
8435
};
Lines changed: 74 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import { ConfigurationError } from "@pipedream/platform";
12
import benchmarkone from "../../benchmarkone.app.mjs";
2-
import { axios } from "@pipedream/platform";
3+
import { parseObject } from "../../common/utils.mjs";
34

45
export default {
56
key: "benchmarkone-create-contact",
67
name: "Create Contact",
7-
description: "Creates a new contact in BenchmarkONE. [See the documentation]()",
8-
version: "0.0.{{ts}}",
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",
910
type: "action",
1011
props: {
1112
benchmarkone,
@@ -14,23 +15,40 @@ export default {
1415
benchmarkone,
1516
"firstName",
1617
],
18+
optional: true,
1719
},
1820
lastName: {
1921
propDefinition: [
2022
benchmarkone,
2123
"lastName",
2224
],
25+
optional: true,
26+
},
27+
title: {
28+
propDefinition: [
29+
benchmarkone,
30+
"title",
31+
],
32+
optional: true,
2333
},
24-
email: {
34+
company: {
2535
propDefinition: [
2636
benchmarkone,
27-
"email",
37+
"company",
2838
],
39+
optional: true,
2940
},
30-
phoneNumbers: {
41+
emails: {
3142
propDefinition: [
3243
benchmarkone,
33-
"phoneNumbers",
44+
"emails",
45+
],
46+
optional: true,
47+
},
48+
phones: {
49+
propDefinition: [
50+
benchmarkone,
51+
"phones",
3452
],
3553
optional: true,
3654
},
@@ -41,20 +59,64 @@ export default {
4159
],
4260
optional: true,
4361
},
62+
status: {
63+
propDefinition: [
64+
benchmarkone,
65+
"status",
66+
],
67+
},
68+
temperature: {
69+
propDefinition: [
70+
benchmarkone,
71+
"temperature",
72+
],
73+
optional: true,
74+
},
75+
website: {
76+
propDefinition: [
77+
benchmarkone,
78+
"website",
79+
],
80+
optional: true,
81+
},
4482
},
4583
async run({ $ }) {
4684
try {
47-
const response = await this.benchmarkone.createContact({
85+
const data = {
86+
contactId: this.contactId,
4887
firstName: this.firstName,
4988
lastName: this.lastName,
50-
email: this.email,
51-
phoneNumbers: this.phoneNumbers,
52-
addresses: this.addresses,
89+
emails: parseObject(this.emails),
90+
phones: parseObject(this.phones),
91+
addresses: parseObject(this.addresses),
92+
};
93+
if (this.status) {
94+
data.status = {
95+
name: this.status.label,
96+
id: this.status.value,
97+
};
98+
}
99+
if (this.temperature) {
100+
data.temperature = {
101+
name: this.temperature.label,
102+
id: this.temperature.value,
103+
};
104+
}
105+
if (this.website) {
106+
data.website = [
107+
{
108+
websiteUrl: this.website,
109+
},
110+
];
111+
}
112+
const response = await this.benchmarkone.createContact({
113+
$,
114+
data,
53115
});
54116
$.export("$summary", `Created contact with ID: ${response.contactId}`);
55117
return response;
56118
} catch (error) {
57-
throw new Error(`Failed to create contact: ${error.message}`);
119+
throw new ConfigurationError(`Failed to create contact: ${error.message}`);
58120
}
59121
},
60122
};

0 commit comments

Comments
 (0)