Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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;
},
};
122 changes: 122 additions & 0 deletions components/benchmarkone/actions/create-contact/create-contact.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
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,
},
emails: {
propDefinition: [
benchmarkone,
"emails",
],
optional: true,
},
phones: {
propDefinition: [
benchmarkone,
"phones",
],
optional: true,
},
addresses: {
propDefinition: [
benchmarkone,
"addresses",
],
optional: true,
},
status: {
propDefinition: [
benchmarkone,
"status",
],
},
temperature: {
propDefinition: [
benchmarkone,
"temperature",
],
optional: true,
},
website: {
propDefinition: [
benchmarkone,
"website",
],
optional: true,
},
},
async run({ $ }) {
try {
const data = {
contactId: this.contactId,
firstName: this.firstName,
lastName: this.lastName,
emails: parseObject(this.emails),
phones: parseObject(this.phones),
addresses: parseObject(this.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}`);
}
},
};
130 changes: 130 additions & 0 deletions components/benchmarkone/actions/update-contact/update-contact.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import { ConfigurationError } from "@pipedream/platform";
import benchmarkone from "../../benchmarkone.app.mjs";
import { parseObject } from "../../common/utils.mjs";

export default {
key: "benchmarkone-update-contact",
name: "Update Contact",
description: "Updates an existing contact. [See the documentation](https://sandbox.hatchbuck.com/api/dist/#!/Contacts/put_contact)",
version: "0.0.1",
type: "action",
props: {
benchmarkone,
contactId: {
propDefinition: [
benchmarkone,
"contactId",
],
},
firstName: {
propDefinition: [
benchmarkone,
"firstName",
],
optional: true,
},
lastName: {
propDefinition: [
benchmarkone,
"lastName",
],
optional: true,
},
title: {
propDefinition: [
benchmarkone,
"title",
],
optional: true,
},
company: {
propDefinition: [
benchmarkone,
"company",
],
optional: true,
},
emails: {
propDefinition: [
benchmarkone,
"emails",
],
optional: true,
},
phones: {
propDefinition: [
benchmarkone,
"phones",
],
optional: true,
},
addresses: {
propDefinition: [
benchmarkone,
"addresses",
],
optional: true,
},
status: {
propDefinition: [
benchmarkone,
"status",
],
optional: true,
},
temperature: {
propDefinition: [
benchmarkone,
"temperature",
],
optional: true,
},
website: {
propDefinition: [
benchmarkone,
"website",
],
optional: true,
},
},
async run({ $ }) {
try {
const data = {
contactId: this.contactId,
firstName: this.firstName,
lastName: this.lastName,
emails: parseObject(this.emails),
phones: parseObject(this.phones),
addresses: parseObject(this.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.updateContact({
$,
data,
});
$.export("$summary", "Contact updated successfully.");
return response;
} catch (error) {
throw new ConfigurationError(`Failed to create contact: ${error.message}`);
}
},
};
Loading
Loading