linkedin 0.4.2 → 0.4.3
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/lib/linked_in/api/query_methods.rb +59 -44
- data/lib/linked_in/api/update_methods.rb +15 -22
- data/lib/linked_in/version.rb +1 -1
- data/lib/linkedin.rb +1 -1
- data/spec/cases/api_spec.rb +18 -0
- data/spec/cases/linkedin_spec.rb +4 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8b5cc310b3dee430de6ffcd0881d71cb6abbf70
|
4
|
+
data.tar.gz: 2a4a132a5cb4b0a9771e86a4a729394f858bdb5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4c43db6e21a6c51ce2d26a0a67605f5f06dbac0c699661a15322ec1629b0986b729422f79a87ad37adaed48b9a0e88eb483d2c429a12749f4baa7f2df28e3df
|
7
|
+
data.tar.gz: 6450d72297adf6f0415d895727e3364dc7e8e4ca05d090a78cbbeee42dcd29a8049ceed846e198bab7fdf05cb65aaca7a666f0f770b746c3a7c653432b66ee88
|
@@ -43,6 +43,16 @@ module LinkedIn
|
|
43
43
|
simple_query(path, options)
|
44
44
|
end
|
45
45
|
|
46
|
+
def group_profile(options)
|
47
|
+
path = group_path(options)
|
48
|
+
simple_query(path, options)
|
49
|
+
end
|
50
|
+
|
51
|
+
def group_posts(options)
|
52
|
+
path = "#{group_path(options)}/posts"
|
53
|
+
simple_query(path, options)
|
54
|
+
end
|
55
|
+
|
46
56
|
def shares(options={})
|
47
57
|
path = "#{person_path(options)}/network/updates"
|
48
58
|
simple_query(path, {:type => "SHAR", :scope => "self"}.merge(options))
|
@@ -60,59 +70,64 @@ module LinkedIn
|
|
60
70
|
|
61
71
|
private
|
62
72
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
path +=":(#{fields.map{ |f| f.to_s.gsub("_","-") }.join(',')})"
|
70
|
-
end
|
73
|
+
def group_path(options)
|
74
|
+
path = "/groups"
|
75
|
+
if id = options.delete(:id)
|
76
|
+
path += "/#{id}"
|
77
|
+
end
|
78
|
+
end
|
71
79
|
|
72
|
-
|
73
|
-
|
74
|
-
path += "?#{params}" if !params.empty?
|
80
|
+
def simple_query(path, options={})
|
81
|
+
fields = options.delete(:fields) || LinkedIn.default_profile_fields
|
75
82
|
|
76
|
-
|
83
|
+
if options.delete(:public)
|
84
|
+
path +=":public"
|
85
|
+
elsif fields
|
86
|
+
path +=":(#{fields.map{ |f| f.to_s.gsub("_","-") }.join(',')})"
|
77
87
|
end
|
78
88
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
else
|
86
|
-
path += "~"
|
87
|
-
end
|
88
|
-
end
|
89
|
+
headers = options.delete(:headers) || {}
|
90
|
+
params = to_query(options)
|
91
|
+
path += "?#{params}" if !params.empty?
|
92
|
+
|
93
|
+
Mash.from_json(get(path, headers))
|
94
|
+
end
|
89
95
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
path += "/url=#{CGI.escape(url)}"
|
99
|
-
elsif name = options.delete(:name)
|
100
|
-
path += "/universal-name=#{CGI.escape(name)}"
|
101
|
-
else
|
102
|
-
path += "/~"
|
103
|
-
end
|
96
|
+
def person_path(options)
|
97
|
+
path = "/people/"
|
98
|
+
if id = options.delete(:id)
|
99
|
+
path += "id=#{id}"
|
100
|
+
elsif url = options.delete(:url)
|
101
|
+
path += "url=#{CGI.escape(url)}"
|
102
|
+
else
|
103
|
+
path += "~"
|
104
104
|
end
|
105
|
+
end
|
105
106
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
107
|
+
def company_path(options)
|
108
|
+
path = "/companies"
|
109
|
+
|
110
|
+
if domain = options.delete(:domain)
|
111
|
+
path += "?email-domain=#{CGI.escape(domain)}"
|
112
|
+
elsif id = options.delete(:id)
|
113
|
+
path += "/id=#{id}"
|
114
|
+
elsif url = options.delete(:url)
|
115
|
+
path += "/url=#{CGI.escape(url)}"
|
116
|
+
elsif name = options.delete(:name)
|
117
|
+
path += "/universal-name=#{CGI.escape(name)}"
|
118
|
+
else
|
119
|
+
path += "/~"
|
113
120
|
end
|
121
|
+
end
|
114
122
|
|
123
|
+
def jobs_path(options)
|
124
|
+
path = "/jobs"
|
125
|
+
if id = options.delete(:id)
|
126
|
+
path += "/id=#{id}"
|
127
|
+
else
|
128
|
+
path += "/~"
|
129
|
+
end
|
130
|
+
end
|
115
131
|
end
|
116
|
-
|
117
132
|
end
|
118
133
|
end
|
@@ -21,23 +21,11 @@ module LinkedIn
|
|
21
21
|
post(path, body.to_json, "Content-Type" => "application/json")
|
22
22
|
end
|
23
23
|
|
24
|
-
# def share(options={})
|
25
|
-
# path = "/people/~/shares"
|
26
|
-
# defaults = { :visability => 'anyone' }
|
27
|
-
# post(path, share_to_xml(defaults.merge(options)))
|
28
|
-
# end
|
29
|
-
#
|
30
24
|
def update_comment(network_key, comment)
|
31
25
|
path = "/people/~/network/updates/key=#{network_key}/update-comments"
|
32
26
|
body = {'comment' => comment}
|
33
27
|
post(path, body.to_json, "Content-Type" => "application/json")
|
34
28
|
end
|
35
|
-
#
|
36
|
-
# def update_network(message)
|
37
|
-
# path = "/people/~/person-activities"
|
38
|
-
# post(path, network_update_to_xml(message))
|
39
|
-
# end
|
40
|
-
#
|
41
29
|
|
42
30
|
def like_share(network_key)
|
43
31
|
path = "/people/~/network/updates/key=#{network_key}/is-liked"
|
@@ -51,24 +39,29 @@ module LinkedIn
|
|
51
39
|
|
52
40
|
def send_message(subject, body, recipient_paths)
|
53
41
|
path = "/people/~/mailbox"
|
54
|
-
|
42
|
+
|
55
43
|
message = {
|
56
|
-
'subject' => subject,
|
44
|
+
'subject' => subject,
|
57
45
|
'body' => body,
|
58
46
|
'recipients' => {
|
59
|
-
'values' => recipient_paths.map do |profile_path|
|
60
|
-
{ 'person' => { '_path' => "/people/#{profile_path}" } }
|
47
|
+
'values' => recipient_paths.map do |profile_path|
|
48
|
+
{ 'person' => { '_path' => "/people/#{profile_path}" } }
|
61
49
|
end
|
62
50
|
}
|
63
51
|
}
|
64
52
|
post(path, message.to_json, "Content-Type" => "application/json")
|
65
53
|
end
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
54
|
+
|
55
|
+
def post_group_discussion(group_id, discussion)
|
56
|
+
path = "/groups/#{group_id}/posts"
|
57
|
+
|
58
|
+
discussion_post = {
|
59
|
+
'title' => discussion['title'],
|
60
|
+
'summary' => discussion['summary']
|
61
|
+
}
|
62
|
+
|
63
|
+
post(path, discussion_post.to_json, "Content-Type" => "application/json")
|
64
|
+
end
|
72
65
|
|
73
66
|
end
|
74
67
|
|
data/lib/linked_in/version.rb
CHANGED
data/lib/linkedin.rb
CHANGED
@@ -10,7 +10,7 @@ module LinkedIn
|
|
10
10
|
# LinkedIn.configure do |config|
|
11
11
|
# config.token = 'consumer_token'
|
12
12
|
# config.secret = 'consumer_secret'
|
13
|
-
# config.default_profile_fields = ['
|
13
|
+
# config.default_profile_fields = ['educations', 'positions']
|
14
14
|
# end
|
15
15
|
#
|
16
16
|
# elsewhere
|
data/spec/cases/api_spec.rb
CHANGED
@@ -183,6 +183,24 @@ describe LinkedIn::Api do
|
|
183
183
|
response.code.should == "201"
|
184
184
|
end
|
185
185
|
|
186
|
+
it "should be able to list a group profile" do
|
187
|
+
stub_request(:get, "https://api.linkedin.com/v1/groups/123").to_return(:body => '{"id": "123"}')
|
188
|
+
response = client.group_profile(:id => 123)
|
189
|
+
response.id.should == '123'
|
190
|
+
end
|
191
|
+
|
192
|
+
it "should be able to list group posts" do
|
193
|
+
stub_request(:get, "https://api.linkedin.com/v1/groups/123/posts").to_return(:body => '{"id": "123"}')
|
194
|
+
response = client.group_posts(:id => 123)
|
195
|
+
response.id.should == '123'
|
196
|
+
end
|
197
|
+
|
198
|
+
it 'should be able to post a discussion to a group' do
|
199
|
+
stub_request(:post, "https://api.linkedin.com/v1/groups/123/posts").to_return(:body => "", :status => 201)
|
200
|
+
response = client.post_group_discussion(123, {'title' => 'New Discussion', 'summary' => 'New Summary'})
|
201
|
+
response.body.should == nil
|
202
|
+
response.code.should == '201'
|
203
|
+
end
|
186
204
|
end
|
187
205
|
|
188
206
|
context "Errors" do
|
data/spec/cases/linkedin_spec.rb
CHANGED
@@ -17,21 +17,21 @@ describe LinkedIn do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should be able to set the default profile fields" do
|
20
|
-
LinkedIn.default_profile_fields = ['
|
20
|
+
LinkedIn.default_profile_fields = ['educations', 'positions']
|
21
21
|
|
22
|
-
LinkedIn.default_profile_fields.should == ['
|
22
|
+
LinkedIn.default_profile_fields.should == ['educations', 'positions']
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should be able to set the consumer token and consumer secret via a configure block" do
|
26
26
|
LinkedIn.configure do |config|
|
27
27
|
config.token = 'consumer_token'
|
28
28
|
config.secret = 'consumer_secret'
|
29
|
-
config.default_profile_fields = ['
|
29
|
+
config.default_profile_fields = ['educations', 'positions']
|
30
30
|
end
|
31
31
|
|
32
32
|
LinkedIn.token.should == 'consumer_token'
|
33
33
|
LinkedIn.secret.should == 'consumer_secret'
|
34
|
-
LinkedIn.default_profile_fields.should == ['
|
34
|
+
LinkedIn.default_profile_fields.should == ['educations', 'positions']
|
35
35
|
end
|
36
36
|
|
37
37
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wynn Netherland
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-09-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hashie
|
@@ -221,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
221
221
|
version: '0'
|
222
222
|
requirements: []
|
223
223
|
rubyforge_project:
|
224
|
-
rubygems_version: 2.0.
|
224
|
+
rubygems_version: 2.0.2
|
225
225
|
signing_key:
|
226
226
|
specification_version: 4
|
227
227
|
summary: Ruby wrapper for the LinkedIn API
|