Skip to content

Commit 6b8d85f

Browse files
committed
updates
1 parent a8912c9 commit 6b8d85f

File tree

3 files changed

+51
-24
lines changed

3 files changed

+51
-24
lines changed

components/hubspot/actions/batch-create-companies/batch-create-companies.mjs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import hubspot from "../../hubspot.app.mjs";
22
import { API_PATH } from "../../common/constants.mjs";
33
import { parseObject } from "../../common/utils.mjs";
4+
import { ConfigurationError } from "@pipedream/platform";
45

56
export default {
67
key: "hubspot-batch-create-companies",
@@ -27,13 +28,20 @@ export default {
2728
},
2829
},
2930
async run({ $ }) {
30-
const response = await this.batchCreateCompanies({
31-
$,
32-
data: {
33-
inputs: parseObject(this.inputs),
34-
},
35-
});
36-
$.export("$summary", `Created ${response.results.length} companies`);
37-
return response;
31+
try {
32+
const response = await this.batchCreateCompanies({
33+
$,
34+
data: {
35+
inputs: parseObject(this.inputs),
36+
},
37+
});
38+
$.export("$summary", `Created ${response.results.length} compan${response.results.length === 1
39+
? "y"
40+
: "ies"}`);
41+
return response;
42+
} catch (error) {
43+
const message = JSON.parse((JSON.parse(error.message).message).split(/:(.+)/)[1])[0].message;
44+
throw new ConfigurationError(message.split(/:(.+)/)[0]);
45+
}
3846
},
3947
};

components/hubspot/actions/batch-update-companies/batch-update-companies.mjs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import hubspot from "../../hubspot.app.mjs";
22
import { API_PATH } from "../../common/constants.mjs";
33
import { parseObject } from "../../common/utils.mjs";
4+
import { ConfigurationError } from "@pipedream/platform";
45

56
export default {
67
key: "hubspot-batch-update-companies",
@@ -27,13 +28,20 @@ export default {
2728
},
2829
},
2930
async run({ $ }) {
30-
const response = await this.batchUpdateCompanies({
31-
$,
32-
data: {
33-
inputs: parseObject(this.inputs),
34-
},
35-
});
36-
$.export("$summary", `Updated ${response.results.length} companies`);
37-
return response;
31+
try {
32+
const response = await this.batchUpdateCompanies({
33+
$,
34+
data: {
35+
inputs: parseObject(this.inputs),
36+
},
37+
});
38+
$.export("$summary", `Updated ${response.results.length} compan${response.results.length === 1
39+
? "y"
40+
: "ies"}`);
41+
return response;
42+
} catch (error) {
43+
const message = JSON.parse((JSON.parse(error.message).message).split(/:(.+)/)[1])[0].message;
44+
throw new ConfigurationError(message.split(/:(.+)/)[0]);
45+
}
3846
},
3947
};

components/hubspot/actions/batch-upsert-companies/batch-upsert-companies.mjs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import hubspot from "../../hubspot.app.mjs";
22
import { API_PATH } from "../../common/constants.mjs";
33
import { parseObject } from "../../common/utils.mjs";
4+
import { ConfigurationError } from "@pipedream/platform";
45

56
export default {
67
key: "hubspot-batch-upsert-companies",
@@ -10,6 +11,11 @@ export default {
1011
type: "action",
1112
props: {
1213
hubspot,
14+
infoAlert: {
15+
type: "alert",
16+
alertType: "info",
17+
content: "Create or update companies identified by a unique property value as specified by the `idProperty` query parameter. `idProperty` query param refers to a property whose values are unique for the object. To manage properties in Hubspot, navigate to your Settings -> Data Management -> Properties.",
18+
},
1319
inputs: {
1420
type: "string[]",
1521
label: "Inputs (Companies)",
@@ -27,13 +33,18 @@ export default {
2733
},
2834
},
2935
async run({ $ }) {
30-
const response = await this.batchUpsertCompanies({
31-
$,
32-
data: {
33-
inputs: parseObject(this.inputs),
34-
},
35-
});
36-
$.export("$summary", `Upserted ${response.results.length} companies`);
37-
return response;
36+
try {
37+
const response = await this.batchUpsertCompanies({
38+
$,
39+
data: {
40+
inputs: parseObject(this.inputs),
41+
},
42+
});
43+
$.export("$summary", `Upserted ${response.results.length} companies`);
44+
return response;
45+
} catch (error) {
46+
const message = JSON.parse((JSON.parse(error.message).message).split(/:(.+)/)[1])[0].message;
47+
throw new ConfigurationError(message.split(/:(.+)/)[0]);
48+
}
3849
},
3950
};

0 commit comments

Comments
 (0)