-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* move common files * refactoring * create-associations - parse toObjectIds array * bug fixes * combine create-contact & create-or-update-contact * versions * versions * new-contact & contact-updated -> new-or-updated-contact * new-company & company-updated -> new-or-updated-company * new-deal & new-deal-updated -> new-or-updated-deal * ticket properties * new-product & product-updated -> new-or-updated-product * new-line-item & line-item-updated -> new-or-updated-line-item * new-blog-article & updated-blog-article -> new-or-updated-blog-article * deprecate new-contact-in-list & add list filtering to new-or-updated-contact * filter engagements by type * add email event types * add test-event to new-email-event * add test-events to sources * add default props to create-deal * improve date prop descriptions * add default props to create-ticket * improve batch-create-or-update-contact * add default properties to search-crm * add createIfNotFound to search-crm * add default props for get-company, get-contact, & get-deal * refactoring * updates * improve summary
- Loading branch information
1 parent
e7371bb
commit f6d3a72
Showing
82 changed files
with
2,686 additions
and
1,657 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
102 changes: 102 additions & 0 deletions
102
components/hubspot/actions/common/common-get-object.mjs
This file contains 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,102 @@ | ||
import hubspot from "../../hubspot.app.mjs"; | ||
import { | ||
DEFAULT_CONTACT_PROPERTIES, | ||
DEFAULT_COMPANY_PROPERTIES, | ||
DEFAULT_DEAL_PROPERTIES, | ||
DEFAULT_TICKET_PROPERTIES, | ||
DEFAULT_PRODUCT_PROPERTIES, | ||
DEFAULT_LINE_ITEM_PROPERTIES, | ||
} from "../../common/constants.mjs"; | ||
|
||
export default { | ||
props: { | ||
hubspot, | ||
objectId: { | ||
type: "string", | ||
label: "Object ID", | ||
description: "Hubspot's internal ID for the object", | ||
async options(opts) { | ||
return this.hubspot.createOptions(this.getObjectType(), opts); | ||
}, | ||
reloadProps: true, | ||
}, | ||
info: { | ||
type: "alert", | ||
alertType: "info", | ||
content: "", | ||
hidden: true, | ||
}, | ||
// eslint-disable-next-line pipedream/props-description | ||
additionalProperties: { | ||
type: "string[]", | ||
label: "Additional properties to retrieve", | ||
optional: true, | ||
async options({ page }) { | ||
if (page !== 0) { | ||
return []; | ||
} | ||
const { results: properties } = await this.hubspot.getProperties({ | ||
objectType: this.getObjectType(), | ||
}); | ||
const defaultProperties = this.getDefaultProperties(this.getObjectType()); | ||
return properties | ||
.filter(({ name }) => !defaultProperties.includes(name)) | ||
.map((property) => ({ | ||
label: property.label, | ||
value: property.name, | ||
})); | ||
}, | ||
}, | ||
}, | ||
async additionalProps(props) { | ||
return { | ||
info: { | ||
...props.info, | ||
content: `Properties:\n\`${this.getDefaultProperties(this.getObjectType()).join(", ")}\``, | ||
hidden: false, | ||
}, | ||
}; | ||
}, | ||
methods: { | ||
getObjectType() { | ||
throw new Error("getObjectType is not implemented"); | ||
}, | ||
getDefaultProperties(objectType) { | ||
if (objectType === "contact") { | ||
return DEFAULT_CONTACT_PROPERTIES; | ||
} else if (objectType === "company") { | ||
return DEFAULT_COMPANY_PROPERTIES; | ||
} else if (objectType === "deal") { | ||
return DEFAULT_DEAL_PROPERTIES; | ||
} else if (objectType === "ticket") { | ||
return DEFAULT_TICKET_PROPERTIES; | ||
} else if (objectType === "product") { | ||
return DEFAULT_PRODUCT_PROPERTIES; | ||
} else if (objectType === "line_item") { | ||
return DEFAULT_LINE_ITEM_PROPERTIES; | ||
} else { | ||
return []; | ||
} | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const objectType = this.getObjectType(); | ||
const { additionalProperties = [] } = this; | ||
const defaultProperties = this.getDefaultProperties(this.getObjectType()); | ||
|
||
const object = await this.hubspot.getObject( | ||
objectType, | ||
this.objectId, | ||
[ | ||
...defaultProperties, | ||
...additionalProperties, | ||
], | ||
$, | ||
); | ||
|
||
const objectName = this.hubspot.getObjectTypeName(objectType); | ||
$.export("$summary", `Successfully fetched ${objectName}`); | ||
|
||
return object; | ||
}, | ||
}; |
This file contains 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.