Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/hubspot/contact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Contact
RECENT_CONTACTS_PATH = '/contacts/v1/lists/recently_updated/contacts/recent'
CREATE_OR_UPDATE_PATH = '/contacts/v1/contact/createOrUpdate/email/:contact_email'
QUERY_PATH = '/contacts/v1/search/query'
MERGE_CONTACT_PATH = '/contacts/v1/contact/merge-vids/:contact_id'

class << self
# {https://developers.hubspot.com/docs/methods/contacts/create_contact}
Expand Down Expand Up @@ -138,6 +139,12 @@ def search(query, options = {})
response = Hubspot::Connection.get_json(QUERY_PATH, { q: query, count: count, offset: offset })
response.merge("contacts" => response["contacts"].map { |contact_hash| new(contact_hash) })
end

def merge(primary_contact_id, vid_to_merge)
post_data = { vidToMerge: vid_to_merge }
response = Hubspot::Connection.post_json(MERGE_CONTACT_PATH, params: { contact_id: primary_contact_id }, body: post_data )
new(response)
end
end

attr_reader :properties, :vid, :is_new
Expand Down