Created
December 5, 2023 15:58
-
-
Save dmurawsky/103833fb0f0d28b1f09e503e8b56dbeb to your computer and use it in GitHub Desktop.
All HubSpot Requests
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
const getTasks = (ownerId, after) => | |
hubspotInstance | |
.post("/crm/v3/objects/tasks/search", { | |
after, | |
limit: 100, | |
filterGroups: [ | |
{ | |
filters: [ | |
{ | |
propertyName: "hs_task_status", | |
operator: "NEQ", | |
value: "COMPLETED", | |
}, | |
{ | |
propertyName: "hubspot_owner_id", | |
operator: "EQ", | |
value: ownerId, | |
}, | |
], | |
}, | |
], | |
properties: [ | |
"hs_createdate", | |
"hs_lastmodifieddate", | |
"hs_object_id", | |
"hs_task_body", | |
"hs_task_status", | |
"hs_task_subject", | |
"hs_task_type", | |
"hs_timestamp", | |
"hubspot_owner_id", | |
"archived", | |
"home_club", | |
], | |
}) | |
.then(({ data }) => data) | |
.catch(handleCatch); | |
const getMeetings = (ownerId, start, end, after) => | |
hubspotInstance | |
.post("/crm/v3/objects/meetings/search", { | |
after, | |
limit: 100, | |
filterGroups: [ | |
{ | |
filters: [ | |
{ | |
propertyName: "hs_meeting_start_time", | |
operator: "GTE", | |
value: start, | |
}, | |
{ | |
propertyName: "hs_meeting_end_time", | |
operator: "LT", | |
value: end, | |
}, | |
{ | |
value: ownerId, | |
operator: "EQ", | |
propertyName: "hubspot_owner_id", | |
}, | |
], | |
}, | |
], | |
properties: [ | |
"home_club", | |
"hs_createdate", | |
"hs_lastmodifieddate", | |
"hs_object_id", | |
"hs_follow_up_action", | |
"hs_internal_meeting_notes", | |
"hs_meeting_body", | |
"hs_meeting_end_time", | |
"hs_meeting_external_url", | |
"hs_meeting_location", | |
"hs_meeting_outcome", | |
"hs_meeting_start_time", | |
"hs_meeting_title", | |
"hs_timestamp", | |
"hs_activity_type", | |
"hs_attachment_ids", | |
"hubspot_owner_id", | |
"archived", | |
], | |
}) | |
.then(({ data }) => data) | |
.catch(handleCatch); | |
const CONTACT_PROPERTIES = [ | |
"abc_member_id", | |
"abc_memberid", | |
"abc_memberstatus", | |
"abc_homeclub", | |
"abc_joinstatus", | |
"hubspot_owner_id", | |
"firstname", | |
"lastname", | |
"email", | |
"phone", | |
"home_club", | |
"archived", | |
"join_status", | |
"member_status", | |
"membership_type", | |
"contact_status", | |
"lastmodifieddate", | |
"sign_date", | |
"n7_days_after_begin_date", | |
"hs_latest_source_timestamp", | |
"notes_last_contacted", | |
"kiosk_session_completed_at", | |
"createdate", | |
"referring_contact_contact_owner", | |
"set_trial_day_term", | |
"is_past_due", | |
"total_past_due_balance", | |
"last_modified_timestamp", | |
"agreement_number", | |
"abc_agreementnumber", | |
"eas_agreementnumber", | |
]; | |
const getContacts = (ownerId, after, latestSource) => | |
hubspotInstance | |
.post("/crm/v3/objects/contacts/search", { | |
after, | |
limit: 100, | |
filterGroups: [ | |
{ | |
filters: [ | |
{ | |
propertyName: "hubspot_owner_id", | |
operator: "EQ", | |
value: ownerId, | |
}, | |
{ | |
propertyName: "hs_latest_source_timestamp", | |
operator: "GTE", | |
value: latestSource, | |
}, | |
], | |
}, | |
], | |
properties: CONTACT_PROPERTIES, | |
}) | |
.then(({ data }) => data) | |
.catch(handleCatch); | |
const hubSpotSearch = (objectType, filterGroups, properties) => | |
hubspotInstance | |
.post(`/crm/v3/objects/${objectType}/search`, { | |
limit: 100, | |
filterGroups, | |
properties, | |
}) | |
.then(({ data }) => data) | |
.catch(handleCatch); | |
const getAssociatedContact = (objectType, id) => | |
hubspotInstance | |
.get(`/crm/v3/objects/${objectType}/${id}?associations=contact`) | |
.then(({ data }) => data) | |
.catch(handleCatch); | |
const getContact = (id) => | |
hubspotInstance | |
.get(`/crm/v3/objects/contact/${id}?properties=${CONTACT_PROPERTIES.join("%2C")}`) | |
.then(({ data }) => data) | |
.catch(handleCatch); | |
const updateMeetingOutcome = (id, outcome) => | |
hubspotInstance | |
.patch(`/crm/v3/objects/meetings/${id}`, { | |
properties: { | |
hs_meeting_outcome: outcome, | |
}, | |
}) | |
.then(({ data }) => data) | |
.catch(handleCatch); | |
const completeTask = (id) => | |
hubspotInstance | |
.patch(`/crm/v3/objects/tasks/${id}`, { | |
properties: { | |
properties: { | |
hs_task_status: "COMPLETED", | |
}, | |
}, | |
}) | |
.then(({ data }) => data) | |
.catch(handleCatch); | |
const getOwners = () => | |
hubspotInstance | |
.get("/owners/v2/owners") | |
.then(({ data }) => data) | |
.catch(handleCatch); | |
const associateReferralWithMainContact = (referralObjectId, contactId) => | |
hubspotInstance | |
.put(`/crm/v3/objects/2-12480436/${referralObjectId}/associations/0-1/${contactId}/abc_referral_to_contact`) | |
.then(({ data }) => data) | |
.catch(handleCatch); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment