linkedin-oauth2 0.1.1 → 1.0.0
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 +9 -9
- data/.gitignore +24 -39
- data/.travis.yml +4 -4
- data/.yardopts +2 -0
- data/CHANGELOG.md +10 -0
- data/CONTRIBUTING.md +1 -0
- data/Gemfile +6 -5
- data/LICENSE +19 -17
- data/README.md +399 -0
- data/Rakefile +15 -22
- data/lib/linked_in/access_token.rb +24 -0
- data/lib/linked_in/api.rb +96 -3
- data/lib/linked_in/api_resource.rb +165 -0
- data/lib/linked_in/communications.rb +40 -0
- data/lib/linked_in/companies.rb +146 -0
- data/lib/linked_in/configuration.rb +41 -0
- data/lib/linked_in/connection.rb +31 -0
- data/lib/linked_in/errors.rb +33 -13
- data/lib/linked_in/groups.rb +116 -0
- data/lib/linked_in/jobs.rb +68 -0
- data/lib/linked_in/mash.rb +34 -34
- data/lib/linked_in/oauth2.rb +223 -0
- data/lib/linked_in/people.rb +141 -0
- data/lib/linked_in/search.rb +58 -43
- data/lib/linked_in/share_and_social_stream.rb +128 -0
- data/lib/linked_in/version.rb +1 -9
- data/lib/linkedin-oauth2.rb +43 -25
- data/linkedin-oauth2.gemspec +35 -21
- data/spec/linked_in/api/api_spec.rb +41 -0
- data/spec/linked_in/api/communications_spec.rb +13 -0
- data/spec/linked_in/api/companies_spec.rb +59 -0
- data/spec/linked_in/api/groups_spec.rb +55 -0
- data/spec/linked_in/api/jobs_spec.rb +33 -0
- data/spec/linked_in/api/people_spec.rb +181 -0
- data/spec/linked_in/api/search_spec.rb +71 -0
- data/spec/linked_in/api/share_and_social_stream_spec.rb +60 -0
- data/spec/linked_in/configuration_spec.rb +46 -0
- data/spec/linked_in/connection_spec.rb +10 -0
- data/spec/linked_in/module_loading_spec.rb +23 -0
- data/spec/linked_in/oauth/access_token_spec.rb +27 -0
- data/spec/linked_in/oauth/auth_code_spec.rb +86 -0
- data/spec/linked_in/oauth/credentials_spec.rb +96 -0
- data/spec/linked_in/oauth/get_access_token_spec.rb +108 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/vcr_cassettes/access_token_success.yml +84 -0
- data/spec/vcr_cassettes/bad_code.yml +78 -0
- data/spec/vcr_cassettes/companies_data.yml +44 -0
- data/spec/vcr_cassettes/invalid_access_token.yml +60 -0
- data/spec/vcr_cassettes/not_found.yml +64 -0
- data/spec/vcr_cassettes/people_picture_urls.yml +54 -0
- data/spec/vcr_cassettes/people_profile_connections_fields.yml +73 -0
- data/spec/vcr_cassettes/people_profile_connections_other.yml +78 -0
- data/spec/vcr_cassettes/people_profile_connections_self.yml +78 -0
- data/spec/vcr_cassettes/people_profile_fields_complex.yml +70 -0
- data/spec/vcr_cassettes/people_profile_fields_simple.yml +57 -0
- data/spec/vcr_cassettes/people_profile_lang_spanish.yml +59 -0
- data/spec/vcr_cassettes/people_profile_multiple_fields.yml +68 -0
- data/spec/vcr_cassettes/people_profile_multiple_uids.yml +70 -0
- data/spec/vcr_cassettes/people_profile_multiple_uids_and_urls.yml +76 -0
- data/spec/vcr_cassettes/people_profile_multiple_urls.yml +70 -0
- data/spec/vcr_cassettes/people_profile_new_connections_fields.yml +69 -0
- data/spec/vcr_cassettes/people_profile_new_connections_other.yml +72 -0
- data/spec/vcr_cassettes/people_profile_new_connections_self.yml +72 -0
- data/spec/vcr_cassettes/people_profile_other_uid.yml +59 -0
- data/spec/vcr_cassettes/people_profile_other_url.yml +59 -0
- data/spec/vcr_cassettes/people_profile_own.yml +59 -0
- data/spec/vcr_cassettes/people_profile_own_secure.yml +59 -0
- data/spec/vcr_cassettes/unauthorized.yml +61 -0
- data/spec/vcr_cassettes/unavailable.yml +81 -0
- metadata +145 -88
- data/.autotest +0 -14
- data/.document +0 -5
- data/.gemtest +0 -0
- data/.rspec +0 -1
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/README.markdown +0 -121
- data/changelog.markdown +0 -94
- data/examples/authenticate.rb +0 -16
- data/examples/network.rb +0 -12
- data/examples/profile.rb +0 -18
- data/examples/sinatra.rb +0 -69
- data/examples/status.rb +0 -6
- data/lib/linked_in/api/query_methods.rb +0 -123
- data/lib/linked_in/api/update_methods.rb +0 -76
- data/lib/linked_in/client.rb +0 -31
- data/lib/linked_in/helpers.rb +0 -6
- data/lib/linked_in/helpers/authorization.rb +0 -106
- data/lib/linked_in/helpers/request.rb +0 -93
- data/spec/cases/api_spec.rb +0 -192
- data/spec/cases/linkedin_spec.rb +0 -37
- data/spec/cases/mash_spec.rb +0 -85
- data/spec/cases/oauth_spec.rb +0 -130
- data/spec/cases/search_spec.rb +0 -190
- data/spec/helper.rb +0 -30
data/.autotest
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
Autotest.add_hook(:initialize) do |at|
|
2
|
-
at.add_exception(".git")
|
3
|
-
end
|
4
|
-
|
5
|
-
Autotest.add_hook(:initialize) do |at|
|
6
|
-
at.clear_mappings
|
7
|
-
|
8
|
-
at.add_mapping %r%/^lib/(.*)\.rb$% do |_, m|
|
9
|
-
possible = File.basename(m[1])
|
10
|
-
files_matching %r%^test/.*(#{possible}_test|test_#{possible})\.rb$%
|
11
|
-
end
|
12
|
-
|
13
|
-
at.add_mapping(%r%^test/.*\.rb$%) {|filename, _| filename }
|
14
|
-
end
|
data/.document
DELETED
data/.gemtest
DELETED
File without changes
|
data/.rspec
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|
data/.ruby-gemset
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
linkedin-oauth2
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
ruby-1.9.3-p429
|
data/README.markdown
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
# LinkedIn
|
2
|
-
|
3
|
-
Oauth 2.0 Ruby wrapper for the [LinkedIn API](http://developer.linkedin.com). Heavily inspired by [pengwynn/linkedin](https://github.com/pengwynn/linkedin)'s Oauth 1.0 Linkedin API interface. Most methods are the same as pengwynn/linkedin's gem, but major terminology changes make this incompatible.
|
4
|
-
|
5
|
-
Travis CI : [](http://travis-ci.org/emorikawa/linkedin-oauth2)
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
[sudo] gem install linkedin-oauth2
|
10
|
-
|
11
|
-
## Usage
|
12
|
-
|
13
|
-
### Authenticate Overview
|
14
|
-
|
15
|
-
LinkedIn's API uses OAuth 2.0 for authentication. Luckily, this gem hides most of the gory details from you.
|
16
|
-
|
17
|
-
The gory details can be found [here](https://developer.linkedin.com/documents/authentication)
|
18
|
-
|
19
|
-
For legacy support of LinkedIn's OAuth 1.0a api, refer to the [pengwynn/linkedin](https://github.com/pengwynn/linkedin) gem.
|
20
|
-
|
21
|
-
Basically, you need 3 things to start using LinkedIn's API:
|
22
|
-
|
23
|
-
1. Your application's `client_id` aka **API Key**
|
24
|
-
1. Your application's `client_secret` aka **Secret Key**
|
25
|
-
1. An `access_token` from a user who authorized your app.
|
26
|
-
|
27
|
-
### If you already have a user's `access_token`
|
28
|
-
Then you have already authenticated! Encoded within that access token are
|
29
|
-
all of the permissions you have on a given user. Assuming you requested
|
30
|
-
the appropriate permissions, you can read their profile, grab connections,
|
31
|
-
etc.
|
32
|
-
|
33
|
-
client = LinkedIn::Client.new("<your client_id>",
|
34
|
-
"<your client_secret>",
|
35
|
-
"<user access_token>")
|
36
|
-
client.profile
|
37
|
-
|
38
|
-
You may also use the `set_access_token` method.
|
39
|
-
|
40
|
-
client.set_access_token("<user access_token>", options)
|
41
|
-
|
42
|
-
### If you need to fetch an `access_token` for a user.
|
43
|
-
There are 4 steps:
|
44
|
-
|
45
|
-
1. Setup a client using your application's `client_id` and `client_secret`
|
46
|
-
|
47
|
-
client = LinkedIn::Client.new('your_client_id', 'your_client_secret')
|
48
|
-
|
49
|
-
2. Get the `authorize_url` to bring up the page that will ask a user
|
50
|
-
to verify permissions & grant you access.
|
51
|
-
|
52
|
-
authorize_url = client.authorize_url
|
53
|
-
|
54
|
-
3. Once a user signs in to your OAuth 2.0 box, you will get an
|
55
|
-
`auth_code` aka **code**. (Check in url you were directed to after a
|
56
|
-
successful auth). Use this **auth code** to request the
|
57
|
-
**access token**.
|
58
|
-
|
59
|
-
access_token = client.request_access_token("<auth_code from last step>")
|
60
|
-
|
61
|
-
4. Once you have an `access_token`, you can request profile information or
|
62
|
-
anything else you have permissions for.
|
63
|
-
|
64
|
-
client.profile
|
65
|
-
|
66
|
-
### Profile examples
|
67
|
-
```ruby
|
68
|
-
# get the profile for the authenticated user
|
69
|
-
client.profile
|
70
|
-
|
71
|
-
# get a profile for someone found in network via ID
|
72
|
-
client.profile(:id => 'gNma67_AdI')
|
73
|
-
|
74
|
-
# get a profile for someone via their public profile url
|
75
|
-
client.profile(:url => 'http://www.linkedin.com/in/netherland')
|
76
|
-
```
|
77
|
-
|
78
|
-
|
79
|
-
More examples in the [examples folder](http://github.com/pengwynn/linkedin/blob/master/examples).
|
80
|
-
|
81
|
-
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).
|
82
|
-
|
83
|
-
If you want to play with the LinkedIn api without using the gem, have a look at the [apigee LinkedIn console](http://app.apigee.com/console/linkedin).
|
84
|
-
|
85
|
-
## Migration from OAuth 1.0a to OAuth 2.0
|
86
|
-
### Overall changes
|
87
|
-
* The term `consumer` is now referred to as the `client`
|
88
|
-
* The terms `token`, `consumer token`, or `consumer key` in OAuth 1.0 are now referred to as **`client_id`** in OAuth 2.0
|
89
|
-
* The terms `secret`, or `consumer secret` in OAuth 1.0 are now referred to as **`client_secret`** in OAuth 2.0
|
90
|
-
* In OAuth 1.0 there is both an `auth token` and an `auth secret`. OAuth 2.0 combines these into a single `access token`.
|
91
|
-
* The terms `auth token`, `auth key`, `auth secret`, `access secret`, `access token`, or `access key` have all been collapsed and are now referred to as the **`access token`**.
|
92
|
-
* `require` `linkedin-oauth2` instead of `linkedin`
|
93
|
-
* Removed proxy options
|
94
|
-
|
95
|
-
### Gem api changes
|
96
|
-
* In general, any place that said "consumer" now says "client"
|
97
|
-
* The `authorize_from_request` method has been deprecated. Instead
|
98
|
-
navigate to the url from `authorize_url` then enter the returned code
|
99
|
-
into the `request_access_token` method.
|
100
|
-
* The `authorize_from_access` method has been deprecated. Instead
|
101
|
-
initialize the `LinkedIn::Client.new` with the `access_token`.
|
102
|
-
`client = Linkedin::Client.new(client_id, client_secret, access_token)`
|
103
|
-
|
104
|
-
|
105
|
-
## Note on Patches/Pull Requests
|
106
|
-
|
107
|
-
* Fork the project.
|
108
|
-
* Make your feature addition or bug fix.
|
109
|
-
* Add tests for it. This is important so I don't break it in a
|
110
|
-
future version unintentionally.
|
111
|
-
* Commit, do not mess with rakefile, version, or history.
|
112
|
-
(if you want to have your own version, that is fine but
|
113
|
-
bump version in a commit by itself I can ignore when I pull)
|
114
|
-
* Send me a pull request. Bonus points for topic branches.
|
115
|
-
|
116
|
-
## Testing
|
117
|
-
Run `bundle install`
|
118
|
-
|
119
|
-
## Copyright
|
120
|
-
|
121
|
-
Copyright (c) 2013 [Evan Morikawa](https://twitter.com/E0M). See LICENSE for details.
|
data/changelog.markdown
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
# Changelog
|
2
|
-
|
3
|
-
# OAuth 2.0 Versions
|
4
|
-
|
5
|
-
## 0.1.0 - July 15, 2013
|
6
|
-
|
7
|
-
* Migrated API over to use Linkedin's OAuth 2.0
|
8
|
-
|
9
|
-
# OAuth 1.0 Legacy Versions Via pengwynn/linkedin
|
10
|
-
|
11
|
-
## 0.4.0 - May 30, 2013
|
12
|
-
|
13
|
-
* Add capability to ask for desired permissions from linked in api
|
14
|
-
* Add option to specify a proxy
|
15
|
-
* Bump hashie version
|
16
|
-
* fix the permission param passing
|
17
|
-
* fix to be able to pass the permission scope
|
18
|
-
* Manipulating comments/likes for network_updates ('shares')
|
19
|
-
* Methods to work with comments/likes for share
|
20
|
-
* Added a method to get a user's shares
|
21
|
-
* Added current user's shares as an option (client.shares)
|
22
|
-
* Readme Typos
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
## 0.2.x - March x, 2010
|
27
|
-
|
28
|
-
* Removed Crack as a dependency, Nokogiri FTW
|
29
|
-
|
30
|
-
## 0.2.1 - March 1, 2010
|
31
|
-
|
32
|
-
* Big dependency clean up, only OAuth and Nokogiri are really needed.
|
33
|
-
|
34
|
-
* Use Nokogiri for xml generation (thanks Leonid Shevtsov - leonid-shevtsov)
|
35
|
-
|
36
|
-
* Like and Likes supported
|
37
|
-
|
38
|
-
* Escape querystring args
|
39
|
-
|
40
|
-
* General coding cleanup
|
41
|
-
|
42
|
-
* Added Languages, Skills, Publications, Patents and Phone Numbers (thanks Tadas Tamošauskas - medwezys)
|
43
|
-
|
44
|
-
* Extra fields added to profile (thanks Tadas Tamošauskas - medwezys)
|
45
|
-
|
46
|
-
* public\_profile\_field added to Profile (thanks troysteinbauer)
|
47
|
-
|
48
|
-
* Added recommendations (thanks Erol)
|
49
|
-
|
50
|
-
* Added current-share
|
51
|
-
|
52
|
-
* Added default\_profile\__fields config option
|
53
|
-
|
54
|
-
## 0.1.7 - February 5, 2010
|
55
|
-
|
56
|
-
* New group join status support JGRP from Terry Ray
|
57
|
-
|
58
|
-
## 0.1.6 - January 20, 2010
|
59
|
-
|
60
|
-
* Fixed bug with network status update connection collections - thanks Terry Ray
|
61
|
-
|
62
|
-
## 0.1.5 - January 13, 2010
|
63
|
-
|
64
|
-
* Added education and profile fields missing from updated LinkedIn docs
|
65
|
-
|
66
|
-
## 0.1.4 - January 13, 2010
|
67
|
-
|
68
|
-
* Applied patch for position end month/year from @holman
|
69
|
-
|
70
|
-
## 0.1.3 - December 24, 2009
|
71
|
-
|
72
|
-
* Added configure block for easier initialization of consumer token, secret
|
73
|
-
|
74
|
-
## 0.1.1 - December 8, 2009
|
75
|
-
|
76
|
-
* Applied patch from [nfo](http://github.com/nfo) to fix error handling
|
77
|
-
|
78
|
-
## 0.1.0 - November 25, 2009
|
79
|
-
|
80
|
-
* Network updates API support
|
81
|
-
|
82
|
-
* Search API support
|
83
|
-
|
84
|
-
* Updates API support
|
85
|
-
|
86
|
-
## 0.0.2 - November 25, 2009
|
87
|
-
|
88
|
-
* Swapped out Crack for ROXML for prettier object access
|
89
|
-
|
90
|
-
* Added more tests for Profile API
|
91
|
-
|
92
|
-
## 0.0.1 - November 24, 2009
|
93
|
-
|
94
|
-
* Initial release
|
data/examples/authenticate.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'linkedin'
|
3
|
-
|
4
|
-
# get your api keys at https://www.linkedin.com/secure/developer
|
5
|
-
client = LinkedIn::Client.new('your_client_id', 'your_client_secret')
|
6
|
-
|
7
|
-
# Get a url that you can enter into the browser to connect a user's
|
8
|
-
# account to your client_id and client_secret.
|
9
|
-
authorize_url = client.authorize_url
|
10
|
-
|
11
|
-
# Record the 'code' param (check the url bar) then use it to request the
|
12
|
-
# access_token.
|
13
|
-
access_token = client.request_access_token("<auth_code from last step>")
|
14
|
-
|
15
|
-
# Once you've initialized the access_token, you can call any api method
|
16
|
-
client.profile
|
data/examples/network.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
# AUTHENTICATE FIRST found in examples/authenticate.rb
|
2
|
-
|
3
|
-
# client is a LinkedIn::Client
|
4
|
-
|
5
|
-
# get network updates for the authenticated user
|
6
|
-
client.network_updates
|
7
|
-
|
8
|
-
# get profile picture changes
|
9
|
-
client.network_updates(:type => 'PICT')
|
10
|
-
|
11
|
-
# view connections for the currently authenticated user
|
12
|
-
client.connections
|
data/examples/profile.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
# AUTHENTICATE FIRST found in examples/authenticate.rb
|
2
|
-
|
3
|
-
# client is a LinkedIn::Client
|
4
|
-
|
5
|
-
# get the profile for the authenticated user
|
6
|
-
client.profile
|
7
|
-
|
8
|
-
# get a profile for someone found in network via ID
|
9
|
-
client.profile(:id => 'gNma67_AdI')
|
10
|
-
|
11
|
-
# get a profile for someone via their public profile url
|
12
|
-
client.profile(:url => 'http://www.linkedin.com/in/netherland')
|
13
|
-
|
14
|
-
# provides the ability to access authenticated user's company field in the profile
|
15
|
-
user = client.profile(:fields => %w(positions))
|
16
|
-
companies = user.positions.all.map{|t| t.company}
|
17
|
-
# Example: most recent company can be accessed via companies[0]
|
18
|
-
|
data/examples/sinatra.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
require "rubygems"
|
2
|
-
require "haml"
|
3
|
-
require "sinatra"
|
4
|
-
require "linkedin"
|
5
|
-
|
6
|
-
enable :sessions
|
7
|
-
|
8
|
-
helpers do
|
9
|
-
def login?
|
10
|
-
!session[:atoken].nil?
|
11
|
-
end
|
12
|
-
|
13
|
-
def profile
|
14
|
-
linkedin_client.profile unless session[:atoken].nil?
|
15
|
-
end
|
16
|
-
|
17
|
-
def connections
|
18
|
-
linkedin_client.connections unless session[:atoken].nil?
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
def linkedin_client
|
23
|
-
client = LinkedIn::Client.new(settings.api, settings.secret, session[:atoken])
|
24
|
-
client
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
configure do
|
30
|
-
# get your api keys at https://www.linkedin.com/secure/developer
|
31
|
-
set :api, "your_api_key"
|
32
|
-
set :secret, "your_secret"
|
33
|
-
end
|
34
|
-
|
35
|
-
get "/" do
|
36
|
-
haml :index
|
37
|
-
end
|
38
|
-
|
39
|
-
get "/auth" do
|
40
|
-
client = LinkedIn::Client.new(settings.api, settings.secret)
|
41
|
-
authorize_url = client.authorize_url(redirect_uri: "http://#{request.host}:#{request.port}/auth/callback")
|
42
|
-
redirect authorize_url
|
43
|
-
end
|
44
|
-
|
45
|
-
get "/auth/logout" do
|
46
|
-
session[:atoken] = nil
|
47
|
-
redirect "/"
|
48
|
-
end
|
49
|
-
|
50
|
-
get "/auth/callback" do
|
51
|
-
client = LinkedIn::Client.new(settings.api, settings.secret)
|
52
|
-
code = params[:code]
|
53
|
-
session[:atoken] = client.request_access_token(code, redirect_uri: "/")
|
54
|
-
redirect "/"
|
55
|
-
end
|
56
|
-
|
57
|
-
|
58
|
-
__END__
|
59
|
-
@@index
|
60
|
-
-if login?
|
61
|
-
%p Welcome #{profile.first_name}!
|
62
|
-
%a{:href => "/auth/logout"} Logout
|
63
|
-
%p= profile.headline
|
64
|
-
%br
|
65
|
-
%div= "You have #{connections.total} connections!"
|
66
|
-
-connections.all.each do |c|
|
67
|
-
%div= "#{c.first_name} #{c.last_name} - #{c.headline}"
|
68
|
-
-else
|
69
|
-
%a{:href => "/auth"} Login using LinkedIn
|
data/examples/status.rb
DELETED
@@ -1,123 +0,0 @@
|
|
1
|
-
module LinkedIn
|
2
|
-
module Api
|
3
|
-
|
4
|
-
module QueryMethods
|
5
|
-
|
6
|
-
def profile(options={})
|
7
|
-
path = person_path(options)
|
8
|
-
simple_query(path, options)
|
9
|
-
end
|
10
|
-
|
11
|
-
def connections(options={})
|
12
|
-
path = "#{person_path(options)}/connections"
|
13
|
-
simple_query(path, options)
|
14
|
-
end
|
15
|
-
|
16
|
-
def network_updates(options={})
|
17
|
-
path = "#{person_path(options)}/network/updates"
|
18
|
-
simple_query(path, options)
|
19
|
-
end
|
20
|
-
|
21
|
-
def company(options = {})
|
22
|
-
path = company_path(options)
|
23
|
-
simple_query(path, options)
|
24
|
-
end
|
25
|
-
|
26
|
-
def job(options = {})
|
27
|
-
path = jobs_path(options)
|
28
|
-
simple_query(path, options)
|
29
|
-
end
|
30
|
-
|
31
|
-
def job_bookmarks(options = {})
|
32
|
-
path = "#{person_path(options)}/job-bookmarks"
|
33
|
-
simple_query(path, options)
|
34
|
-
end
|
35
|
-
|
36
|
-
def job_suggestions(options = {})
|
37
|
-
path = "#{person_path(options)}/suggestions/job-suggestions"
|
38
|
-
simple_query(path, options)
|
39
|
-
end
|
40
|
-
|
41
|
-
def group_memberships(options = {})
|
42
|
-
path = "#{person_path(options)}/group-memberships"
|
43
|
-
simple_query(path, options)
|
44
|
-
end
|
45
|
-
|
46
|
-
def shares(options={})
|
47
|
-
path = "#{person_path(options)}/network/updates?type=SHAR&scope=self"
|
48
|
-
simple_query(path, options)
|
49
|
-
end
|
50
|
-
|
51
|
-
def share_comments(update_key, options={})
|
52
|
-
path = "#{person_path(options)}/network/updates/key=#{update_key}/update-comments"
|
53
|
-
simple_query(path, options)
|
54
|
-
end
|
55
|
-
|
56
|
-
def share_likes(update_key, options={})
|
57
|
-
path = "#{person_path(options)}/network/updates/key=#{update_key}/likes"
|
58
|
-
simple_query(path, options)
|
59
|
-
end
|
60
|
-
|
61
|
-
private
|
62
|
-
|
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
|
71
|
-
|
72
|
-
headers = options.delete(:headers) || {}
|
73
|
-
|
74
|
-
params = to_query(options)
|
75
|
-
path += "?#{params}" if !params.empty?
|
76
|
-
|
77
|
-
Mash.from_json(get(path, headers))
|
78
|
-
end
|
79
|
-
|
80
|
-
def person_path(options)
|
81
|
-
path = "/people"
|
82
|
-
if id = options.delete(:id)
|
83
|
-
if id.is_a? Array
|
84
|
-
path += "::(#{id.join(",")})"
|
85
|
-
else
|
86
|
-
path += "/id=#{id}"
|
87
|
-
end
|
88
|
-
elsif url = options.delete(:url)
|
89
|
-
path += "/url=#{CGI.escape(url)}"
|
90
|
-
else
|
91
|
-
path += "/~"
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def company_path(options)
|
96
|
-
path = "/companies"
|
97
|
-
|
98
|
-
if domain = options.delete(:domain)
|
99
|
-
path += "?email-domain=#{CGI.escape(domain)}"
|
100
|
-
elsif id = options.delete(:id)
|
101
|
-
path += "/id=#{id}"
|
102
|
-
elsif url = options.delete(:url)
|
103
|
-
path += "/url=#{CGI.escape(url)}"
|
104
|
-
elsif name = options.delete(:name)
|
105
|
-
path += "/universal-name=#{CGI.escape(name)}"
|
106
|
-
else
|
107
|
-
path += "/~"
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
def jobs_path(options)
|
112
|
-
path = "/jobs"
|
113
|
-
if id = options.delete(:id)
|
114
|
-
path += "/id=#{id}"
|
115
|
-
else
|
116
|
-
path += "/~"
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
end
|
121
|
-
|
122
|
-
end
|
123
|
-
end
|