@pinpt/hubspot-helper
v1.0.12
Published
<div align="center"> <img width="500" src=".github/logo.svg" alt="Pinpoint Logo" /> </div>
Downloads
11
Keywords
Readme
Setup
npm i @pinpt/hubspot-helper
Methods
buildDefinition
(from: ENTITIES, to: ENTITIES) => DEFINITIONS | undefined
Creates a definition based on the entity being mapped FROM and TO. Returns undefined
if the mapping given does not exist in Hubspot.
invertDefinition
(definition: DEFINITIONS) => DEFINITIONS
Returns the inversion of a definition. For example, if given DEFINITIONS.CHILD_COMPANY_TO_PARENT_COMPANY
, will return DEFINITIONS.PARENT_COMPANY_TO_CHILD_COMPANY
.
createAssociation
(from: HSObjectId, to: HSObjectId, definition: DEFINITIONS) => HSAssociation
Creates an association object that can be sent to the Hubspot API to associate one object ID to another.
createTransactionalEmail
(to: string, emailId: string, properties?: HSTransactionalEmailCustomProperties) => HSTransactionalEmail | undefined
Takes an email address, email template ID, and optional properties array and returns an object that can be sent to the Hubspot API to send a transactional email.
objectIdToNumber
(objectId: HSObjectId) => number
Takes in an object ID as a string or integer, and ensures it is converted to a number for hubspot
createDeal
(properties: HSDealCustomProperties, associatedCompanies: HSObjectId[], associatedUsers?: HSObjectId[]) => HSDeal | undefined
Takes in an array of properties, associated companies, and associated users and returns an object that can be send to the Hubspot API to create a deal
updateManyObjects
(ids: HSObjectId[], values: HSCustomProperty[]) => HSUpdateMany[] | undefined
Takes in an array of object IDs to update to the values given. Each object will be updated with the same options array that is passed. Returns undefined if no object IDs or values are passed.
Return Types
HSAssociation
Can be sent to the hubspot API to create associations
{
fromObjectId: number;
toObjectId: number;
category: CATEGORY;
definitionId: DEFINITIONS;
}
HSDeal
Can be sent to the Hubspot API to create deals
{
associations: {
associatedCompanyIds?: number[];
associatedVids?: number[];
};
properties: HSDealCustomProperties;
}
HSTransactionalEmail
Can be sent to the Hubspot API to send a transactional email
{
emailId: string;
message: HSTransactionalEmailMessage;
customProperties?: HSTransactionalEmailCustomProperties;
}
HSTransactionalEmailMessage
{
to: string;
}
HSCustomProperty
{
name: string;
value: string | number;
}
HSTransactionalEmailCustomProperties
HSCustomProperty[]
HSDealCustomProperties
HSCustomProperty[]
HSUpdateMany
Can be sent to the hubspot API to update many objects with the same fields
{
objectId: number,
properties: HSCustomProperty[],
}
Hubspot Types
HSObjectId
Object IDs can be input as a string or a number, and the library will handle parsing them to an integer for the Hubspot API if needed.
string | number
CATEGORY
enum CATEGORY {
HUBSPOT_DEFINED = 'HUBSPOT_DEFINED'
}
ENTITIES
enum ENTITIES {
// ENTITIES
CONTACT,
COMPANY,
DEAL,
ENGAGEMENT,
PARENT_COMPANY,
CHILD_COMPANY,
TICKET,
LINE_ITEM,
// Special Entities
ADVISOR,
BOARD_MEMBER,
CONTRACTOR,
MANAGER,
BUSINESS_OWNER,
PARTNER,
RESELLER
}
DEFINITIONS
enum DEFINITIONS {
// Association Definitions
CONTACT_TO_COMPANY = 1,
COMPANY_TO_CONTACT = 2,
DEAL_TO_CONTACT = 3,
CONTACT_TO_DEAL = 4,
DEAL_TO_COMPANY = 5,
COMPANY_TO_DEAL = 6,
COMPANY_TO_ENGAGEMENT = 7,
ENGAGEMENT_TO_COMPANY = 8,
CONTACT_TO_ENGAGEMENT = 9,
ENGAGEMENT_TO_CONTACT = 10,
DEAL_TO_ENGAGEMENT = 11,
ENGAGEMENT_TO_DEAL = 12,
PARENT_COMPANY_TO_CHILD_COMPANY = 13,
CHILD_COMPANY_TO_PARENT_COMPANY = 14,
CONTACT_TO_TICKET = 15,
TICKET_TO_CONTACT = 16,
TICKET_TO_ENGAGEMENT = 17,
ENGAGEMENT_TO_TICKET = 18,
DEAL_TO_LINE_ITEM = 19,
LINE_ITEM_TO_DEAL = 20,
COMPANY_TO_TICKET = 25,
TICKET_TO_COMPANY = 26,
DEAL_TO_TICKET = 27,
TICKET_TO_DEAL = 28,
// Special Associations
ADVISOR_TO_COMPANY = 33,
COMPANY_TO_ADVISOR = 34,
BOARD_MEMBER_TO_COMPANY = 35,
COMPANY_TO_BOARD_MEMBER = 36,
CONTRACTOR_TO_COMPANY = 37,
COMPANY_TO_CONTRACTOR = 38,
MANAGER_TO_COMPANY = 39,
COMPANY_TO_MANAGER = 40,
BUSINESS_OWNER_TO_COMPANY = 41,
COMPANY_TO_BUSINESS_OWNER = 42,
PARTNER_TO_COMPANY = 43,
COMPANY_TO_PARTNER = 44,
RESELLER_TO_COMPANY = 45,
COMPANY_TO_RESELLER = 46,
}