Skip to content

Commit 24e3086

Browse files
committed
new sources
1 parent af6dda5 commit 24e3086

File tree

5 files changed

+128
-2
lines changed

5 files changed

+128
-2
lines changed

components/hubspot/hubspot.app.mjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,5 +1008,19 @@ export default {
10081008
...opts,
10091009
});
10101010
},
1011+
listNotes(opts = {}) {
1012+
return this.makeRequest({
1013+
api: API_PATH.CRMV3,
1014+
endpoint: "/objects/notes",
1015+
...opts,
1016+
});
1017+
},
1018+
listTasks(opts = {}) {
1019+
return this.makeRequest({
1020+
api: API_PATH.CRMV3,
1021+
endpoint: "/objects/tasks",
1022+
...opts,
1023+
});
1024+
},
10111025
},
10121026
};

components/hubspot/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/hubspot",
3-
"version": "0.12.1",
3+
"version": "0.13.0",
44
"description": "Pipedream Hubspot Components",
55
"main": "hubspot.app.mjs",
66
"keywords": [

components/hubspot/sources/common/common.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export default {
181181
},
182182
async run() {
183183
const after = this._getAfter();
184-
const params = this.getParams(after);
184+
const params = await this.getParams(after);
185185
await this.processResults(after, params);
186186
},
187187
};
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import common from "../common/common.mjs";
2+
import {
3+
DEFAULT_LIMIT, OBJECT_TYPES,
4+
} from "../../common/constants.mjs";
5+
6+
export default {
7+
...common,
8+
key: "hubspot-new-note",
9+
name: "New Note Created",
10+
description: "Emit new event for each new note created. [See the documentation](https://developers.hubspot.com/docs/reference/api/crm/engagements/notes#get-%2Fcrm%2Fv3%2Fobjects%2Fnotes)",
11+
version: "0.0.1",
12+
type: "source",
13+
dedupe: "unique",
14+
methods: {
15+
...common.methods,
16+
getTs(note) {
17+
return Date.parse(note.createdAt);
18+
},
19+
generateMeta(note) {
20+
return {
21+
id: note.id,
22+
summary: `New Note: ${note.properties.hs_body_preview || note.id}`,
23+
ts: this.getTs(note),
24+
};
25+
},
26+
isRelevant(note, createdAfter) {
27+
return this.getTs(note) > createdAfter;
28+
},
29+
async getParams() {
30+
const { results: allProperties } = await this.hubspot.getProperties({
31+
objectType: "notes",
32+
});
33+
const properties = allProperties.map(({ name }) => name);
34+
35+
const objectTypes = OBJECT_TYPES.map(({ value }) => value);
36+
const { results: custom } = await this.hubspot.listSchemas();
37+
const customObjects = custom?.map(({ name }) => name);
38+
const associations = [
39+
...objectTypes,
40+
...customObjects,
41+
];
42+
43+
return {
44+
params: {
45+
limit: DEFAULT_LIMIT,
46+
properties: properties.join(","),
47+
associations: associations.join(","),
48+
},
49+
};
50+
},
51+
async processResults(after, params) {
52+
const notes = await this.getPaginatedItems(this.hubspot.listNotes.bind(this), params);
53+
await this.processEvents(notes, after);
54+
},
55+
},
56+
};
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import common from "../common/common.mjs";
2+
import {
3+
DEFAULT_LIMIT, OBJECT_TYPES,
4+
} from "../../common/constants.mjs";
5+
6+
export default {
7+
...common,
8+
key: "hubspot-new-task",
9+
name: "New Task Created",
10+
description: "Emit new event for each new task created. [See the documentation](https://developers.hubspot.com/docs/reference/api/crm/engagements/tasks#get-%2Fcrm%2Fv3%2Fobjects%2Ftasks)",
11+
version: "0.0.1",
12+
type: "source",
13+
dedupe: "unique",
14+
methods: {
15+
...common.methods,
16+
getTs(task) {
17+
return Date.parse(task.createdAt);
18+
},
19+
generateMeta(task) {
20+
return {
21+
id: task.id,
22+
summary: `New Task: ${task.properties.hs_task_subject || task.id}`,
23+
ts: this.getTs(task),
24+
};
25+
},
26+
isRelevant(task, createdAfter) {
27+
return this.getTs(task) > createdAfter;
28+
},
29+
async getParams() {
30+
const { results: allProperties } = await this.hubspot.getProperties({
31+
objectType: "tasks",
32+
});
33+
const properties = allProperties.map(({ name }) => name);
34+
35+
const objectTypes = OBJECT_TYPES.map(({ value }) => value);
36+
const { results: custom } = await this.hubspot.listSchemas();
37+
const customObjects = custom?.map(({ name }) => name);
38+
const associations = [
39+
...objectTypes,
40+
...customObjects,
41+
];
42+
43+
return {
44+
params: {
45+
limit: DEFAULT_LIMIT,
46+
properties: properties.join(","),
47+
associations: associations.join(","),
48+
},
49+
};
50+
},
51+
async processResults(after, params) {
52+
const tasks = await this.getPaginatedItems(this.hubspot.listTasks.bind(this), params);
53+
await this.processEvents(tasks, after);
54+
},
55+
},
56+
};

0 commit comments

Comments
 (0)