diff --git a/Gemfile b/Gemfile index d3d99b0..b5aa0f9 100644 --- a/Gemfile +++ b/Gemfile @@ -1,9 +1,10 @@ source "http://rubygems.org" gem "rake" -gem "json", "~>1.4.0" +gem "json", "~>1.4" gem "json_pure", "~>1.4.0" gem "rdoc" +gem "iconv" group :test do gem "rr", "~>1.0" diff --git a/Gemfile.lock b/Gemfile.lock index fdfacc2..8a300ed 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,8 +1,9 @@ GEM remote: http://rubygems.org/ specs: - json (1.4.6) - json (1.4.6-java) + iconv (1.0.4) + json (1.8.1) + json (1.8.1-java) json_pure (1.4.6) rake (0.9.2.2) rdoc (3.11) @@ -14,7 +15,8 @@ PLATFORMS ruby DEPENDENCIES - json (~> 1.4.0) + iconv + json (~> 1.4) json_pure (~> 1.4.0) rake rdoc diff --git a/lib/get_response/contact.rb b/lib/get_response/contact.rb index 0f1719a..516ca1b 100644 --- a/lib/get_response/contact.rb +++ b/lib/get_response/contact.rb @@ -136,6 +136,14 @@ def opens @connection.send_request("get_contact_opens", param)["result"] end + # List dates when links were clicked by contact. If a contact clicked the same link multiple + # times, only the newest date is listed. + # returns:: Hash + def clicks + param = {"contact" => @id} + @connection.send_request("get_contact_clicks", param)["result"] + end + # Set contact name. Method can raise GetResponseError exception. # diff --git a/test/unit/contact_test.rb b/test/unit/contact_test.rb index 299e80e..34f29de 100644 --- a/test/unit/contact_test.rb +++ b/test/unit/contact_test.rb @@ -159,6 +159,15 @@ def test_opens assert_equal 2, resp.keys.size end + def test_clicks + mock(@mocked_response).body { contact_clicks_response } + contact = new_contact + resp = contact.clicks + + assert_kind_of Hash, resp + assert_equal 3, resp.keys.size + end + def test_set_name_exception mock(@mocked_response).body { set_contact_name_exception_response } @@ -280,6 +289,17 @@ def contact_opens_response }.to_json end + def contact_clicks_response + { + "result" => { + "link_id_1" => (Time.now - (1 * 24 * 60 * 60)).to_s, + "link_id_2" => (Time.now - (2 * 24 * 60 * 60)).to_s, + "link_id_3" => (Time.now - (2 * 24 * 60 * 60)).to_s + }, + "error" => nil + }.to_json + end + def set_contact_name_exception_response {