Skip to content

Commit 9fb867c

Browse files
committed
Refactor HubSpot workflow actions to use v3 API endpoints
- Updated workflow-related actions to utilize the v3 API instead of v4. - Renamed variables for clarity and consistency. - Removed deprecated props from create and update workflow actions. - Adjusted descriptions in action components to reflect the new API documentation. - Bumped versions for several source components to maintain compatibility.
1 parent e62ab48 commit 9fb867c

File tree

32 files changed

+63
-179
lines changed

32 files changed

+63
-179
lines changed

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

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import hubspot from "../../hubspot.app.mjs";
44
export default {
55
key: "hubspot-create-workflow",
66
name: "Create a New Workflow",
7-
description: "Create a new workflow. [See the documentation](https://developers.hubspot.com/docs/api-reference/automation-automation-v4-v4/workflows/post-automation-v4-flows)",
7+
description: "Create a new workflow. [See the documentation](https://developers.hubspot.com/docs/api-reference/legacy/create-manage-workflows-v3/post-automation-v3-workflows)",
88
version: "0.0.1",
99
type: "action",
1010
props: {
@@ -14,12 +14,6 @@ export default {
1414
label: "Workflow Name",
1515
description: "The name of the workflow to create",
1616
},
17-
isEnabled: {
18-
propDefinition: [
19-
hubspot,
20-
"isEnabled",
21-
],
22-
},
2317
type: {
2418
propDefinition: [
2519
hubspot,
@@ -32,23 +26,13 @@ export default {
3226
"actions",
3327
],
3428
},
35-
enrollmentCriteria: {
36-
propDefinition: [
37-
hubspot,
38-
"enrollmentCriteria",
39-
],
40-
},
4129
},
4230
async run({ $ }) {
4331
const response = await this.hubspot.createWorkflow({
4432
data: {
4533
name: this.name,
4634
type: this.type,
47-
isEnabled: this.isEnabled,
48-
objectTypeId: "0-1",
49-
flowType: "WORKFLOW",
5035
actions: parseObject(this.actions),
51-
enrollmentCriteria: parseObject(this.enrollmentCriteria),
5236
},
5337
$,
5438
});

components/hubspot/actions/delete-workflow/delete-workflow.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import hubspot from "../../hubspot.app.mjs";
33
export default {
44
key: "hubspot-delete-workflow",
55
name: "Delete a Workflow",
6-
description: "Delete a workflow by ID. [See the documentation](https://developers.hubspot.com/docs/api-reference/automation-automation-v4-v4/workflows/delete-automation-v4-flows-flowId)",
6+
description: "Delete a workflow by ID. [See the documentation](https://developers.hubspot.com/docs/api-reference/legacy/create-manage-workflows-v3/delete-automation-v3-workflows-workflowId)",
77
version: "0.0.1",
88
type: "action",
99
props: {

components/hubspot/actions/retrieve-migrated-workflow-mappings/retrieve-migrated-workflow-mappings.mjs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,26 @@ export default {
1010
props: {
1111
hubspot,
1212
flowIds: {
13+
propDefinition: [
14+
hubspot,
15+
"workflow",
16+
() => ({
17+
version: "V4",
18+
}),
19+
],
1320
type: "string[]",
1421
label: "Flow IDs",
1522
description: "A list of flowIds from the V4 API.",
1623
optional: true,
1724
},
18-
workflowIds: {
25+
workflow: {
26+
propDefinition: [
27+
hubspot,
28+
"workflow",
29+
() => ({
30+
version: "V3",
31+
}),
32+
],
1933
type: "string[]",
2034
label: "Workflow IDs",
2135
description: "A list of workflowIds from the V3 API.",

components/hubspot/actions/retrieve-workflow-details/retrieve-workflow-details.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import hubspot from "../../hubspot.app.mjs";
33
export default {
44
key: "hubspot-retrieve-workflow-details",
55
name: "Retrieve Workflow Details",
6-
description: "Retrieve detailed information about a specific workflow. [See the documentation](https://developers.hubspot.com/docs/api-reference/automation-automation-v4-v4/workflows/get-automation-v4-flows-flowId)",
6+
description: "Retrieve detailed information about a specific workflow. [See the documentation](https://developers.hubspot.com/docs/api-reference/legacy/create-manage-workflows-v3/get-automation-v3-workflows-workflowId)",
77
version: "0.0.1",
88
type: "action",
99
props: {

components/hubspot/actions/retrieve-workflows/retrieve-workflows.mjs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,15 @@ import hubspot from "../../hubspot.app.mjs";
33
export default {
44
key: "hubspot-retrieve-workflows",
55
name: "Retrieve Workflows",
6-
description: "Retrieve a list of all workflows. [See the documentation](https://developers.hubspot.com/docs/api-reference/automation-automation-v4-v4/workflows/get-automation-v4-flows)",
6+
description: "Retrieve a list of all workflows. [See the documentation](https://developers.hubspot.com/docs/api-reference/legacy/create-manage-workflows-v3/get-automation-v3-workflows)",
77
version: "0.0.1",
88
type: "action",
99
props: {
1010
hubspot,
11-
after: {
12-
type: "string",
13-
label: "After",
14-
description: "The paging cursor token of the last successfully read resource will be returned as the `paging.next.after` JSON property of a paged response containing more results.",
15-
optional: true,
16-
},
17-
limit: {
18-
type: "integer",
19-
label: "Limit",
20-
description: "The maximum number of results to display per page.",
21-
default: 100,
22-
optional: true,
23-
},
2411
},
2512
async run({ $ }) {
2613
const response = await this.hubspot.listWorkflows({
2714
$,
28-
params: {
29-
after: this.after,
30-
limit: this.limit,
31-
},
3215
});
3316

3417
$.export("$summary", `Successfully retrieved ${response.results.length} workflows`);

components/hubspot/actions/update-workflow/update-workflow.mjs

Lines changed: 0 additions & 82 deletions
This file was deleted.

components/hubspot/common/constants.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const API_PATH = {
2020
CRMV4: "/crm/v4",
2121
CMS: "/cms/v3",
2222
AUTOMATION: "/automation/v2",
23+
AUTOMATIONV3: "/automation/v3",
2324
AUTOMATIONV4: "/automation/v4",
2425
DEAL: "/deals/v1",
2526
BUSINESS_UNITS: "/business-units/v3",

components/hubspot/hubspot.app.mjs

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,10 @@ export default {
343343
label: "Workflow",
344344
description: "The ID of the workflow you wish to see metadata for.",
345345
async options() {
346-
const { results } = await this.listWorkflows();
346+
const { workflows } = await this.listWorkflows();
347+
347348
return {
348-
options: results.map(({
349+
options: workflows.map(({
349350
name: label, id: value,
350351
}) => ({
351352
label,
@@ -682,32 +683,25 @@ export default {
682683
description: "The type of workflow to create",
683684
options: [
684685
{
685-
label: "Contact-based Workflow",
686-
value: "CONTACT_FLOW",
686+
label: "Drip Delay",
687+
value: "DRIP_DELAY",
688+
},
689+
{
690+
label: "Static Anchor",
691+
value: "STATIC_ANCHOR",
687692
},
688693
{
689-
label: "All other workflow types (e.g., deal-based, goal-based, etc.)",
690-
value: "PLATFORM_FLOW",
694+
label: "Property Anchor",
695+
value: "PROPERTY_ANCHOR",
691696
},
692697
],
693698
},
694-
isEnabled: {
695-
type: "boolean",
696-
label: "Is Enabled",
697-
description: "Whether the workflow is enabled",
698-
},
699699
actions: {
700700
type: "string[]",
701701
label: "Actions",
702702
description: "A list of objects representing the workflow actions. [See the documentation](https://developers.hubspot.com/docs/api-reference/automation-automation-v4-v4/guide#action-types) for more information.",
703703
optional: true,
704704
},
705-
enrollmentCriteria: {
706-
type: "object",
707-
label: "Enrollment Criteria",
708-
description: "The enrollment criteria of the workflow. [See the documentation](https://developers.hubspot.com/docs/api-reference/automation-automation-v4-v4/guide#enrollment-criteria) for more information.",
709-
optional: true,
710-
},
711705
},
712706
methods: {
713707
_getHeaders() {
@@ -1240,8 +1234,8 @@ export default {
12401234
},
12411235
listWorkflows(opts = {}) {
12421236
return this.makeRequest({
1243-
api: API_PATH.AUTOMATIONV4,
1244-
endpoint: "/flows",
1237+
api: API_PATH["AUTOMATIONV3"],
1238+
endpoint: "/workflows",
12451239
...opts,
12461240
});
12471241
},
@@ -1266,26 +1260,16 @@ export default {
12661260
workflowId, ...opts
12671261
}) {
12681262
return this.makeRequest({
1269-
api: API_PATH.AUTOMATIONV4,
1270-
endpoint: `/flows/${workflowId}`,
1263+
api: API_PATH.AUTOMATIONV3,
1264+
endpoint: `/workflows/${workflowId}`,
12711265
...opts,
12721266
});
12731267
},
12741268
createWorkflow(opts = {}) {
12751269
return this.makeRequest({
12761270
method: "POST",
1277-
api: API_PATH.AUTOMATIONV4,
1278-
endpoint: "/flows",
1279-
...opts,
1280-
});
1281-
},
1282-
updateWorkflow({
1283-
workflowId, ...opts
1284-
}) {
1285-
return this.makeRequest({
1286-
method: "PUT",
1287-
api: API_PATH.AUTOMATIONV4,
1288-
endpoint: `/flows/${workflowId}`,
1271+
api: API_PATH.AUTOMATIONV3,
1272+
endpoint: "/workflows",
12891273
...opts,
12901274
});
12911275
},
@@ -1294,8 +1278,8 @@ export default {
12941278
}) {
12951279
return this.makeRequest({
12961280
method: "DELETE",
1297-
api: API_PATH.AUTOMATIONV4,
1298-
endpoint: `/flows/${workflowId}`,
1281+
api: API_PATH.AUTOMATIONV3,
1282+
endpoint: `/workflows/${workflowId}`,
12991283
...opts,
13001284
});
13011285
},

components/hubspot/sources/delete-blog-article/delete-blog-article.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "hubspot-delete-blog-article",
77
name: "Deleted Blog Posts",
88
description: "Emit new event for each deleted blog post.",
9-
version: "0.0.28",
9+
version: "0.0.29",
1010
dedupe: "unique",
1111
type: "source",
1212
methods: {

components/hubspot/sources/new-company-property-change/new-company-property-change.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
key: "hubspot-new-company-property-change",
88
name: "New Company Property Change",
99
description: "Emit new event when a specified property is provided or updated on a company. [See the documentation](https://developers.hubspot.com/docs/api/crm/companies)",
10-
version: "0.0.21",
10+
version: "0.0.22",
1111
dedupe: "unique",
1212
type: "source",
1313
props: {

0 commit comments

Comments
 (0)