linkedin 0.4.4 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/LICENSE +3 -1
- data/README.markdown +13 -9
- data/changelog.markdown +13 -4
- data/examples/authenticate.rb +8 -3
- data/examples/communication.rb +7 -0
- data/lib/linked_in/api/query_methods.rb +12 -2
- data/lib/linked_in/api/update_methods.rb +10 -11
- data/lib/linked_in/version.rb +1 -1
- data/linkedin.gemspec +4 -4
- data/spec/cases/api_spec.rb +32 -10
- metadata +30 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: beb262e6873736feb890b56c140f682c80beb36f
|
4
|
+
data.tar.gz: 8e1878a8f048e6807c3c3470aa9e9cc391ba4354
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4de393817404a35a883e2987ef686e2763a5b9c0d684998aff0c66a28e988dde4da3513889fa6de8bed23562abd2e9a32851d8a6fedb6967d5027d2442c28f6d
|
7
|
+
data.tar.gz: 8b22d8d9eff024281c1a8c388ecabe73e436f3ed80806694113890d319c72c206d3f58ad8a831e37d88e856490bdccf00f8f5d3365f65d2787e1adb998619be3
|
data/.travis.yml
CHANGED
data/LICENSE
CHANGED
data/README.markdown
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# LinkedIn
|
2
2
|
|
3
|
-
Ruby wrapper for the [LinkedIn API](http://developer.linkedin.com).
|
3
|
+
Ruby wrapper for the [LinkedIn API](http://developer.linkedin.com). The LinkedIn gem provides an easy-to-use wrapper for LinkedIn's Oauth/XML APIs.
|
4
4
|
|
5
5
|
Travis CI : [](http://travis-ci.org/hexgnu/linkedin)
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
|
-
|
9
|
+
gem install linkedin
|
10
10
|
|
11
11
|
## Usage
|
12
12
|
|
@@ -15,17 +15,21 @@ Travis CI : [](
|
|
15
15
|
LinkedIn's API uses Oauth for authentication. Luckily, the LinkedIn gem hides most of the gory details from you.
|
16
16
|
|
17
17
|
```ruby
|
18
|
-
require 'rubygems'
|
19
18
|
require 'linkedin'
|
20
19
|
|
21
20
|
# get your api keys at https://www.linkedin.com/secure/developer
|
22
21
|
client = LinkedIn::Client.new('your_consumer_key', 'your_consumer_secret')
|
23
|
-
|
24
|
-
|
22
|
+
|
23
|
+
# If you want to use one of the scopes from linkedin you have to pass it in at this point
|
24
|
+
# You can learn more about it here: http://developer.linkedin.com/documents/authentication
|
25
|
+
request_token = client.request_token({}, :scope => "r_basicprofile+r_emailaddress")
|
26
|
+
|
27
|
+
rtoken = request_token.token
|
28
|
+
rsecret = request_token.secret
|
25
29
|
|
26
30
|
# to test from your desktop, open the following url in your browser
|
27
31
|
# and record the pin it gives you
|
28
|
-
|
32
|
+
request_token.authorize_url
|
29
33
|
=> "https://api.linkedin.com/uas/oauth/authorize?oauth_token=<generated_token>"
|
30
34
|
|
31
35
|
# then fetch your access keys
|
@@ -33,7 +37,7 @@ client.authorize_from_request(rtoken, rsecret, pin)
|
|
33
37
|
=> ["OU812", "8675309"] # <= save these for future requests
|
34
38
|
|
35
39
|
# or authorize from previously fetched access keys
|
36
|
-
|
40
|
+
c.authorize_from_access("OU812", "8675309")
|
37
41
|
|
38
42
|
# you're now free to move about the cabin, call any API method
|
39
43
|
```
|
@@ -50,7 +54,6 @@ client.profile(:id => 'gNma67_AdI')
|
|
50
54
|
client.profile(:url => 'http://www.linkedin.com/in/netherland')
|
51
55
|
```
|
52
56
|
|
53
|
-
|
54
57
|
More examples in the [examples folder](http://github.com/pengwynn/linkedin/blob/master/examples).
|
55
58
|
|
56
59
|
For a nice example on using this in a [Rails App](http://pivotallabs.com/users/will/blog/articles/1096-linkedin-gem-for-a-web-app).
|
@@ -70,6 +73,7 @@ If you want to play with the LinkedIn api without using the gem, have a look at
|
|
70
73
|
* Make your feature addition or bug fix.
|
71
74
|
* Add tests for it. This is important so I don't break it in a
|
72
75
|
future version unintentionally.
|
76
|
+
* Make sure your test doesn't just check of instance of LinkedIn::Mash :smile:.
|
73
77
|
* Commit, do not mess with rakefile, version, or history.
|
74
78
|
(if you want to have your own version, that is fine but
|
75
79
|
bump version in a commit by itself I can ignore when I pull)
|
@@ -77,4 +81,4 @@ If you want to play with the LinkedIn api without using the gem, have a look at
|
|
77
81
|
|
78
82
|
## Copyright
|
79
83
|
|
80
|
-
Copyright (c) 2009-11 [Wynn Netherland](http://wynnnetherland.com). See LICENSE for details.
|
84
|
+
Copyright (c) 2013-Present [Matt Kirk](http://matthewkirk.com) 2009-11 [Wynn Netherland](http://wynnnetherland.com). See LICENSE for details.
|
data/changelog.markdown
CHANGED
@@ -1,20 +1,29 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.4.4 - Jan 11, 2014
|
4
|
+
|
5
|
+
* Group share add
|
6
|
+
* Readme updates
|
7
|
+
|
8
|
+
## 0.4.3
|
9
|
+
|
10
|
+
## 0.4.2
|
11
|
+
|
12
|
+
## 0.4.1
|
13
|
+
|
3
14
|
## 0.4.0 - May 30, 2013
|
4
15
|
|
5
16
|
* Add capability to ask for desired permissions from linked in api
|
6
17
|
* Add option to specify a proxy
|
7
18
|
* Bump hashie version
|
8
19
|
* fix the permission param passing
|
9
|
-
* fix to be able to pass the permission scope
|
20
|
+
* fix to be able to pass the permission scope
|
10
21
|
* Manipulating comments/likes for network_updates ('shares')
|
11
|
-
* Methods to work with comments/likes for share
|
22
|
+
* Methods to work with comments/likes for share
|
12
23
|
* Added a method to get a user's shares
|
13
24
|
* Added current user's shares as an option (client.shares)
|
14
25
|
* Readme Typos
|
15
26
|
|
16
|
-
|
17
|
-
|
18
27
|
## 0.2.x - March x, 2010
|
19
28
|
|
20
29
|
* Removed Crack as a dependency, Nokogiri FTW
|
data/examples/authenticate.rb
CHANGED
@@ -3,12 +3,17 @@ require 'linkedin'
|
|
3
3
|
|
4
4
|
# get your api keys at https://www.linkedin.com/secure/developer
|
5
5
|
client = LinkedIn::Client.new('your_consumer_key', 'your_consumer_secret')
|
6
|
-
|
7
|
-
|
6
|
+
|
7
|
+
# If you want to use one of the scopes from linkedin you have to pass it in at this point
|
8
|
+
# You can learn more about it here: http://developer.linkedin.com/documents/authentication
|
9
|
+
request_token = client.request_token({}, :scope => "r_basicprofile+r_emailaddress")
|
10
|
+
|
11
|
+
rtoken = request_token.token
|
12
|
+
rsecret = request_token.secret
|
8
13
|
|
9
14
|
# to test from your desktop, open the following url in your browser
|
10
15
|
# and record the pin it gives you
|
11
|
-
|
16
|
+
request_token.authorize_url
|
12
17
|
=> "https://api.linkedin.com/uas/oauth/authorize?oauth_token=<generated_token>"
|
13
18
|
|
14
19
|
# then fetch your access keys
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# AUTHENTICATE FIRST found in examples/authenticate.rb
|
2
|
+
|
3
|
+
# client is a LinkedIn::Client
|
4
|
+
|
5
|
+
# send a message to a person in your network. you will need to authenticate the
|
6
|
+
# user and ask for the "w_messages" permission.
|
7
|
+
response = client.send_message("subject", "body", ["person_1_id", "person_2_id"])
|
@@ -87,7 +87,7 @@ module LinkedIn
|
|
87
87
|
path = "#{person_path(options)}/network/updates/key=#{update_key}/likes"
|
88
88
|
simple_query(path, options)
|
89
89
|
end
|
90
|
-
|
90
|
+
|
91
91
|
def picture_urls(options={})
|
92
92
|
picture_size = options.delete(:picture_size) || 'original'
|
93
93
|
path = "#{picture_urls_path(options)}::(#{picture_size})"
|
@@ -109,7 +109,7 @@ module LinkedIn
|
|
109
109
|
if options.delete(:public)
|
110
110
|
path +=":public"
|
111
111
|
elsif fields
|
112
|
-
path +=":(#{fields
|
112
|
+
path +=":(#{build_fields_params(fields)})"
|
113
113
|
end
|
114
114
|
|
115
115
|
headers = options.delete(:headers) || {}
|
@@ -119,6 +119,16 @@ module LinkedIn
|
|
119
119
|
Mash.from_json(get(path, headers))
|
120
120
|
end
|
121
121
|
|
122
|
+
def build_fields_params(fields)
|
123
|
+
if fields.is_a?(Hash) && !fields.empty?
|
124
|
+
fields.map {|index,value| "#{index}:(#{build_fields_params(value)})" }.join(',')
|
125
|
+
elsif fields.respond_to?(:each)
|
126
|
+
fields.map {|field| build_fields_params(field) }.join(',')
|
127
|
+
else
|
128
|
+
fields.to_s.gsub("_", "-")
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
122
132
|
def person_path(options)
|
123
133
|
path = "/people/"
|
124
134
|
if id = options.delete(:id)
|
@@ -15,6 +15,16 @@ module LinkedIn
|
|
15
15
|
post(path, defaults.merge(share).to_json, "Content-Type" => "application/json")
|
16
16
|
end
|
17
17
|
|
18
|
+
def post_group_discussion(group_id, discussion)
|
19
|
+
warn 'Use add_group_share over post_group_discussion. This will be taken out in future versions'
|
20
|
+
add_group_share(group_id, discussion)
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_group_share(group_id, share)
|
24
|
+
path = "/groups/#{group_id}/posts"
|
25
|
+
post(path, share.to_json, "Content-Type" => "application/json")
|
26
|
+
end
|
27
|
+
|
18
28
|
def follow_company(company_id)
|
19
29
|
path = "/people/~/following/companies"
|
20
30
|
body = {:id => company_id }
|
@@ -69,17 +79,6 @@ module LinkedIn
|
|
69
79
|
post(path, message.to_json, "Content-Type" => "application/json")
|
70
80
|
end
|
71
81
|
|
72
|
-
def post_group_discussion(group_id, discussion)
|
73
|
-
path = "/groups/#{group_id}/posts"
|
74
|
-
|
75
|
-
discussion_post = {
|
76
|
-
'title' => discussion['title'],
|
77
|
-
'summary' => discussion['summary']
|
78
|
-
}
|
79
|
-
|
80
|
-
post(path, discussion_post.to_json, "Content-Type" => "application/json")
|
81
|
-
end
|
82
|
-
|
83
82
|
end
|
84
83
|
|
85
84
|
end
|
data/lib/linked_in/version.rb
CHANGED
data/linkedin.gemspec
CHANGED
@@ -12,11 +12,11 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.add_development_dependency 'simplecov', '~> 0.7'
|
13
13
|
gem.add_development_dependency 'vcr', '~> 2.5'
|
14
14
|
gem.add_development_dependency 'webmock', '~> 1.11'
|
15
|
-
gem.authors = [
|
16
|
-
gem.description =
|
17
|
-
gem.email = ['wynn.netherland@gmail.com', 'josh.kalderimis@gmail.com']
|
15
|
+
gem.authors = ['Matthew Kirk', 'Wynn Netherland', 'Josh Kalderimis']
|
16
|
+
gem.description = 'Ruby wrapper for the LinkedIn API'
|
17
|
+
gem.email = ['meteor.kirk@gmail.com', 'wynn.netherland@gmail.com', 'josh.kalderimis@gmail.com']
|
18
18
|
gem.files = `git ls-files`.split("\n")
|
19
|
-
gem.homepage = 'http://github.com/
|
19
|
+
gem.homepage = 'http://github.com/hexgnu/linkedin'
|
20
20
|
gem.name = 'linkedin'
|
21
21
|
gem.require_paths = ['lib']
|
22
22
|
gem.summary = gem.description
|
data/spec/cases/api_spec.rb
CHANGED
@@ -19,7 +19,7 @@ describe LinkedIn::Api do
|
|
19
19
|
stub_request(:get, "https://api.linkedin.com/v1/people/id=123").to_return(:body => "{}")
|
20
20
|
client.profile(:id => 123).should be_an_instance_of(LinkedIn::Mash)
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
it "should be able to view the picture urls" do
|
24
24
|
stub_request(:get, "https://api.linkedin.com/v1/people/~/picture-urls::(original)").to_return(:body => "{}")
|
25
25
|
client.picture_urls.should be_an_instance_of(LinkedIn::Mash)
|
@@ -89,13 +89,6 @@ describe LinkedIn::Api do
|
|
89
89
|
response.code.should == "201"
|
90
90
|
end
|
91
91
|
|
92
|
-
it "should be able to send a message" do
|
93
|
-
stub_request(:post, "https://api.linkedin.com/v1/people/~/mailbox").to_return(:body => "", :status => 201)
|
94
|
-
response = client.send_message("subject", "body", ["recip1", "recip2"])
|
95
|
-
response.body.should == nil
|
96
|
-
response.code.should == "201"
|
97
|
-
end
|
98
|
-
|
99
92
|
it "should be able to like a network update" do
|
100
93
|
stub_request(:put, "https://api.linkedin.com/v1/people/~/network/updates/key=SOMEKEY/is-liked").
|
101
94
|
with(:body => "true").to_return(:body => "", :status => 201)
|
@@ -234,6 +227,11 @@ describe LinkedIn::Api do
|
|
234
227
|
client.group_memberships.should be_an_instance_of(LinkedIn::Mash)
|
235
228
|
end
|
236
229
|
|
230
|
+
it "should be able to parse nested fields" do
|
231
|
+
stub_request(:get, "https://api.linkedin.com/v1/people/~/group-memberships:(group:(id,name,small-logo-url,short-description))").to_return(:body => "{}")
|
232
|
+
client.group_memberships(fields: [{group: ['id', 'name', 'small-logo-url', 'short-description']}]).should be_an_instance_of(LinkedIn::Mash)
|
233
|
+
end
|
234
|
+
|
237
235
|
it "should be able to join a group" do
|
238
236
|
stub_request(:put, "https://api.linkedin.com/v1/people/~/group-memberships/123").to_return(:body => "", :status => 201)
|
239
237
|
|
@@ -255,11 +253,35 @@ describe LinkedIn::Api do
|
|
255
253
|
end
|
256
254
|
|
257
255
|
it 'should be able to post a discussion to a group' do
|
258
|
-
|
259
|
-
|
256
|
+
expected = {
|
257
|
+
'title' => 'New Discussion',
|
258
|
+
'summary' => 'New Summary',
|
259
|
+
'content' => {
|
260
|
+
"submitted-url" => "http://www.google.com"
|
261
|
+
}
|
262
|
+
}
|
263
|
+
|
264
|
+
stub_request(:post, "https://api.linkedin.com/v1/groups/123/posts").with(:body => expected).to_return(:body => "", :status => 201)
|
265
|
+
response = client.post_group_discussion(123, expected)
|
260
266
|
response.body.should == nil
|
261
267
|
response.code.should == '201'
|
262
268
|
end
|
269
|
+
|
270
|
+
it "should be able to share a new group status" do
|
271
|
+
stub_request(:post, "https://api.linkedin.com/v1/groups/1/posts").to_return(:body => "", :status => 201)
|
272
|
+
response = client.add_group_share(1, :comment => "Testing, 1, 2, 3")
|
273
|
+
response.body.should == nil
|
274
|
+
response.code.should == "201"
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
context "Communication API" do
|
279
|
+
it "should be able to send a message" do
|
280
|
+
stub_request(:post, "https://api.linkedin.com/v1/people/~/mailbox").to_return(:body => "", :status => 201)
|
281
|
+
response = client.send_message("subject", "body", ["recip1", "recip2"])
|
282
|
+
response.body.should == nil
|
283
|
+
response.code.should == "201"
|
284
|
+
end
|
263
285
|
end
|
264
286
|
|
265
287
|
context "Errors" do
|
metadata
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linkedin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
+
- Matthew Kirk
|
7
8
|
- Wynn Netherland
|
8
9
|
- Josh Kalderimis
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date:
|
13
|
+
date: 2014-01-16 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: hashie
|
@@ -145,6 +146,7 @@ dependencies:
|
|
145
146
|
version: '1.11'
|
146
147
|
description: Ruby wrapper for the LinkedIn API
|
147
148
|
email:
|
149
|
+
- meteor.kirk@gmail.com
|
148
150
|
- wynn.netherland@gmail.com
|
149
151
|
- josh.kalderimis@gmail.com
|
150
152
|
executables: []
|
@@ -163,6 +165,7 @@ files:
|
|
163
165
|
- Rakefile
|
164
166
|
- changelog.markdown
|
165
167
|
- examples/authenticate.rb
|
168
|
+
- examples/communication.rb
|
166
169
|
- examples/network.rb
|
167
170
|
- examples/profile.rb
|
168
171
|
- examples/sinatra.rb
|
@@ -202,7 +205,7 @@ files:
|
|
202
205
|
- spec/fixtures/cassette_library/LinkedIn_Search/_search_company/by_single_keywords_option_with_facets_to_return.yml
|
203
206
|
- spec/fixtures/cassette_library/LinkedIn_Search/_search_company/by_single_keywords_option_with_pagination.yml
|
204
207
|
- spec/helper.rb
|
205
|
-
homepage: http://github.com/
|
208
|
+
homepage: http://github.com/hexgnu/linkedin
|
206
209
|
licenses: []
|
207
210
|
metadata: {}
|
208
211
|
post_install_message:
|
@@ -221,8 +224,30 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
221
224
|
version: '0'
|
222
225
|
requirements: []
|
223
226
|
rubyforge_project:
|
224
|
-
rubygems_version: 2.0.
|
227
|
+
rubygems_version: 2.0.2
|
225
228
|
signing_key:
|
226
229
|
specification_version: 4
|
227
230
|
summary: Ruby wrapper for the LinkedIn API
|
228
|
-
test_files:
|
231
|
+
test_files:
|
232
|
+
- spec/cases/api_spec.rb
|
233
|
+
- spec/cases/linkedin_spec.rb
|
234
|
+
- spec/cases/mash_spec.rb
|
235
|
+
- spec/cases/oauth_spec.rb
|
236
|
+
- spec/cases/search_spec.rb
|
237
|
+
- spec/fixtures/cassette_library/LinkedIn_Api/Company_API.yml
|
238
|
+
- spec/fixtures/cassette_library/LinkedIn_Client/_authorize_from_request.yml
|
239
|
+
- spec/fixtures/cassette_library/LinkedIn_Client/_request_token.yml
|
240
|
+
- spec/fixtures/cassette_library/LinkedIn_Client/_request_token/with_a_callback_url.yml
|
241
|
+
- spec/fixtures/cassette_library/LinkedIn_Client/_request_token/with_default_options.yml
|
242
|
+
- spec/fixtures/cassette_library/LinkedIn_Search/_search/by_company_name_option.yml
|
243
|
+
- spec/fixtures/cassette_library/LinkedIn_Search/_search/by_first_name_and_last_name_options.yml
|
244
|
+
- spec/fixtures/cassette_library/LinkedIn_Search/_search/by_first_name_and_last_name_options_with_fields.yml
|
245
|
+
- spec/fixtures/cassette_library/LinkedIn_Search/_search/by_keywords_string_parameter.yml
|
246
|
+
- spec/fixtures/cassette_library/LinkedIn_Search/_search/by_single_keywords_option.yml
|
247
|
+
- spec/fixtures/cassette_library/LinkedIn_Search/_search/by_single_keywords_option_with_pagination.yml
|
248
|
+
- spec/fixtures/cassette_library/LinkedIn_Search/_search_company/by_keywords_options_with_fields.yml
|
249
|
+
- spec/fixtures/cassette_library/LinkedIn_Search/_search_company/by_keywords_string_parameter.yml
|
250
|
+
- spec/fixtures/cassette_library/LinkedIn_Search/_search_company/by_single_keywords_option.yml
|
251
|
+
- spec/fixtures/cassette_library/LinkedIn_Search/_search_company/by_single_keywords_option_with_facets_to_return.yml
|
252
|
+
- spec/fixtures/cassette_library/LinkedIn_Search/_search_company/by_single_keywords_option_with_pagination.yml
|
253
|
+
- spec/helper.rb
|