Permalink
Browse files

Methods to work with comments/likes for share

  • Loading branch information...
1 parent f32f2eb commit 35e65b3689f2a90de0a1c440922e9b67e265f0ab Slavik Derevyanko committed Aug 6, 2012
Showing with 47 additions and 2 deletions.
  1. +10 −0 lib/linked_in/api/query_methods.rb
  2. +11 −0 lib/linked_in/api/update_methods.rb
  3. +26 −2 spec/cases/api_spec.rb
@@ -33,6 +33,16 @@ def shares(options={})
simple_query(path, options)
end
+ def share_comments(update_key, options={})
+ path = "#{person_path(options)}/network/updates/key=#{update_key}/update-comments"
+ simple_query(path, options)
+ end
+
+ def share_likes(update_key, options={})
+ path = "#{person_path(options)}/network/updates/key=#{update_key}/likes"
+ simple_query(path, options)
+ end
+
private
def simple_query(path, options={})
@@ -32,6 +32,17 @@ def update_comment(network_key, comment)
# post(path, network_update_to_xml(message))
# end
#
+
+ def like_share(network_key)
+ path = "/people/~/network/updates/key=#{network_key}/is-liked"
+ put(path, 'true', "Content-Type" => "application/json")
+ end
+
+ def unlike_share(network_key)
+ path = "/people/~/network/updates/key=#{network_key}/is-liked"
+ put(path, 'false', "Content-Type" => "application/json")
+ end
+
def send_message(subject, body, recipient_paths)
path = "/people/~/mailbox"
View
@@ -29,6 +29,16 @@
stub_request(:get, "https://api.linkedin.com/v1/people/~/network/updates").to_return(:body => "{}")
client.network_updates.should be_an_instance_of(LinkedIn::Mash)
end
+
+ it "should be able to view network_update's comments" do
+ stub_request(:get, "https://api.linkedin.com/v1/people/~/network/updates/key=network_update_key/update-comments").to_return(:body => "{}")
+ client.share_comments("network_update_key").should be_an_instance_of(LinkedIn::Mash)
+ end
+
+ it "should be able to view network_update's likes" do
+ stub_request(:get, "https://api.linkedin.com/v1/people/~/network/updates/key=network_update_key/likes").to_return(:body => "{}")
+ client.share_likes("network_update_key").should be_an_instance_of(LinkedIn::Mash)
+ end
it "should be able to search with a keyword if given a String" do
stub_request(:get, "https://api.linkedin.com/v1/people-search?keywords=business").to_return(:body => "{}")
@@ -67,8 +77,22 @@
response.body.should == ""
response.code.should == "201"
end
-
-
+
+ it "should be able to like a network update" do
+ stub_request(:put, "https://api.linkedin.com/v1/people/~/network/updates/key=SOMEKEY/is-liked").
+ with(:body => "true").to_return(:body => "", :status => 201)
+ response = client.like_share('SOMEKEY')
+ response.body.should == nil
+ response.code.should == "201"
+ end
+
+ it "should be able to unlike a network update" do
+ stub_request(:put, "https://api.linkedin.com/v1/people/~/network/updates/key=SOMEKEY/is-liked").
+ with(:body => "false").to_return(:body => "", :status => 201)
+ response = client.unlike_share('SOMEKEY')
+ response.body.should == nil
+ response.code.should == "201"
+ end
context "Company API" do
use_vcr_cassette

0 comments on commit 35e65b3

Please sign in to comment.