Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading