Skip to content

Commit

Permalink
New Components - benchmarkone (#15668)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
luancazarine and vunguyenhung authored Feb 26, 2025
1 parent 915a70a commit db6687e
Show file tree
Hide file tree
Showing 10 changed files with 834 additions and 6 deletions.
54 changes: 54 additions & 0 deletions components/benchmarkone/actions/add-note/add-note.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { ConfigurationError } from "@pipedream/platform";
import benchmarkone from "../../benchmarkone.app.mjs";

export default {
key: "benchmarkone-add-note",
name: "Add Note to Contact",
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).",
version: "0.0.1",
type: "action",
props: {
benchmarkone,
contactId: {
propDefinition: [
benchmarkone,
"contactId",
],
},
subject: {
type: "string",
label: "Subject",
description: "Subject line for the note.",
},
body: {
type: "string",
label: "Body",
description: "Body of the note.",
},
copyToCompany: {
type: "boolean",
label: "Copy To Company",
description: "Copy this note to the contact's associated company record.",
optional: true,
},
},
async run({ $ }) {
try {
const response = await this.benchmarkone.addNoteToContact({
$,
contactId: this.contactId,
data: {
subject: this.subject,
body: this.body,
copyToCompany: this.copyToCompany,
},
});

$.export("$summary", `Added note to contact with ID ${this.contactId}`);

return response;
} catch (error) {
throw new ConfigurationError(error.message);
}
},
};
35 changes: 35 additions & 0 deletions components/benchmarkone/actions/add-tag/add-tag.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import benchmarkone from "../../benchmarkone.app.mjs";
import { parseObject } from "../../common/utils.mjs";

export default {
key: "benchmarkone-add-tag",
name: "Add Tag to Contact",
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).",
version: "0.0.1",
type: "action",
props: {
benchmarkone,
contactId: {
propDefinition: [
benchmarkone,
"contactId",
],
},
tags: {
type: "string[]",
label: "Tags",
description: "A list of tags to add to the contact.",
},
},
async run({ $ }) {
const response = await this.benchmarkone.addTagToContact({
contactId: this.contactId,
data: parseObject(this.tags)?.map((item) => ({
name: item,
})),
});

$.export("$summary", `Succcessfully added tags to contact ID ${this.contactId}`);
return response;
},
};
183 changes: 183 additions & 0 deletions components/benchmarkone/actions/create-contact/create-contact.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
import { ConfigurationError } from "@pipedream/platform";
import benchmarkone from "../../benchmarkone.app.mjs";
import { parseObject } from "../../common/utils.mjs";

export default {
key: "benchmarkone-create-contact",
name: "Create Contact",
description: "Creates a new contact in BenchmarkONE. [See the documentation](https://sandbox.hatchbuck.com/api/dist/#!/Contacts/post_contact)",
version: "0.0.1",
type: "action",
props: {
benchmarkone,
firstName: {
propDefinition: [
benchmarkone,
"firstName",
],
optional: true,
},
lastName: {
propDefinition: [
benchmarkone,
"lastName",
],
optional: true,
},
title: {
propDefinition: [
benchmarkone,
"title",
],
optional: true,
},
company: {
propDefinition: [
benchmarkone,
"company",
],
optional: true,
},
workEmail: {
propDefinition: [
benchmarkone,
"workEmail",
],
optional: true,
},
homeEmail: {
propDefinition: [
benchmarkone,
"homeEmail",
],
optional: true,
},
workPhone: {
propDefinition: [
benchmarkone,
"workPhone",
],
optional: true,
},
homePhone: {
propDefinition: [
benchmarkone,
"homePhone",
],
optional: true,
},
workAddress: {
propDefinition: [
benchmarkone,
"workAddress",
],
optional: true,
},
homeAddress: {
propDefinition: [
benchmarkone,
"homeAddress",
],
optional: true,
},
status: {
propDefinition: [
benchmarkone,
"status",
],
},
temperature: {
propDefinition: [
benchmarkone,
"temperature",
],
optional: true,
},
website: {
propDefinition: [
benchmarkone,
"website",
],
optional: true,
},
},
async run({ $ }) {
try {
const emails = [];
if (this.workEmail) {
emails.push({
address: this.workEmail,
type: "Work",
});
}
if (this.homeEmail) {
emails.push({
address: this.homeEmail,
type: "Home",
});
}
const phones = [];
if (this.workPhone) {
phones.push({
number: this.workPhone,
type: "Work",
});
}
if (this.homePhone) {
phones.push({
number: this.homePhone,
type: "Home",
});
}
const addresses = [];
if (this.workAddress) {
addresses.push({
...parseObject(this.workAddress),
type: "Work",
});
}
if (this.homeAddress) {
addresses.push({
...parseObject(this.homeAddress),
type: "Home",
});
}

const data = {
contactId: this.contactId,
firstName: this.firstName,
lastName: this.lastName,
emails,
phones,
addresses,
};
if (this.status) {
data.status = {
name: this.status.label,
id: this.status.value,
};
}
if (this.temperature) {
data.temperature = {
name: this.temperature.label,
id: this.temperature.value,
};
}
if (this.website) {
data.website = [
{
websiteUrl: this.website,
},
];
}
const response = await this.benchmarkone.createContact({
$,
data,
});
$.export("$summary", `Created contact with ID: ${response.contactId}`);
return response;
} catch (error) {
throw new ConfigurationError(`Failed to create contact: ${error.message}`);
}
},
};
Loading

0 comments on commit db6687e

Please sign in to comment.