From e8101c2f08aab6cde8a0f46d859efd302a364659 Mon Sep 17 00:00:00 2001 From: Brian Cody Date: Thu, 14 Sep 2017 10:52:28 -0500 Subject: [PATCH 1/2] Add merge contact option --- lib/hubspot/contact.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/hubspot/contact.rb b/lib/hubspot/contact.rb index 4633d55e..3a25d5b3 100644 --- a/lib/hubspot/contact.rb +++ b/lib/hubspot/contact.rb @@ -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} @@ -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 From 32932f391e564dcf96f8c0f51b23011a410142d2 Mon Sep 17 00:00:00 2001 From: Brian Cody Date: Thu, 14 Sep 2017 11:58:08 -0500 Subject: [PATCH 2/2] Small cleanup --- lib/hubspot/contact.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/hubspot/contact.rb b/lib/hubspot/contact.rb index 3a25d5b3..9d80f9e2 100644 --- a/lib/hubspot/contact.rb +++ b/lib/hubspot/contact.rb @@ -141,8 +141,8 @@ def search(query, options = {}) 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 ) + 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