Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #131 from slavik112211/master

Manipulating comments/likes for network_updates ('shares')
  • Loading branch information...
commit bb1372ca943f0f70d61eac4fd9ba2d780ca52cb7 2 parents dae65d8 + 35e65b3
@ryanatwork ryanatwork authored
View
10 lib/linked_in/api/query_methods.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={})
View
20 lib/linked_in/api/update_methods.rb
@@ -21,16 +21,28 @@ def join_group(group_id)
# post(path, share_to_xml(defaults.merge(options)))
# end
#
- # def update_comment(network_key, comment)
- # path = "/people/~/network/updates/key=#{network_key}/update-comments"
- # post(path, comment_to_xml(comment))
- # end
+ def update_comment(network_key, comment)
+ path = "/people/~/network/updates/key=#{network_key}/update-comments"
+ body = {'comment' => comment}
+ post(path, body.to_json, "Content-Type" => "application/json")
+ end
#
# def update_network(message)
# path = "/people/~/person-activities"
# 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
38 spec/cases/api_spec.rb
@@ -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 => "{}")
@@ -41,7 +51,8 @@
end
it "should be able to search with an option and fetch specific fields" do
- stub_request(:get, "https://api.linkedin.com/v1/people-search:(num-results,total)?first-name=Javan").to_return(:body => "{}")
+ stub_request(:get, "https://api.linkedin.com/v1/people-search:(num-results,total)?first-name=Javan").to_return(
+ :body => "{}")
client.search(:first_name => "Javan", :fields => ["num_results", "total"]).should be_an_instance_of(LinkedIn::Mash)
end
@@ -52,13 +63,36 @@
response.code.should == "201"
end
+ it "should be able to comment on network update" do
+ stub_request(:post, "https://api.linkedin.com/v1/people/~/network/updates/key=SOMEKEY/update-comments").to_return(
+ :body => "", :status => 201)
+ response = client.update_comment('SOMEKEY', "Testing, 1, 2, 3")
+ response.body.should == ""
+ response.code.should == "201"
+ end
+
it "should be able to send a message" do
stub_request(:post, "https://api.linkedin.com/v1/people/~/mailbox").to_return(:body => "", :status => 201)
response = client.send_message("subject", "body", ["recip1", "recip2"])
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
Please sign in to comment.
Something went wrong with that request. Please try again.