From 99459215982d4985dba6b417c77e258a58670fd7 Mon Sep 17 00:00:00 2001 From: pramodshinde Date: Fri, 27 Dec 2013 12:47:42 +0530 Subject: [PATCH 1/4] New Api's added -Retrieving a List of Companies Followed -Retrieving suggested list companies to Follow --- lib/linked_in/api/query_methods.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/linked_in/api/query_methods.rb b/lib/linked_in/api/query_methods.rb index 106c8ad5..33868483 100644 --- a/lib/linked_in/api/query_methods.rb +++ b/lib/linked_in/api/query_methods.rb @@ -42,6 +42,11 @@ def company_updates_likes(update_key, options={}) path = "#{company_path(options)}/updates/key=#{update_key}/likes" simple_query(path, options) end + + def companies(options={}) + path = companies_path + simple_query(path) + end def job(options = {}) path = jobs_path(options) @@ -148,6 +153,15 @@ def company_path(options) end end + def companies_path(options) + path = "/people/~" + if options[:suggetions] + path += "/suggestions/to-follow/companies" + else + path += "/following/companies" + end + end + def picture_urls_path(options) path = person_path(options) path += "/picture-urls" From d7fca97083458fbe7a8b2c3a032325fc28f132ed Mon Sep 17 00:00:00 2001 From: pramodshinde Date: Fri, 27 Dec 2013 12:58:41 +0530 Subject: [PATCH 2/4] Argument error fixied for retreiving list companies Followed --- lib/linked_in/api/query_methods.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/linked_in/api/query_methods.rb b/lib/linked_in/api/query_methods.rb index 33868483..d1830ee6 100644 --- a/lib/linked_in/api/query_methods.rb +++ b/lib/linked_in/api/query_methods.rb @@ -44,7 +44,7 @@ def company_updates_likes(update_key, options={}) end def companies(options={}) - path = companies_path + path = companies_path(options) simple_query(path) end From 3c952aaff42ce556712517361149961be5ebf2ab Mon Sep 17 00:00:00 2001 From: pramodshinde Date: Fri, 27 Dec 2013 19:36:07 +0530 Subject: [PATCH 3/4] Tests added for - - Retrieving a List of companies user currently following - Retrieving a List of companies suggested companies to follow --- spec/cases/api_spec.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/spec/cases/api_spec.rb b/spec/cases/api_spec.rb index e300859c..98987e56 100644 --- a/spec/cases/api_spec.rb +++ b/spec/cases/api_spec.rb @@ -175,7 +175,7 @@ stub_request(:get, "https://api.linkedin.com/v1/companies/id=1586/updates/key=company_update_key/likes").to_return(:body => "{}") client.company_updates_likes("company_update_key", :id => 1586).should be_an_instance_of(LinkedIn::Mash) end - + it "should be able to follow a company" do stub_request(:post, "https://api.linkedin.com/v1/people/~/following/companies").to_return(:body => "", :status => 201) @@ -191,7 +191,16 @@ response.body.should == nil response.code.should == "201" end + + it "should be able to retrive list of companies user currently following" do + stub_request(:get, "https://api.linkedin.com/v1/people/~/following/companies").to_return(:body => "{}") + client.companies.should be_an_instance_of(LinkedIn::Mash) + end + it "should be able to retrive list of suggested companies to follow" do + stub_request(:get, "https://api.linkedin.com/v1/people/~/suggestions/to-follow/companies").to_return(:body => "{}") + client.companies(suggetions: true).should be_an_instance_of(LinkedIn::Mash) + end end context "Job API" do From a5aea252f728e595caa75f099c12699ca2a8e3fa Mon Sep 17 00:00:00 2001 From: pramodshinde Date: Sat, 28 Dec 2013 13:39:11 +0530 Subject: [PATCH 4/4] Code cleanup for -Retrieving a List of companies user currently following -Retrieving a List of companies suggested companies to follow --- lib/linked_in/api/query_methods.rb | 18 ++++++------------ spec/cases/api_spec.rb | 4 ++-- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/lib/linked_in/api/query_methods.rb b/lib/linked_in/api/query_methods.rb index d1830ee6..dc836726 100644 --- a/lib/linked_in/api/query_methods.rb +++ b/lib/linked_in/api/query_methods.rb @@ -43,9 +43,12 @@ def company_updates_likes(update_key, options={}) simple_query(path, options) end - def companies(options={}) - path = companies_path(options) - simple_query(path) + def suggested_companies + simple_query('/people/~/suggestions/to-follow/companies') + end + + def followed_companies + simple_query('/people/~/following/companies') end def job(options = {}) @@ -153,15 +156,6 @@ def company_path(options) end end - def companies_path(options) - path = "/people/~" - if options[:suggetions] - path += "/suggestions/to-follow/companies" - else - path += "/following/companies" - end - end - def picture_urls_path(options) path = person_path(options) path += "/picture-urls" diff --git a/spec/cases/api_spec.rb b/spec/cases/api_spec.rb index 98987e56..4887b275 100644 --- a/spec/cases/api_spec.rb +++ b/spec/cases/api_spec.rb @@ -194,12 +194,12 @@ it "should be able to retrive list of companies user currently following" do stub_request(:get, "https://api.linkedin.com/v1/people/~/following/companies").to_return(:body => "{}") - client.companies.should be_an_instance_of(LinkedIn::Mash) + client.followed_companies.should be_an_instance_of(LinkedIn::Mash) end it "should be able to retrive list of suggested companies to follow" do stub_request(:get, "https://api.linkedin.com/v1/people/~/suggestions/to-follow/companies").to_return(:body => "{}") - client.companies(suggetions: true).should be_an_instance_of(LinkedIn::Mash) + client.suggested_companies.should be_an_instance_of(LinkedIn::Mash) end end