Skip to content

Commit fb62fb3

Browse files
authored
Hubspot updates - Leads and Custom Objects (#14686)
* update search-crm * update create-associations * new components * pnpm-lock.yaml * versions * updates
1 parent 4cfcfc6 commit fb62fb3

File tree

49 files changed

+389
-128
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+389
-128
lines changed

components/hubspot/actions/add-contact-to-list/add-contact-to-list.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "hubspot-add-contact-to-list",
55
name: "Add Contact to List",
66
description: "Adds a contact to a specific static list. [See the documentation](https://legacydocs.hubspot.com/docs/methods/lists/add_contact_to_list)",
7-
version: "0.0.9",
7+
version: "0.0.10",
88
type: "action",
99
props: {
1010
hubspot,

components/hubspot/actions/batch-create-or-update-contact/batch-create-or-update-contact.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "hubspot-batch-create-or-update-contact",
55
name: "Batch Create or Update Contact",
66
description: "Create or update a batch of contacts by its ID or email. [See the documentation](https://developers.hubspot.com/docs/api/crm/contacts)",
7-
version: "0.0.6",
7+
version: "0.0.7",
88
type: "action",
99
props: {
1010
hubspot,

components/hubspot/actions/common/common-create-object.mjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,17 @@ export default {
3333
isDefaultProperty() {
3434
return false;
3535
},
36+
createObject(opts = {}) {
37+
return this.hubspot.createObject(opts);
38+
},
3639
},
3740
async run({ $ }) {
3841
const {
3942
hubspot,
4043
/* eslint-disable no-unused-vars */
4144
propertyGroups,
45+
customObjectType,
46+
contactId,
4247
$db,
4348
updateIfExists,
4449
...properties
@@ -54,7 +59,7 @@ export default {
5459
}
5560
});
5661
try {
57-
const response = await hubspot.createObject({
62+
const response = await this.createObject({
5863
$,
5964
objectType,
6065
data: {

components/hubspot/actions/common/common-create.mjs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export default {
7070
? options
7171
: undefined;
7272
},
73-
makePropDefinition(property, requiredProperties) {
73+
async makePropDefinition(property, requiredProperties) {
7474
let type = "string";
7575
let options = this.makeLabelValueOptions(property);
7676

@@ -83,13 +83,32 @@ export default {
8383
property.description += ". Enter date in ISO-8601 format. Example: `2024-06-25T15:43:49.214Z`";
8484
}
8585

86+
const objectType = this.hubspot.getObjectTypeName(this.getObjectType());
87+
let reloadProps;
88+
if (property.name === "hs_pipeline") {
89+
options = await this.hubspot.getPipelinesOptions(objectType);
90+
reloadProps = true;
91+
}
92+
if (property.name === "hs_pipeline_stage") {
93+
options = await this.hubspot.getPipelineStagesOptions(objectType, this.hs_pipeline);
94+
}
95+
if (property.name === "hs_all_assigned_business_unit_ids") {
96+
try {
97+
options = await this.hubspot.getBusinessUnitOptions();
98+
} catch {
99+
console.log("Could not load business units");
100+
}
101+
property.description += " For use with the Business Units Add-On.";
102+
}
103+
86104
return {
87105
type,
88106
name: property.name,
89107
label: property.label,
90108
description: property.description,
91109
optional: !requiredProperties.includes(property.name),
92110
options,
111+
reloadProps,
93112
};
94113
},
95114
},
@@ -101,9 +120,12 @@ export default {
101120
const { results: properties } = await this.hubspot.getProperties({
102121
objectType,
103122
});
104-
return properties
105-
.filter(this.isRelevantProperty)
106-
.map((property) => this.makePropDefinition(property, schema.requiredProperties))
123+
const relevantProperties = properties.filter(this.isRelevantProperty);
124+
const propDefinitions = [];
125+
for (const property of relevantProperties) {
126+
propDefinitions.push(await this.makePropDefinition(property, schema.requiredProperties));
127+
}
128+
return propDefinitions
107129
.reduce((props, {
108130
name, ...definition
109131
}) => {

components/hubspot/actions/common/common-update-object.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export default {
3232
hubspot,
3333
/* eslint-disable no-unused-vars */
3434
propertyGroups,
35+
customObjectType,
3536
$db,
3637
objectId,
3738
...properties

components/hubspot/actions/create-associations/create-associations.mjs

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
import hubspot from "../../hubspot.app.mjs";
2-
import { ASSOCIATION_CATEGORY } from "../../common/constants.mjs";
32
import { ConfigurationError } from "@pipedream/platform";
43

54
export default {
65
key: "hubspot-create-associations",
76
name: "Create Associations",
87
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)",
9-
version: "0.0.9",
8+
version: "0.0.10",
109
type: "action",
1110
props: {
1211
hubspot,
1312
fromObjectType: {
1413
propDefinition: [
1514
hubspot,
1615
"objectType",
16+
() => ({
17+
includeCustom: true,
18+
}),
1719
],
1820
label: "From Object Type",
1921
description: "The type of the object being associated",
@@ -34,6 +36,9 @@ export default {
3436
propDefinition: [
3537
hubspot,
3638
"objectType",
39+
() => ({
40+
includeCustom: true,
41+
}),
3742
],
3843
label: "To Object Type",
3944
description: "Type of the objects the from object is being associated with",
@@ -60,6 +65,20 @@ export default {
6065
description: "Id's of the objects the from object is being associated with",
6166
},
6267
},
68+
methods: {
69+
async getAssociationCategory({
70+
$, fromObjectType, toObjectType, associationType,
71+
}) {
72+
const { results } = await this.hubspot.getAssociationTypes({
73+
$,
74+
fromObjectType,
75+
toObjectType,
76+
associationType,
77+
});
78+
const association = results.find(({ typeId }) => typeId === this.associationType);
79+
return association.category;
80+
},
81+
},
6382
async run({ $ }) {
6483
const {
6584
fromObjectType,
@@ -77,6 +96,13 @@ export default {
7796
throw new ConfigurationError("Could not parse \"To Objects\" array.");
7897
}
7998
}
99+
100+
const associationCategory = await this.getAssociationCategory({
101+
$,
102+
fromObjectType,
103+
toObjectType,
104+
associationType,
105+
});
80106
const response = await this.hubspot.createAssociations({
81107
$,
82108
fromObjectType,
@@ -91,7 +117,7 @@ export default {
91117
},
92118
types: [
93119
{
94-
associationCategory: ASSOCIATION_CATEGORY.HUBSPOT_DEFINED,
120+
associationCategory,
95121
associationTypeId: associationType,
96122
},
97123
],

components/hubspot/actions/create-communication/create-communication.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
key: "hubspot-create-communication",
99
name: "Create Communication",
1010
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)",
11-
version: "0.0.1",
11+
version: "0.0.2",
1212
type: "action",
1313
props: {
1414
...appProp.props,

components/hubspot/actions/create-company/create-company.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "hubspot-create-company",
77
name: "Create Company",
88
description: "Create a company in Hubspot. [See the documentation](https://developers.hubspot.com/docs/api/crm/companies#endpoint?spec=POST-/crm/v3/objects/companies)",
9-
version: "0.0.12",
9+
version: "0.0.13",
1010
type: "action",
1111
methods: {
1212
...common.methods,
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import hubspot from "../../hubspot.app.mjs";
2+
import common from "../common/common-create-object.mjs";
3+
4+
export default {
5+
...common,
6+
key: "hubspot-create-custom-object",
7+
name: "Create Custom Object",
8+
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)",
9+
version: "0.0.1",
10+
type: "action",
11+
props: {
12+
hubspot,
13+
customObjectType: {
14+
propDefinition: [
15+
hubspot,
16+
"customObjectType",
17+
],
18+
},
19+
...common.props,
20+
},
21+
methods: {
22+
...common.methods,
23+
getObjectType() {
24+
return this.customObjectType;
25+
},
26+
},
27+
};

components/hubspot/actions/create-deal/create-deal.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "hubspot-create-deal",
77
name: "Create Deal",
88
description: "Create a deal in Hubspot. [See the documentation](https://developers.hubspot.com/docs/api/crm/deals#endpoint?spec=POST-/crm/v3/objects/deals)",
9-
version: "0.0.12",
9+
version: "0.0.13",
1010
type: "action",
1111
props: {
1212
...common.props,

0 commit comments

Comments
 (0)