linkedin 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5552595bdd5a79931bf124e803d6d6ff3a5e1939
4
- data.tar.gz: 7dd0706eaf4cdd8d0c79544e5c23f5838c561b5f
3
+ metadata.gz: d8b5cc310b3dee430de6ffcd0881d71cb6abbf70
4
+ data.tar.gz: 2a4a132a5cb4b0a9771e86a4a729394f858bdb5f
5
5
  SHA512:
6
- metadata.gz: 9f4b1b612f67887669815943046da41af7a4e9cbf0948a8bbc65ff4cf6ae76027aa16b36fcea8c7edf097ab3798316084d11d89032f2ec0ad568fab9c62110b5
7
- data.tar.gz: 2f922908abab564f4e87027b4fce1e74536e9722a7228f270c48eb00f797b29fc206fda30135988fb74ddc334ad78f5eb8a9172050ccd0804346a1ba03a290fe
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
- def simple_query(path, options={})
64
- fields = options.delete(:fields) || LinkedIn.default_profile_fields
65
-
66
- if options.delete(:public)
67
- path +=":public"
68
- elsif fields
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
- headers = options.delete(:headers) || {}
73
- params = to_query(options)
74
- path += "?#{params}" if !params.empty?
80
+ def simple_query(path, options={})
81
+ fields = options.delete(:fields) || LinkedIn.default_profile_fields
75
82
 
76
- Mash.from_json(get(path, headers))
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
- def person_path(options)
80
- path = "/people/"
81
- if id = options.delete(:id)
82
- path += "id=#{id}"
83
- elsif url = options.delete(:url)
84
- path += "url=#{CGI.escape(url)}"
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
- def company_path(options)
91
- path = "/companies"
92
-
93
- if domain = options.delete(:domain)
94
- path += "?email-domain=#{CGI.escape(domain)}"
95
- elsif id = options.delete(:id)
96
- path += "/id=#{id}"
97
- elsif url = options.delete(:url)
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
- def jobs_path(options)
107
- path = "/jobs"
108
- if id = options.delete(:id)
109
- path += "/id=#{id}"
110
- else
111
- path += "/~"
112
- end
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
- # def clear_status
68
- # path = "/people/~/current-status"
69
- # delete(path).code
70
- # end
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
 
@@ -3,7 +3,7 @@ module LinkedIn
3
3
  module VERSION #:nodoc:
4
4
  MAJOR = 0
5
5
  MINOR = 4
6
- PATCH = 2
6
+ PATCH = 3
7
7
  PRE = nil
8
8
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
9
9
  end
@@ -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 = ['education', 'positions']
13
+ # config.default_profile_fields = ['educations', 'positions']
14
14
  # end
15
15
  #
16
16
  # elsewhere
@@ -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
@@ -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 = ['education', 'positions']
20
+ LinkedIn.default_profile_fields = ['educations', 'positions']
21
21
 
22
- LinkedIn.default_profile_fields.should == ['education', 'positions']
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 = ['education', 'positions']
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 == ['education', 'positions']
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.2
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-08-06 00:00:00.000000000 Z
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.3
224
+ rubygems_version: 2.0.2
225
225
  signing_key:
226
226
  specification_version: 4
227
227
  summary: Ruby wrapper for the LinkedIn API