Skip to content

Commit 0bc6bc9

Browse files
committed
new components
1 parent 20ac5e4 commit 0bc6bc9

File tree

11 files changed

+667
-1
lines changed

11 files changed

+667
-1
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import hubspot from "../../hubspot.app.mjs";
2+
3+
export default {
4+
key: "hubspot-get-subscription-preferences",
5+
name: "Get Subscription Preferences",
6+
description: "Retrieves the subscription preferences for a contact. [See the documentation](https://developers.hubspot.com/docs/reference/api/marketing/subscriptions#get-%2Fcommunication-preferences%2Fv4%2Fstatuses%2F%7Bsubscriberidstring%7D)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
hubspot,
11+
contactEmail: {
12+
propDefinition: [
13+
hubspot,
14+
"contactEmail",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.hubspot.getSubscriptionPreferences({
20+
$,
21+
email: this.contactEmail,
22+
params: {
23+
channel: "EMAIL",
24+
},
25+
});
26+
27+
$.export("$summary", `Retrieved subscription preferences for ${this.contactEmail}`);
28+
return response;
29+
},
30+
};
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
import hubspot from "../../hubspot.app.mjs";
2+
3+
export default {
4+
key: "hubspot-list-blog-posts",
5+
name: "List Blog Posts",
6+
description: "Retrieves a list of blog posts. [See the documentation](https://developers.hubspot.com/docs/reference/api/cms/blogs/blog-posts)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
hubspot,
11+
createdAt: {
12+
type: "string",
13+
label: "Created At",
14+
description: "Only return Blog Posts created at exactly the specified time. Format: YYYY-MM-DDTHH:MM:SSZ",
15+
optional: true,
16+
},
17+
createdAfter: {
18+
type: "string",
19+
label: "Created After",
20+
description: "Only return Blog Posts created after the specified time. Format: YYYY-MM-DDTHH:MM:SSZ",
21+
optional: true,
22+
},
23+
createdBefore: {
24+
type: "string",
25+
label: "Created Before",
26+
description: "Only return Blog Posts created before the specified time. Format: YYYY-MM-DDTHH:MM:SSZ",
27+
optional: true,
28+
},
29+
updatedAt: {
30+
type: "string",
31+
label: "Updated At",
32+
description: "Only return Blog Posts updated at exactly the specified time. Format: YYYY-MM-DDTHH:MM:SSZ",
33+
optional: true,
34+
},
35+
updatedAfter: {
36+
type: "string",
37+
label: "Updated After",
38+
description: "Only return Blog Posts updated after the specified time. Format: YYYY-MM-DDTHH:MM:SSZ",
39+
optional: true,
40+
},
41+
updatedBefore: {
42+
type: "string",
43+
label: "Updated Before",
44+
description: "Only return Blog Posts updated before the specified time. Format: YYYY-MM-DDTHH:MM:SSZ",
45+
optional: true,
46+
},
47+
archived: {
48+
type: "boolean",
49+
label: "Archived",
50+
description: "Specifies whether to return deleted Blog Posts",
51+
optional: true,
52+
},
53+
sort: {
54+
type: "string",
55+
label: "Sort",
56+
description: "Sort the results by the specified field",
57+
options: [
58+
"name",
59+
"createdAt",
60+
"updatedAt",
61+
"createdBy",
62+
"updatedBy",
63+
],
64+
optional: true,
65+
},
66+
maxResults: {
67+
type: "integer",
68+
label: "Max Results",
69+
description: "The maximum number of results to return",
70+
default: 100,
71+
optional: true,
72+
},
73+
},
74+
async run({ $ }) {
75+
const results = [];
76+
let hasMore, count = 0;
77+
78+
const params = {
79+
createdAt: this.createdAt,
80+
createdAfter: this.createdAfter,
81+
createdBefore: this.createdBefore,
82+
updatedAt: this.updatedAt,
83+
updatedAfter: this.updatedAfter,
84+
updatedBefore: this.updatedBefore,
85+
archived: this.archived,
86+
sort: this.sort,
87+
};
88+
89+
do {
90+
const {
91+
paging, results,
92+
} = await this.hubspot.getBlogPosts({
93+
$,
94+
params,
95+
});
96+
if (!results?.length) {
97+
break;
98+
}
99+
for (const item of results) {
100+
results.push(item);
101+
count++;
102+
if (count >= this.maxResults) {
103+
break;
104+
}
105+
}
106+
hasMore = paging?.next.after;
107+
params.after = paging?.next.after;
108+
} while (hasMore && count < this.maxResults);
109+
110+
$.export("$summary", `Found ${results.length} page${results.length === 1
111+
? ""
112+
: "s"}`);
113+
return results;
114+
},
115+
};
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import hubspot from "../../hubspot.app.mjs";
2+
3+
export default {
4+
key: "hubspot-list-campaigns",
5+
name: "List Campaigns",
6+
description: "Retrieves a list of campaigns. [See the documentation](https://developers.hubspot.com/docs/reference/api/marketing/campaigns#get-%2Fmarketing%2Fv3%2Fcampaigns%2F)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
hubspot,
11+
sort: {
12+
type: "string",
13+
label: "Sort",
14+
description: "The field by which to sort the results. An optional '-' before the property name can denote descending order",
15+
options: [
16+
"hs_name",
17+
"-hs_name",
18+
"createdAt",
19+
"-createdAt",
20+
"updatedAt",
21+
"-updatedAt",
22+
],
23+
optional: true,
24+
},
25+
maxResults: {
26+
type: "integer",
27+
label: "Max Results",
28+
description: "The maximum number of results to return",
29+
default: 100,
30+
optional: true,
31+
},
32+
},
33+
async run({ $ }) {
34+
const results = [];
35+
let hasMore, count = 0;
36+
37+
const params = {
38+
sort: this.sort,
39+
};
40+
41+
do {
42+
const {
43+
paging, results,
44+
} = await this.hubspot.listCampaigns({
45+
$,
46+
params,
47+
});
48+
if (!results?.length) {
49+
break;
50+
}
51+
for (const item of results) {
52+
results.push(item);
53+
count++;
54+
if (count >= this.maxResults) {
55+
break;
56+
}
57+
}
58+
hasMore = paging?.next.after;
59+
params.after = paging?.next.after;
60+
} while (hasMore && count < this.maxResults);
61+
62+
$.export("$summary", `Found ${results.length} campaign${results.length === 1
63+
? ""
64+
: "s"}`);
65+
return results;
66+
},
67+
};
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import hubspot from "../../hubspot.app.mjs";
2+
3+
export default {
4+
key: "hubspot-list-forms",
5+
name: "List Forms",
6+
description: "Retrieves a list of forms. [See the documentation](https://developers.hubspot.com/docs/reference/api/marketing/forms#get-%2Fmarketing%2Fv3%2Fforms%2F)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
hubspot,
11+
archived: {
12+
type: "boolean",
13+
label: "Archived",
14+
description: "Whether to return only results that have been archived",
15+
optional: true,
16+
},
17+
maxResults: {
18+
type: "integer",
19+
label: "Max Results",
20+
description: "The maximum number of results to return",
21+
default: 100,
22+
optional: true,
23+
},
24+
},
25+
async run({ $ }) {
26+
const results = [];
27+
let hasMore, count = 0;
28+
29+
const params = {
30+
archived: this.archived,
31+
};
32+
33+
do {
34+
const {
35+
paging, results,
36+
} = await this.hubspot.listMarketingForms({
37+
$,
38+
params,
39+
});
40+
if (!results?.length) {
41+
break;
42+
}
43+
for (const item of results) {
44+
results.push(item);
45+
count++;
46+
if (count >= this.maxResults) {
47+
break;
48+
}
49+
}
50+
hasMore = paging?.next.after;
51+
params.after = paging?.next.after;
52+
} while (hasMore && count < this.maxResults);
53+
54+
$.export("$summary", `Found ${results.length} form${results.length === 1
55+
? ""
56+
: "s"}`);
57+
return results;
58+
},
59+
};
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
import hubspot from "../../hubspot.app.mjs";
2+
3+
export default {
4+
key: "hubspot-list-marketing-emails",
5+
name: "List Marketing Emails",
6+
description: "Retrieves a list of marketing emails. [See the documentation](https://developers.hubspot.com/docs/reference/api/marketing/emails/marketing-emails#get-%2Fmarketing%2Fv3%2Femails%2F)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
hubspot,
11+
createdAt: {
12+
type: "string",
13+
label: "Created At",
14+
description: "Only return Marketing Emails created at exactly the specified time. Format: YYYY-MM-DDTHH:MM:SSZ",
15+
optional: true,
16+
},
17+
createdAfter: {
18+
type: "string",
19+
label: "Created After",
20+
description: "Only return Marketing Emails created after the specified time. Format: YYYY-MM-DDTHH:MM:SSZ",
21+
optional: true,
22+
},
23+
createdBefore: {
24+
type: "string",
25+
label: "Created Before",
26+
description: "Only return Marketing Emails created before the specified time. Format: YYYY-MM-DDTHH:MM:SSZ",
27+
optional: true,
28+
},
29+
updatedAt: {
30+
type: "string",
31+
label: "Updated At",
32+
description: "Only return Marketing Emails updated at exactly the specified time. Format: YYYY-MM-DDTHH:MM:SSZ",
33+
optional: true,
34+
},
35+
updatedAfter: {
36+
type: "string",
37+
label: "Updated After",
38+
description: "Only return Marketing Emails updated after the specified time. Format: YYYY-MM-DDTHH:MM:SSZ",
39+
optional: true,
40+
},
41+
updatedBefore: {
42+
type: "string",
43+
label: "Updated Before",
44+
description: "Only return Marketing Emails updated before the specified time. Format: YYYY-MM-DDTHH:MM:SSZ",
45+
optional: true,
46+
},
47+
includeStats: {
48+
type: "boolean",
49+
label: "Include Stats",
50+
description: "Include statistics with emails",
51+
optional: true,
52+
},
53+
archived: {
54+
type: "boolean",
55+
label: "Archived",
56+
description: "Specifies whether to return deleted Marketing Emails",
57+
optional: true,
58+
},
59+
sort: {
60+
type: "string",
61+
label: "Sort",
62+
description: "Sort the results by the specified field",
63+
options: [
64+
"name",
65+
"createdAt",
66+
"updatedAt",
67+
"createdBy",
68+
"updatedBy",
69+
],
70+
optional: true,
71+
},
72+
maxResults: {
73+
type: "integer",
74+
label: "Max Results",
75+
description: "The maximum number of results to return",
76+
default: 100,
77+
optional: true,
78+
},
79+
},
80+
async run({ $ }) {
81+
const results = [];
82+
let hasMore, count = 0;
83+
84+
const params = {
85+
createdAt: this.createdAt,
86+
createdAfter: this.createdAfter,
87+
createdBefore: this.createdBefore,
88+
updatedAt: this.updatedAt,
89+
updatedAfter: this.updatedAfter,
90+
updatedBefore: this.updatedBefore,
91+
includeStats: this.includeStats,
92+
archived: this.archived,
93+
sort: this.sort,
94+
};
95+
96+
do {
97+
const {
98+
paging, results,
99+
} = await this.hubspot.listMarketingEmails({
100+
$,
101+
params,
102+
});
103+
if (!results?.length) {
104+
break;
105+
}
106+
for (const item of results) {
107+
results.push(item);
108+
count++;
109+
if (count >= this.maxResults) {
110+
break;
111+
}
112+
}
113+
hasMore = paging?.next.after;
114+
params.after = paging?.next.after;
115+
} while (hasMore && count < this.maxResults);
116+
117+
$.export("$summary", `Found ${results.length} email${results.length === 1
118+
? ""
119+
: "s"}`);
120+
return results;
121+
},
122+
};

0 commit comments

Comments
 (0)