ezlinkedin 0.1.2 → 0.2.2
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/ezlinkedin/api/query_methods.rb +24 -3
- data/lib/ezlinkedin/api/update_methods.rb +16 -5
- data/lib/ezlinkedin/request.rb +6 -0
- data/lib/ezlinkedin/version.rb +1 -1
- data/lib/ezlinkedin.rb +1 -0
- data/spec/api_spec.rb +21 -16
- data/spec/ezlinkedin_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 732cfd1e0e6434f0a3cafe87bd6e6196c4537442
|
4
|
+
data.tar.gz: af17d9ba544c77223fe0c81bf016c45a9dbbca58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 358ee684769177036991aab5cb8b22dcab1f1df0267aec93b6ebf8939729d31ef79594012682e026cbf47620c26a46435bae809567de1d67d942cc8cd900c1a6
|
7
|
+
data.tar.gz: 83813e8d1f536d4e8380a12248b13e3053e43e619e4cf329991ad3e18c8e7eb786b9df133d9ebe6d2fe6417e1c861b2e78854ecc4daedecf98d38912df1ecb09
|
@@ -48,11 +48,23 @@ module EzLinkedin
|
|
48
48
|
# options can also include a string array of fields to return. See
|
49
49
|
# the linkedin api for available fields
|
50
50
|
#
|
51
|
-
# @return [
|
51
|
+
# @return [Mash] Mash hash of results
|
52
52
|
def company(options={})
|
53
53
|
path = company_path(options)
|
54
|
-
|
55
|
-
make_query(path, options,
|
54
|
+
use_fields = options.include?(:fields)
|
55
|
+
make_query(path, options, use_fields)
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
#
|
60
|
+
# Returns the groups the current user is a member of
|
61
|
+
# @param options={} [Hash] can include a string array
|
62
|
+
# containing the names of fields to get from each group
|
63
|
+
#
|
64
|
+
# @return [Mash] Mash hash of results
|
65
|
+
def group_memberships(options={})
|
66
|
+
path = "#{person_path(options)}/group-memberships#{group_options(options)}"
|
67
|
+
make_query(path, options.merge({member: true}), false)
|
56
68
|
end
|
57
69
|
|
58
70
|
private
|
@@ -84,6 +96,7 @@ module EzLinkedin
|
|
84
96
|
end
|
85
97
|
end
|
86
98
|
|
99
|
+
|
87
100
|
#
|
88
101
|
# create a valid path to make a restful request
|
89
102
|
# @param path [String] current path
|
@@ -100,6 +113,8 @@ module EzLinkedin
|
|
100
113
|
path += network_options(options).to_s # if getting updates, add relevant options to the path
|
101
114
|
elsif count = options.delete(:count)
|
102
115
|
path += "?count=#{count}"
|
116
|
+
elsif member = options.delete(:member)
|
117
|
+
path += "?membership-state=member"
|
103
118
|
end
|
104
119
|
|
105
120
|
Mash.from_json(get(path, options))
|
@@ -140,6 +155,12 @@ module EzLinkedin
|
|
140
155
|
options_path += "&#{option}"
|
141
156
|
end
|
142
157
|
end
|
158
|
+
|
159
|
+
def group_options(options)
|
160
|
+
if fields = options.delete(:fields)
|
161
|
+
path = ":(group:(#{fields.join(',')}))"
|
162
|
+
end
|
163
|
+
end
|
143
164
|
end
|
144
165
|
|
145
166
|
end
|
@@ -2,11 +2,10 @@ module EzLinkedin
|
|
2
2
|
module Api
|
3
3
|
|
4
4
|
module UpdateMethods
|
5
|
-
|
6
|
-
#
|
5
|
+
#
|
7
6
|
# post a share to Linkedin
|
8
7
|
# @param share [Hash] a hash containing at least the required
|
9
|
-
# attributes for a share.
|
8
|
+
# attributes for a share.
|
10
9
|
# post_share({:comment => "I'm a comment",
|
11
10
|
# :content => { :title => "A title!",
|
12
11
|
# :description => "A description",
|
@@ -15,13 +14,25 @@ module EzLinkedin
|
|
15
14
|
# },
|
16
15
|
# :visibility => { :code => "anyone"}
|
17
16
|
# })
|
18
|
-
#
|
19
|
-
# @return [HTTP::Response
|
17
|
+
#
|
18
|
+
# @return [HTTP::Response] response of post call
|
20
19
|
def post_share(share)
|
21
20
|
path = "/people/~/shares"
|
22
21
|
defaults = { visibility: { code: 'anyone' } }
|
23
22
|
post(path, defaults.merge(share).to_json, "Content-Type" => "application/json")
|
24
23
|
end
|
24
|
+
|
25
|
+
|
26
|
+
#
|
27
|
+
# Join a group
|
28
|
+
# @param id [Fixnum] number representing group id
|
29
|
+
#
|
30
|
+
# @return [HTTP:Response] response of put call
|
31
|
+
def join_group(id)
|
32
|
+
path = "/people/~/group-memberships/#{id}"
|
33
|
+
body = {'membership-state' => {'code' => 'member'}}
|
34
|
+
put(path, body.to_json, "Content-Type" => "application/json")
|
35
|
+
end
|
25
36
|
end
|
26
37
|
end
|
27
38
|
end
|
data/lib/ezlinkedin/request.rb
CHANGED
@@ -21,6 +21,12 @@ module EzLinkedin
|
|
21
21
|
response
|
22
22
|
end
|
23
23
|
|
24
|
+
def put(path, body='', options={})
|
25
|
+
response = access_token.put("#{API_PATH}#{path}", body, DEFAULT_HEADERS.merge(options))
|
26
|
+
raise_errors(response)
|
27
|
+
response
|
28
|
+
end
|
29
|
+
|
24
30
|
private
|
25
31
|
|
26
32
|
def raise_errors(response)
|
data/lib/ezlinkedin/version.rb
CHANGED
data/lib/ezlinkedin.rb
CHANGED
data/spec/api_spec.rb
CHANGED
@@ -130,22 +130,27 @@ describe EzLinkedin::Api do
|
|
130
130
|
# end
|
131
131
|
end
|
132
132
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
133
|
+
context "Group API" do
|
134
|
+
|
135
|
+
it "should be able to list group memberships for a profile" do
|
136
|
+
stub_request(:get, "https://api.linkedin.com/v1/people/~/group-memberships?membership-state=member").to_return(:body => "{}")
|
137
|
+
client.group_memberships.should be_an_instance_of(EzLinkedin::Mash)
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should be able to get group memberships given an option of fields" do
|
141
|
+
stub_request(:get, "https://api.linkedin.com/v1/people/~/group-memberships:(group:(id,name))?membership-state=member").to_return(:body => "{}")
|
142
|
+
client.group_memberships(fields: ['id', 'name']).should be_an_instance_of(EzLinkedin::Mash)
|
143
|
+
end
|
144
|
+
|
145
|
+
it "should be able to join a group" do
|
146
|
+
stub_request(:put, "https://api.linkedin.com/v1/people/~/group-memberships/123").to_return(:body => "", :status => 201)
|
147
|
+
|
148
|
+
response = client.join_group(123)
|
149
|
+
response.body.should == nil
|
150
|
+
response.code.should == "201"
|
151
|
+
end
|
152
|
+
|
153
|
+
end
|
149
154
|
|
150
155
|
context "Errors" do
|
151
156
|
it "should raise AccessDeniedError when EzLinkedin returns 403 status code" do
|
data/spec/ezlinkedin_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ezlinkedin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- akonwi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oauth
|