ezlinkedin 0.0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -8
- data/ezlinkedin.gemspec +1 -1
- data/lib/ezlinkedin/api/query_methods.rb +45 -14
- data/lib/ezlinkedin/api/update_methods.rb +1 -1
- data/lib/ezlinkedin/version.rb +1 -1
- data/spec/api_spec.rb +30 -30
- 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: 9279206e6ac5b5b444a29ee41b4c8e398807b6db
|
4
|
+
data.tar.gz: 687d9e2396ee7cd29b9c19e2dbd8aa75995c8dfc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f653c3d37e99e835e6e32bb9a5c94926dfc76e59960c9a2acfefc529af5d95162ee048db5402e18bce0d513b068794e0896604ebfee88a29c9a89ff467b6fec
|
7
|
+
data.tar.gz: 18dc467e7e54300d7e1ac240bd3c886b3082ee7d16bb7f98609fa8de8b0deef27b3c596513b24938ab22321c31f2096d0b4f29b11e33dfab68f8e41865d3714a
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
A simple way to make calls on Linkedin's API. NOTE: It is not yet completed and does not encompass all of the api at this time. It serves the purpose I made it for but I will continue to develop it.
|
4
4
|
|
5
|
-
This is heavily inspired and influenced by pengwynn
|
5
|
+
This is heavily inspired and influenced by the [pengwynn/linkedin](https://github.com/pengwynn/linkedin) gem. I was having issues with his gem though and there is very little documentation for using it so I decided to redo it myself in order to:
|
6
6
|
* Make it work for what I needed
|
7
7
|
* Add precise and useful documentation
|
8
8
|
* contribute a bit more robust ruby wrapper for Linkedin's API
|
@@ -25,15 +25,26 @@ Or install it yourself as:
|
|
25
25
|
|
26
26
|
## Usage
|
27
27
|
|
28
|
-
|
28
|
+
This is meant to be used alongside omniauth. Obtain access tokens from omniauth authentication and then use them to make api calls.
|
29
29
|
|
30
|
-
|
30
|
+
```ruby
|
31
|
+
require 'ezlinkedin'
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
# Create a client
|
34
|
+
linkedin = EzLinkedin::Client.new("API KEY", "SECRET KEY", options) # options are the typical OAuth consumer options
|
35
|
+
linkedin.authorize("access_token", "access_token_secret") # tokens obtained from omniauth
|
36
|
+
|
37
|
+
linkedin.profile(id: 1234, fields: ['name', 'email']
|
38
|
+
linkedin.connections(count: 30)
|
39
|
+
linkedin.network_updates(types: [:shar, :prfx, :conn], count: 50)
|
40
|
+
linkedin.post_share({:comment => "I'm a comment",
|
41
|
+
:content => { :title => "A title!",
|
42
|
+
:description => "A description",
|
43
|
+
:submitted_url => "http...",
|
44
|
+
:submitted_image_url => "http..." },
|
45
|
+
:visibility => { :code => "anyone"} })
|
46
|
+
```
|
47
|
+
Currently, one can post shares, retrieve updates, user profile, and connections.
|
37
48
|
|
38
49
|
## Contributing
|
39
50
|
|
data/ezlinkedin.gemspec
CHANGED
@@ -27,6 +27,6 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_development_dependency "rspec", '~> 2.6'
|
28
28
|
spec.add_development_dependency 'guard'
|
29
29
|
spec.add_development_dependency 'guard-rspec'
|
30
|
-
spec.add_development_dependency '
|
30
|
+
spec.add_development_dependency 'rb-inotify'
|
31
31
|
spec.add_development_dependency "webmock", '~> 1.11.0'
|
32
32
|
end
|
@@ -2,13 +2,13 @@ module EzLinkedin
|
|
2
2
|
module Api
|
3
3
|
|
4
4
|
module QueryMethods
|
5
|
-
|
6
|
-
#
|
5
|
+
|
6
|
+
#
|
7
7
|
# Retrieve a certain profile depending on the options passed in.
|
8
8
|
# @param options={} [Hash] can be an array of fields as strings and an id,
|
9
|
-
# and a url to a public profile. This can also contain request
|
9
|
+
# and a url to a public profile. This can also contain request
|
10
10
|
# headers
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# @return [Mash] a Mash hash representing the found profile
|
13
13
|
def profile(options={})
|
14
14
|
path = person_path(options)
|
@@ -16,30 +16,45 @@ module EzLinkedin
|
|
16
16
|
end
|
17
17
|
|
18
18
|
|
19
|
-
#
|
19
|
+
#
|
20
20
|
# Retrieve the authenticated user's connections
|
21
21
|
# @param options={} [Hash] pass in fields and/or a count
|
22
|
-
#
|
22
|
+
#
|
23
23
|
# @return [Mash] Mash hash of connections
|
24
24
|
def connections(options={})
|
25
25
|
path = "#{person_path(options)}/connections"
|
26
26
|
make_query(path, options, true)
|
27
27
|
end
|
28
28
|
|
29
|
-
#
|
29
|
+
#
|
30
30
|
# Retrieve the user's social feed
|
31
31
|
# @param options={} [Hash] visit Linkedin's api to
|
32
|
-
# see possible options. it will default to an
|
33
|
-
# aggregated feed unless :scope => 'self'.
|
34
|
-
# :types => [:shar, :recu, :apps]
|
35
|
-
# :count => 5
|
36
|
-
#
|
37
|
-
# @return [Mash] Mash hash of updates
|
32
|
+
# see possible options. it will default to an
|
33
|
+
# aggregated feed unless :scope => 'self'.
|
34
|
+
# :types => [:shar, :recu, :apps]
|
35
|
+
# :count => 5
|
36
|
+
#
|
37
|
+
# @return [Mash] Mash hash of updates
|
38
38
|
def network_updates(options={})
|
39
39
|
path = "#{person_path(options)}/network/updates"
|
40
40
|
make_query(path, options, false)
|
41
41
|
end
|
42
42
|
|
43
|
+
|
44
|
+
#
|
45
|
+
# Do a company search based on id, email, or universal-name
|
46
|
+
# @param options={} [Hash] parameters to search by, includes:
|
47
|
+
# id, universal-name(pass it in as :name), email-domain(:domain).
|
48
|
+
# options can also include a string array of fields to return. See
|
49
|
+
# the linkedin api for available fields
|
50
|
+
#
|
51
|
+
# @return [type] [description]
|
52
|
+
def company(options={})
|
53
|
+
path = company_path(options)
|
54
|
+
fields = options.include?(:fields)
|
55
|
+
make_query(path, options, fields)
|
56
|
+
end
|
57
|
+
|
43
58
|
private
|
44
59
|
|
45
60
|
def person_path(options)
|
@@ -53,7 +68,23 @@ module EzLinkedin
|
|
53
68
|
end
|
54
69
|
end
|
55
70
|
|
56
|
-
|
71
|
+
def company_path(options)
|
72
|
+
path = "/companies"
|
73
|
+
id = options.delete(:id)
|
74
|
+
name = options.delete(:name)
|
75
|
+
domain = options.delete(:domain)
|
76
|
+
if id && name
|
77
|
+
path += "::(#{id},universal-name=#{CGI.escape(name)})"
|
78
|
+
elsif id
|
79
|
+
path += "/#{id}"
|
80
|
+
elsif name
|
81
|
+
path += "/universal-name=#{name}"
|
82
|
+
elsif domain
|
83
|
+
path += "?email-domain=#{domain}"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
#
|
57
88
|
# create a valid path to make a restful request
|
58
89
|
# @param path [String] current path
|
59
90
|
# @param options [Hash] set of options
|
data/lib/ezlinkedin/version.rb
CHANGED
data/spec/api_spec.rb
CHANGED
@@ -99,36 +99,36 @@ describe EzLinkedin::Api do
|
|
99
99
|
# response.code.should == "201"
|
100
100
|
# end
|
101
101
|
#
|
102
|
-
|
103
|
-
#
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
#
|
121
|
-
#
|
122
|
-
|
123
|
-
#
|
124
|
-
#
|
125
|
-
#
|
126
|
-
#
|
127
|
-
#
|
128
|
-
#
|
129
|
-
#
|
130
|
-
#
|
131
|
-
|
102
|
+
context "Company API" do
|
103
|
+
# use_vcr_cassette
|
104
|
+
|
105
|
+
it "should be able to view a company profile" do
|
106
|
+
stub_request(:get, "https://api.linkedin.com/v1/companies/1586").to_return(:body => "{}")
|
107
|
+
client.company(:id => 1586).should be_an_instance_of(EzLinkedin::Mash)
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should be able to view a company by universal name" do
|
111
|
+
stub_request(:get, "https://api.linkedin.com/v1/companies/universal-name=acme").to_return(:body => "{}")
|
112
|
+
client.company(:name => 'acme').should be_an_instance_of(EzLinkedin::Mash)
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should be able to view a company by e-mail domain" do
|
116
|
+
stub_request(:get, "https://api.linkedin.com/v1/companies?email-domain=acme.com").to_return(:body => "{}")
|
117
|
+
client.company(:domain => 'acme.com').should be_an_instance_of(EzLinkedin::Mash)
|
118
|
+
end
|
119
|
+
|
120
|
+
# it "should load correct company data" do
|
121
|
+
# client.company(:id => 1586).name.should == "Amazon"
|
122
|
+
|
123
|
+
# data = client.company(:id => 1586, :fields => %w{ id name industry locations:(address:(city state country-code) is-headquarters) employee-count-range })
|
124
|
+
# data.id.should == 1586
|
125
|
+
# data.name.should == "Amazon"
|
126
|
+
# data.employee_count_range.name.should == "10001+"
|
127
|
+
# data.industry.should == "Internet"
|
128
|
+
# data.locations.all[0].address.city.should == "Seattle"
|
129
|
+
# data.locations.all[0].is_headquarters.should == true
|
130
|
+
# end
|
131
|
+
end
|
132
132
|
|
133
133
|
# context "Group API" do
|
134
134
|
#
|
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.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- akonwi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oauth
|
@@ -137,7 +137,7 @@ dependencies:
|
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
140
|
+
name: rb-inotify
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - '>='
|