-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - hubspot #17940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+170
−1
Merged
New Components - hubspot #17940
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ecb7c7d
new components
michelle0927 7304b95
pnpm-lock.yaml
michelle0927 efec088
pnpm-lock.yaml
michelle0927 a8912c9
pnpm-lock.yaml
michelle0927 6b8d85f
updates
michelle0927 c4bba00
Merge remote-tracking branch 'origin/master' into issue-17860
michelle0927 50c656f
pnpm-lock.yaml
michelle0927 a13d124
Merge branch 'master' into issue-17860
michelle0927 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
components/hubspot/actions/batch-create-companies/batch-create-companies.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import hubspot from "../../hubspot.app.mjs"; | ||
import { API_PATH } from "../../common/constants.mjs"; | ||
import { parseObject } from "../../common/utils.mjs"; | ||
import { ConfigurationError } from "@pipedream/platform"; | ||
|
||
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.1", | ||
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\"} } ]`", | ||
}, | ||
}, | ||
methods: { | ||
batchCreateCompanies(opts = {}) { | ||
return this.hubspot.makeRequest({ | ||
api: API_PATH.CRMV3, | ||
endpoint: "/objects/companies/batch/create", | ||
method: "POST", | ||
...opts, | ||
}); | ||
}, | ||
}, | ||
async run({ $ }) { | ||
try { | ||
const response = await this.batchCreateCompanies({ | ||
$, | ||
data: { | ||
inputs: parseObject(this.inputs), | ||
}, | ||
}); | ||
$.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; | ||
throw new ConfigurationError(message.split(/:(.+)/)[0]); | ||
} | ||
}, | ||
}; |
47 changes: 47 additions & 0 deletions
47
components/hubspot/actions/batch-update-companies/batch-update-companies.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import hubspot from "../../hubspot.app.mjs"; | ||
import { API_PATH } from "../../common/constants.mjs"; | ||
import { parseObject } from "../../common/utils.mjs"; | ||
import { ConfigurationError } from "@pipedream/platform"; | ||
|
||
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.1", | ||
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\"} } ]`", | ||
}, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
methods: { | ||
batchUpdateCompanies(opts = {}) { | ||
return this.hubspot.makeRequest({ | ||
api: API_PATH.CRMV3, | ||
endpoint: "/objects/companies/batch/update", | ||
method: "POST", | ||
...opts, | ||
}); | ||
}, | ||
}, | ||
async run({ $ }) { | ||
try { | ||
const response = await this.batchUpdateCompanies({ | ||
$, | ||
data: { | ||
inputs: parseObject(this.inputs), | ||
}, | ||
}); | ||
$.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; | ||
throw new ConfigurationError(message.split(/:(.+)/)[0]); | ||
} | ||
}, | ||
}; |
50 changes: 50 additions & 0 deletions
50
components/hubspot/actions/batch-upsert-companies/batch-upsert-companies.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import hubspot from "../../hubspot.app.mjs"; | ||
import { API_PATH } from "../../common/constants.mjs"; | ||
import { parseObject } from "../../common/utils.mjs"; | ||
import { ConfigurationError } from "@pipedream/platform"; | ||
|
||
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.1", | ||
type: "action", | ||
props: { | ||
hubspot, | ||
infoAlert: { | ||
Check warning on line 14 in components/hubspot/actions/batch-upsert-companies/batch-upsert-companies.mjs
|
||
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.", | ||
}, | ||
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\" } } ]`", | ||
}, | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
methods: { | ||
batchUpsertCompanies(opts = {}) { | ||
return this.hubspot.makeRequest({ | ||
api: API_PATH.CRMV3, | ||
endpoint: "/objects/companies/batch/upsert", | ||
method: "POST", | ||
...opts, | ||
}); | ||
}, | ||
}, | ||
async run({ $ }) { | ||
try { | ||
const response = await this.batchUpsertCompanies({ | ||
$, | ||
data: { | ||
inputs: parseObject(this.inputs), | ||
}, | ||
}); | ||
$.export("$summary", `Upserted ${response.results.length} companies`); | ||
return response; | ||
} catch (error) { | ||
const message = JSON.parse((JSON.parse(error.message).message).split(/:(.+)/)[1])[0].message; | ||
throw new ConfigurationError(message.split(/:(.+)/)[0]); | ||
} | ||
}, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export const parseObject = (obj) => { | ||
if (!obj) { | ||
return undefined; | ||
} | ||
if (typeof obj === "string") { | ||
try { | ||
return JSON.parse(obj); | ||
} catch (e) { | ||
return obj; | ||
} | ||
} | ||
if (Array.isArray(obj)) { | ||
return obj.map(parseObject); | ||
} | ||
if (typeof obj === "object") { | ||
return Object.fromEntries(Object.entries(obj).map(([ | ||
key, | ||
value, | ||
]) => [ | ||
key, | ||
parseObject(value), | ||
])); | ||
} | ||
return obj; | ||
}; | ||
michelle0927 marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.