Skip to content
2 changes: 1 addition & 1 deletion components/apimage/apimage.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
console.log(Object.keys(this.$auth));
},
},
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import hubspot from "../../hubspot.app.mjs";
export default {
key: "hubspot-add-contact-to-list",
name: "Add Contact to List",
description: "Adds a contact to a specific static list. [See the documentation](https://legacydocs.hubspot.com/docs/methods/lists/add_contact_to_list)",
version: "0.0.21",
description:
"Adds a contact to a specific static list. [See the documentation](https://legacydocs.hubspot.com/docs/methods/lists/add_contact_to_list)",
version: "0.0.23",
type: "action",
props: {
hubspot,
Expand All @@ -18,7 +19,8 @@ export default {
],
type: "string",
label: "List",
description: "The list which the contact will be added to. Only static lists are shown here, as dynamic lists cannot be manually added to.",
description:
"The list which the contact will be added to. Only static lists are shown here, as dynamic lists cannot be manually added to.",
},
contactEmail: {
propDefinition: [
Expand All @@ -30,8 +32,7 @@ export default {
},
async run({ $ }) {
const {
list,
contactEmail,
list, contactEmail,
} = this;
const response = await this.hubspot.addContactsToList({
$,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ import hubspot from "../../hubspot.app.mjs";
export default {
key: "hubspot-batch-create-companies",
name: "Batch Create Companies",
description: "Create a batch of companies in Hubspot. [See the documentation](https://developers.hubspot.com/docs/reference/api/crm/objects/companies#post-%2Fcrm%2Fv3%2Fobjects%2Fcompanies%2Fbatch%2Fcreate)",
version: "0.0.4",
description:
"Create a batch of companies in Hubspot. [See the documentation](https://developers.hubspot.com/docs/reference/api/crm/objects/companies#post-%2Fcrm%2Fv3%2Fobjects%2Fcompanies%2Fbatch%2Fcreate)",
version: "0.0.6",
type: "action",
props: {
hubspot,
inputs: {
type: "string[]",
label: "Inputs (Companies)",
description: "Provide a **list of companies** to be created. [See the documentation](https://developers.hubspot.com/docs/reference/api/crm/objects/companies#post-%2Fcrm%2Fv3%2Fobjects%2Fcompanies%2Fbatch%2Fcreate) for more information. Example: `[ { \"properties\": { \"name\": \"CompanyName\"} } ]`",
description:
"Provide a **list of companies** to be created. [See the documentation](https://developers.hubspot.com/docs/reference/api/crm/objects/companies#post-%2Fcrm%2Fv3%2Fobjects%2Fcompanies%2Fbatch%2Fcreate) for more information. Example: `[ { \"properties\": { \"name\": \"CompanyName\"} } ]`",
},
},
methods: {
Expand All @@ -35,12 +37,19 @@ export default {
inputs: parseObject(this.inputs),
},
});
$.export("$summary", `Created ${response.results.length} compan${response.results.length === 1
? "y"
: "ies"}`);
$.export(
"$summary",
`Created ${response.results.length} compan${
response.results.length === 1
? "y"
: "ies"
}`,
);
return response;
} catch (error) {
const message = JSON.parse((JSON.parse(error.message).message).split(/:(.+)/)[1])[0].message;
const message = JSON.parse(
JSON.parse(error.message).message.split(/:(.+)/)[1],
)[0].message;
throw new ConfigurationError(message.split(/:(.+)/)[0]);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,28 @@ import hubspot from "../../hubspot.app.mjs";
export default {
key: "hubspot-batch-create-or-update-contact",
name: "Batch Create or Update Contact",
description: "Create or update a batch of contacts by its ID or email. [See the documentation](https://developers.hubspot.com/docs/api/crm/contacts)",
version: "0.0.18",
description:
"Create or update a batch of contacts by its ID or email. [See the documentation](https://developers.hubspot.com/docs/api/crm/contacts)",
version: "0.0.20",
type: "action",
props: {
hubspot,
contacts: {
label: "Contacts Array",
description: "Provide a **list of contacts** to be created or updated. If the provided contact has the prop ID or if the provided email already exists, this action will attempt to update it.\n\n**Expected format for create:** `{ \"company\": \"Biglytics\", \"email\": \"[email protected]\", \"firstname\": \"Bryan\", \"lastname\": \"Cooper\", \"phone\": \"(877) 929-0687\", \"website\": \"biglytics.net\" }` \n\n**Expected format for update:** `{ \"id\": \"101\", \"company\": \"Biglytics\", \"email\": \"[email protected]\", \"firstname\": \"Bryan\", \"lastname\": \"Cooper\", \"phone\": \"(877) 929-0687\", \"website\": \"biglytics.net\" }`",
description:
"Provide a **list of contacts** to be created or updated. If the provided contact has the prop ID or if the provided email already exists, this action will attempt to update it.\n\n**Expected format for create:** `{ \"company\": \"Biglytics\", \"email\": \"[email protected]\", \"firstname\": \"Bryan\", \"lastname\": \"Cooper\", \"phone\": \"(877) 929-0687\", \"website\": \"biglytics.net\" }` \n\n**Expected format for update:** `{ \"id\": \"101\", \"company\": \"Biglytics\", \"email\": \"[email protected]\", \"firstname\": \"Bryan\", \"lastname\": \"Cooper\", \"phone\": \"(877) 929-0687\", \"website\": \"biglytics.net\" }`",
type: "string[]",
},
},
methods: {
parseContactArray(contacts) {
if (typeof (contacts) === "string") {
if (typeof contacts === "string") {
contacts = JSON.parse(contacts);
}
else if (Array.isArray(contacts) && contacts.length > 0 && typeof (contacts[0]) === "string") {
} else if (
Array.isArray(contacts) &&
contacts.length > 0 &&
typeof contacts[0] === "string"
) {
contacts = contacts.map((contact) => JSON.parse(contact));
}
return contacts;
Expand All @@ -40,15 +45,18 @@ export default {
},
});
const updateEmails = results?.map(({ properties }) => properties.email);
const insertProperties = contacts.filter(({ email }) => !updateEmails.includes(email))
const insertProperties = contacts
.filter(({ email }) => !updateEmails.includes(email))
.map((properties) => ({
properties,
}));
const updateProperties = [];
for (const contact of results) {
updateProperties.push({
id: contact.id,
properties: contacts.find(({ email }) => contact.properties.email === email),
properties: contacts.find(
({ email }) => contact.properties.email === email,
),
});
}
return {
Expand All @@ -62,9 +70,11 @@ export default {

const {
insertProperties, updateProperties,
} = await this.searchExistingContactProperties(contacts, $);
} =
await this.searchExistingContactProperties(contacts, $);

const updatePropertiesWithId = contacts.filter((contact) => (Object.prototype.hasOwnProperty.call(contact, "id")))
const updatePropertiesWithId = contacts
.filter((contact) => Object.prototype.hasOwnProperty.call(contact, "id"))
.map(({
id, ...properties
}) => ({
Expand All @@ -90,7 +100,10 @@ export default {
},
});

$.export("$summary", `Successfully created ${insertProperties.length} and updated ${updateProperties.length} contacts`);
$.export(
"$summary",
`Successfully created ${insertProperties.length} and updated ${updateProperties.length} contacts`,
);

return response;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ import hubspot from "../../hubspot.app.mjs";
export default {
key: "hubspot-batch-update-companies",
name: "Batch Update Companies",
description: "Update a batch of companies in Hubspot. [See the documentation](https://developers.hubspot.com/docs/reference/api/crm/objects/companies#post-%2Fcrm%2Fv3%2Fobjects%2Fcompanies%2Fbatch%2Fupdate)",
version: "0.0.4",
description:
"Update a batch of companies in Hubspot. [See the documentation](https://developers.hubspot.com/docs/reference/api/crm/objects/companies#post-%2Fcrm%2Fv3%2Fobjects%2Fcompanies%2Fbatch%2Fupdate)",
version: "0.0.6",
type: "action",
props: {
hubspot,
inputs: {
type: "string[]",
label: "Inputs (Companies)",
description: "Provide a **list of companies** to be updated. [See the documentation](https://developers.hubspot.com/docs/reference/api/crm/objects/companies#post-%2Fcrm%2Fv3%2Fobjects%2Fcompanies%2Fbatch%2Fupdate) for more information. Example: `[ { \"id\": \"123\", \"properties\": { \"name\": \"CompanyName\"} } ]`",
description:
"Provide a **list of companies** to be updated. [See the documentation](https://developers.hubspot.com/docs/reference/api/crm/objects/companies#post-%2Fcrm%2Fv3%2Fobjects%2Fcompanies%2Fbatch%2Fupdate) for more information. Example: `[ { \"id\": \"123\", \"properties\": { \"name\": \"CompanyName\"} } ]`",
},
},
methods: {
Expand All @@ -35,12 +37,19 @@ export default {
inputs: parseObject(this.inputs),
},
});
$.export("$summary", `Updated ${response.results.length} compan${response.results.length === 1
? "y"
: "ies"}`);
$.export(
"$summary",
`Updated ${response.results.length} compan${
response.results.length === 1
? "y"
: "ies"
}`,
);
return response;
} catch (error) {
const message = JSON.parse((JSON.parse(error.message).message).split(/:(.+)/)[1])[0].message;
const message = JSON.parse(
JSON.parse(error.message).message.split(/:(.+)/)[1],
)[0].message;
throw new ConfigurationError(message.split(/:(.+)/)[0]);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,23 @@
export default {
key: "hubspot-batch-upsert-companies",
name: "Batch Upsert Companies",
description: "Upsert a batch of companies in Hubspot. [See the documentation](https://developers.hubspot.com/docs/reference/api/crm/objects/companies#post-%2Fcrm%2Fv3%2Fobjects%2Fcompanies%2Fbatch%2Fupsert)",
version: "0.0.4",
description:
"Upsert a batch of companies in Hubspot. [See the documentation](https://developers.hubspot.com/docs/reference/api/crm/objects/companies#post-%2Fcrm%2Fv3%2Fobjects%2Fcompanies%2Fbatch%2Fupsert)",
version: "0.0.6",
type: "action",
props: {
hubspot,
infoAlert: {

Check warning on line 15 in components/hubspot/actions/batch-upsert-companies/batch-upsert-companies.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop infoAlert must have a description. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 15 in components/hubspot/actions/batch-upsert-companies/batch-upsert-companies.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop infoAlert must have a label. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "info",
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.",
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.",
},
inputs: {
type: "string[]",
label: "Inputs (Companies)",
description: "Provide a **list of companies** to be upserted. [See the documentation](https://developers.hubspot.com/docs/reference/api/crm/objects/companies#post-%2Fcrm%2Fv3%2Fobjects%2Fcompanies%2Fbatch%2Fupsert) for more information. Example: `[ { \"idProperty\": \"unique_property\", \"id\": \"123\", \"properties\": { \"name\": \"CompanyName\" } } ]`",
description:
"Provide a **list of companies** to be upserted. [See the documentation](https://developers.hubspot.com/docs/reference/api/crm/objects/companies#post-%2Fcrm%2Fv3%2Fobjects%2Fcompanies%2Fbatch%2Fupsert) for more information. Example: `[ { \"idProperty\": \"unique_property\", \"id\": \"123\", \"properties\": { \"name\": \"CompanyName\" } } ]`",
},
},
methods: {
Expand All @@ -43,7 +46,9 @@
$.export("$summary", `Upserted ${response.results.length} companies`);
return response;
} catch (error) {
const message = JSON.parse((JSON.parse(error.message).message).split(/:(.+)/)[1])[0].message;
const message = JSON.parse(
JSON.parse(error.message).message.split(/:(.+)/)[1],
)[0].message;
throw new ConfigurationError(message.split(/:(.+)/)[0]);
}
},
Expand Down
5 changes: 3 additions & 2 deletions components/hubspot/actions/clone-email/clone-email.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import hubspot from "../../hubspot.app.mjs";
export default {
key: "hubspot-clone-email",
name: "Clone Marketing Email",
description: "Clone a marketing email in HubSpot. [See the documentation](https://developers.hubspot.com/docs/reference/api/marketing/emails/marketing-emails#post-%2Fmarketing%2Fv3%2Femails%2Fclone)",
version: "0.0.2",
description:
"Clone a marketing email in HubSpot. [See the documentation](https://developers.hubspot.com/docs/reference/api/marketing/emails/marketing-emails#post-%2Fmarketing%2Fv3%2Femails%2Fclone)",
version: "0.0.4",
type: "action",
props: {
hubspot,
Expand Down
10 changes: 7 additions & 3 deletions components/hubspot/actions/clone-site-page/clone-site-page.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import hubspot from "../../hubspot.app.mjs";
export default {
key: "hubspot-clone-site-page",
name: "Clone Site Page",
description: "Clone a site page in Hubspot. [See the documentation](https://developers.hubspot.com/docs/reference/api/cms/pages#post-%2Fcms%2Fv3%2Fpages%2Fsite-pages%2Fclone)",
version: "0.0.2",
description:
"Clone a site page in Hubspot. [See the documentation](https://developers.hubspot.com/docs/reference/api/cms/pages#post-%2Fcms%2Fv3%2Fpages%2Fsite-pages%2Fclone)",
version: "0.0.4",
type: "action",
props: {
hubspot,
Expand All @@ -29,7 +30,10 @@ export default {
},
});

$.export("$summary", `Successfully cloned site page with ID: ${response.id}`);
$.export(
"$summary",
`Successfully cloned site page with ID: ${response.id}`,
);

return response;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import hubspot from "../../hubspot.app.mjs";
export default {
key: "hubspot-create-associations",
name: "Create Associations",
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)",
version: "1.0.7",
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)",
version: "1.0.9",
type: "action",
props: {
hubspot,
Expand Down Expand Up @@ -41,7 +42,8 @@ export default {
}),
],
label: "To Object Type",
description: "Type of the objects the from object is being associated with",
description:
"Type of the objects the from object is being associated with",
},
associationType: {
propDefinition: [
Expand All @@ -62,30 +64,34 @@ export default {
}),
],
label: "To Objects",
description: "Id's of the objects the from object is being associated with",
description:
"Id's of the objects the from object is being associated with",
},
},
methods: {
async getAssociationCategory({
$, fromObjectType, toObjectType, associationType,
$,
fromObjectType,
toObjectType,
associationType,
}) {
const { results } = await this.hubspot.getAssociationTypes({
$,
fromObjectType,
toObjectType,
associationType,
});
const association = results.find(({ typeId }) => typeId === this.associationType);
const association = results.find(
({ typeId }) => typeId === this.associationType,
);
return association.category;
},
},
async run({ $ }) {
const {
fromObjectType,
fromObjectId,
toObjectType,
associationType,
} = this;
fromObjectType, fromObjectId, toObjectType, associationType,
} =
this;
let toObjectIds;
if (Array.isArray(this.toObjectIds)) {
toObjectIds = this.toObjectIds;
Expand Down Expand Up @@ -125,9 +131,12 @@ export default {
},
});
const l = response.results.length;
$.export("$summary", `Successfully created ${l} association${l === 1
? ""
: "s"}`);
$.export(
"$summary",
`Successfully created ${l} association${l === 1
? ""
: "s"}`,
);
return response;
},
};
Loading
Loading