Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hubspot updates - Leads and Custom Objects #14686

Merged
merged 8 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "hubspot-add-contact-to-list",
name: "Add Contact to List",
description: "Adds a contact to a specific static list. [See the documentation](https://legacydocs.hubspot.com/docs/methods/lists/add_contact_to_list)",
version: "0.0.9",
version: "0.0.10",
type: "action",
props: {
hubspot,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "hubspot-batch-create-or-update-contact",
name: "Batch Create or Update Contact",
description: "Create or update a batch of contacts by its ID or email. [See the documentation](https://developers.hubspot.com/docs/api/crm/contacts)",
version: "0.0.6",
version: "0.0.7",
type: "action",
props: {
hubspot,
Expand Down
7 changes: 6 additions & 1 deletion components/hubspot/actions/common/common-create-object.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,17 @@ export default {
isDefaultProperty() {
return false;
},
createObject(opts = {}) {
return this.hubspot.createObject(opts);
},
},
async run({ $ }) {
const {
hubspot,
/* eslint-disable no-unused-vars */
propertyGroups,
customObjectType,
contactId,
michelle0927 marked this conversation as resolved.
Show resolved Hide resolved
$db,
updateIfExists,
...properties
Expand All @@ -54,7 +59,7 @@ export default {
}
});
try {
const response = await hubspot.createObject({
const response = await this.createObject({
$,
objectType,
data: {
Expand Down
1 change: 1 addition & 0 deletions components/hubspot/actions/common/common-update-object.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default {
hubspot,
/* eslint-disable no-unused-vars */
propertyGroups,
customObjectType,
$db,
objectId,
...properties
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import hubspot from "../../hubspot.app.mjs";
import { ASSOCIATION_CATEGORY } from "../../common/constants.mjs";
import { ConfigurationError } from "@pipedream/platform";

export default {
key: "hubspot-create-associations",
name: "Create Associations",
description: "Create associations between objects. [See the documentation](https://developers.hubspot.com/docs/api/crm/associations#endpoint?spec=POST-/crm/v3/associations/{fromObjectType}/{toObjectType}/batch/create)",
version: "0.0.9",
version: "0.0.10",
type: "action",
props: {
hubspot,
fromObjectType: {
propDefinition: [
hubspot,
"objectType",
() => ({
includeCustom: true,
}),
],
label: "From Object Type",
description: "The type of the object being associated",
Expand All @@ -34,6 +36,9 @@ export default {
propDefinition: [
hubspot,
"objectType",
() => ({
includeCustom: true,
}),
],
label: "To Object Type",
description: "Type of the objects the from object is being associated with",
Expand All @@ -60,6 +65,20 @@ export default {
description: "Id's of the objects the from object is being associated with",
},
},
methods: {
async getAssociationCategory({
$, fromObjectType, toObjectType, associationType,
}) {
const { results } = await this.hubspot.getAssociationTypes({
$,
fromObjectType,
toObjectType,
associationType,
});
const association = results.find(({ typeId }) => typeId === this.associationType);
return association.category;
},
michelle0927 marked this conversation as resolved.
Show resolved Hide resolved
},
async run({ $ }) {
const {
fromObjectType,
Expand All @@ -77,6 +96,13 @@ export default {
throw new ConfigurationError("Could not parse \"To Objects\" array.");
}
}

const associationCategory = await this.getAssociationCategory({
$,
fromObjectType,
toObjectType,
associationType,
});
const response = await this.hubspot.createAssociations({
$,
fromObjectType,
Expand All @@ -91,7 +117,7 @@ export default {
},
types: [
{
associationCategory: ASSOCIATION_CATEGORY.HUBSPOT_DEFINED,
associationCategory,
associationTypeId: associationType,
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
key: "hubspot-create-communication",
name: "Create Communication",
description: "Create a WhatsApp, LinkedIn, or SMS message. [See the documentation](https://developers.hubspot.com/beta-docs/reference/api/crm/engagements/communications/v3#post-%2Fcrm%2Fv3%2Fobjects%2Fcommunications)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
...appProp.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "hubspot-create-company",
name: "Create Company",
description: "Create a company in Hubspot. [See the documentation](https://developers.hubspot.com/docs/api/crm/companies#endpoint?spec=POST-/crm/v3/objects/companies)",
version: "0.0.12",
version: "0.0.13",
type: "action",
methods: {
...common.methods,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import hubspot from "../../hubspot.app.mjs";
import common from "../common/common-create-object.mjs";

export default {
...common,
key: "hubspot-create-custom-object",
name: "Create Custom Object",
description: "Create a new custom object in Hubspot. [See the documentation](https://developers.hubspot.com/beta-docs/guides/api/crm/objects/custom-objects#create-a-custom-object)",
version: "0.0.1",
type: "action",
props: {
hubspot,
customObjectType: {
propDefinition: [
hubspot,
"customObjectType",
],
},
...common.props,
},
methods: {
...common.methods,
getObjectType() {
return this.customObjectType;
},
},
};
2 changes: 1 addition & 1 deletion components/hubspot/actions/create-deal/create-deal.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "hubspot-create-deal",
name: "Create Deal",
description: "Create a deal in Hubspot. [See the documentation](https://developers.hubspot.com/docs/api/crm/deals#endpoint?spec=POST-/crm/v3/objects/deals)",
version: "0.0.12",
version: "0.0.13",
type: "action",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default {
key: "hubspot-create-engagement",
name: "Create Engagement",
description: "Create a new engagement for a contact. [See the documentation](https://developers.hubspot.com/docs/api/crm/engagements)",
version: "0.0.11",
version: "0.0.12",
type: "action",
props: {
...common.props,
Expand Down
56 changes: 56 additions & 0 deletions components/hubspot/actions/create-lead/create-lead.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import {
OBJECT_TYPE, ASSOCIATION_CATEGORY,
} from "../../common/constants.mjs";
import common from "../common/common-create-object.mjs";
import hubspot from "../../hubspot.app.mjs";

export default {
...common,
key: "hubspot-create-lead",
name: "Create Lead",
description: "Create a lead in Hubspot. [See the documentation](https://developers.hubspot.com/beta-docs/guides/api/crm/objects/leads#create-leads)",
version: "0.0.1",
type: "action",
props: {
hubspot,
contactId: {
propDefinition: [
hubspot,
"objectId",
() => ({
objectType: "contact",
}),
],
label: "Contact ID",
description: "The contact to associate with the lead",
},
...common.props,
},
methods: {
...common.methods,
getObjectType() {
return OBJECT_TYPE.LEAD;
},
createObject(opts) {
return this.hubspot.createObject({
...opts,
data: {
...opts?.data,
associations: [
{
types: [
{
associationCategory: ASSOCIATION_CATEGORY.HUBSPOT_DEFINED,
associationTypeId: 578, // ID for "Lead with Primary Contact"
},
],
to: {
id: this.contactId,
},
},
],
},
});
},
michelle0927 marked this conversation as resolved.
Show resolved Hide resolved
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "hubspot-create-or-update-contact",
name: "Create or Update Contact",
description: "Create or update a contact in Hubspot. [See the documentation](https://developers.hubspot.com/docs/api/crm/contacts#endpoint?spec=POST-/crm/v3/objects/contacts)",
version: "0.0.10",
version: "0.0.11",
type: "action",
props: {
...common.props,
Expand Down
2 changes: 1 addition & 1 deletion components/hubspot/actions/create-ticket/create-ticket.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "hubspot-create-ticket",
name: "Create Ticket",
description: "Create a ticket in Hubspot. [See the documentation](https://developers.hubspot.com/docs/api/crm/tickets)",
version: "0.0.3",
version: "0.0.4",
type: "action",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "hubspot-enroll-contact-into-workflow",
name: "Enroll Contact Into Workflow",
description: "Add a contact to a workflow. Note: The Workflows API currently only supports contact-based workflows and is only available for Marketing Hub Enterprise accounts. [See the documentation](https://legacydocs.hubspot.com/docs/methods/workflows/add_contact)",
version: "0.0.9",
version: "0.0.10",
type: "action",
props: {
hubspot,
Expand Down
2 changes: 1 addition & 1 deletion components/hubspot/actions/get-company/get-company.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "hubspot-get-company",
name: "Get Company",
description: "Gets a company. [See the documentation](https://developers.hubspot.com/docs/api/crm/companies#endpoint?spec=GET-/crm/v3/objects/companies/{companyId})",
version: "0.0.9",
version: "0.0.10",
type: "action",
props: {
...common.props,
Expand Down
2 changes: 1 addition & 1 deletion components/hubspot/actions/get-contact/get-contact.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "hubspot-get-contact",
name: "Get Contact",
description: "Gets a contact. [See the documentation](https://developers.hubspot.com/docs/api/crm/contacts#endpoint?spec=GET-/crm/v3/objects/contacts/{contactId})",
version: "0.0.9",
version: "0.0.10",
type: "action",
props: {
...common.props,
Expand Down
2 changes: 1 addition & 1 deletion components/hubspot/actions/get-deal/get-deal.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "hubspot-get-deal",
name: "Get Deal",
description: "Gets a deal. [See the documentation](https://developers.hubspot.com/docs/api/crm/deals#endpoint?spec=GET-/crm/v3/objects/deals/{dealId})",
version: "0.0.9",
version: "0.0.10",
type: "action",
props: {
...common.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "hubspot-get-file-public-url",
name: "Get File Public URL",
description: "Get a publicly available URL for a file that was uploaded using a Hubspot form. [See the documentation](https://developers.hubspot.com/docs/api/files/files#endpoint?spec=GET-/files/v3/files/{fileId}/signed-url)",
version: "0.0.9",
version: "0.0.10",
type: "action",
props: {
hubspot,
Expand Down
Loading
Loading