linkedin-api2 1.1.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/.autotest +14 -0
  3. data/.gemtest +0 -0
  4. data/.gitignore +42 -0
  5. data/.rspec +1 -0
  6. data/.travis.yml +6 -0
  7. data/.yardopts +7 -0
  8. data/CHANGELOG.md +99 -0
  9. data/EXAMPLES.md +202 -0
  10. data/Gemfile +11 -0
  11. data/LICENSE +22 -0
  12. data/README.md +43 -0
  13. data/Rakefile +15 -0
  14. data/lib/linked_in/api.rb +38 -0
  15. data/lib/linked_in/api/communications.rb +44 -0
  16. data/lib/linked_in/api/companies.rb +129 -0
  17. data/lib/linked_in/api/groups.rb +115 -0
  18. data/lib/linked_in/api/jobs.rb +64 -0
  19. data/lib/linked_in/api/people.rb +73 -0
  20. data/lib/linked_in/api/query_helpers.rb +86 -0
  21. data/lib/linked_in/api/share_and_social_stream.rb +137 -0
  22. data/lib/linked_in/client.rb +51 -0
  23. data/lib/linked_in/errors.rb +29 -0
  24. data/lib/linked_in/helpers.rb +6 -0
  25. data/lib/linked_in/helpers/authorization.rb +69 -0
  26. data/lib/linked_in/helpers/request.rb +85 -0
  27. data/lib/linked_in/mash.rb +95 -0
  28. data/lib/linked_in/search.rb +71 -0
  29. data/lib/linked_in/version.rb +11 -0
  30. data/lib/linkedin.rb +35 -0
  31. data/linkedin-api2.gemspec +27 -0
  32. data/spec/cases/api_spec.rb +308 -0
  33. data/spec/cases/linkedin_spec.rb +37 -0
  34. data/spec/cases/mash_spec.rb +113 -0
  35. data/spec/cases/oauth_spec.rb +178 -0
  36. data/spec/cases/search_spec.rb +234 -0
  37. data/spec/fixtures/cassette_library/LinkedIn_Api/Company_API.yml +81 -0
  38. data/spec/fixtures/cassette_library/LinkedIn_Api/Company_API/should_load_correct_company_data.yml +81 -0
  39. data/spec/fixtures/cassette_library/LinkedIn_Client/_authorize_from_request/should_return_a_valid_access_token.yml +37 -0
  40. data/spec/fixtures/cassette_library/LinkedIn_Client/_request_token/with_a_callback_url/should_return_a_valid_access_token.yml +37 -0
  41. data/spec/fixtures/cassette_library/LinkedIn_Client/_request_token/with_default_options/should_return_a_valid_request_token.yml +37 -0
  42. data/spec/fixtures/cassette_library/LinkedIn_Search/_search/by_company_name_option/should_perform_a_search.yml +92 -0
  43. data/spec/fixtures/cassette_library/LinkedIn_Search/_search/by_email_address/should_perform_a_people_search.yml +57 -0
  44. data/spec/fixtures/cassette_library/LinkedIn_Search/_search/by_first_name_and_last_name_options/should_perform_a_search.yml +100 -0
  45. data/spec/fixtures/cassette_library/LinkedIn_Search/_search/by_first_name_and_last_name_options_with_fields/should_perform_a_search.yml +114 -0
  46. data/spec/fixtures/cassette_library/LinkedIn_Search/_search/by_keywords_string_parameter/should_perform_a_search.yml +52 -0
  47. data/spec/fixtures/cassette_library/LinkedIn_Search/_search/by_multiple_email_address/should_perform_a_multi-email_search.yml +59 -0
  48. data/spec/fixtures/cassette_library/LinkedIn_Search/_search/by_single_keywords_option/should_perform_a_search.yml +52 -0
  49. data/spec/fixtures/cassette_library/LinkedIn_Search/_search/by_single_keywords_option_with_pagination/should_perform_a_search.yml +43 -0
  50. data/spec/fixtures/cassette_library/LinkedIn_Search/_search/email_search_returns_unauthorized/should_raise_an_unauthorized_error.yml +59 -0
  51. data/spec/fixtures/cassette_library/LinkedIn_Search/_search_company/by_keywords_options_with_fields/should_perform_a_search.yml +43 -0
  52. data/spec/fixtures/cassette_library/LinkedIn_Search/_search_company/by_keywords_string_parameter/should_perform_a_company_search.yml +80 -0
  53. data/spec/fixtures/cassette_library/LinkedIn_Search/_search_company/by_single_keywords_option/should_perform_a_company_search.yml +80 -0
  54. data/spec/fixtures/cassette_library/LinkedIn_Search/_search_company/by_single_keywords_option_with_facets_to_return/should_return_a_facet.yml +80 -0
  55. data/spec/fixtures/cassette_library/LinkedIn_Search/_search_company/by_single_keywords_option_with_pagination/should_perform_a_search.yml +74 -0
  56. data/spec/helper.rb +34 -0
  57. metadata +268 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f9f4ecb56436648bda96bcdf4725e074be794791
4
+ data.tar.gz: ecd89a55479a5cc2bbad17c9a5280e31fc1a23b5
5
+ SHA512:
6
+ metadata.gz: 7d8e8696ebc4f5b87935e5829650a59c479d4ac3c3c66e21beb3b6a10fae612c23ec71cb3944e658fa2fba19e55456fe3ab9db654fad6f1c992e161ed202d14c
7
+ data.tar.gz: e8298eef910818b2afa4df29fb7dc18c8daf8b222d1901bcf9173b4df038c54066372cabc55070b2ace06fc26d14f151132496a8e40c2a15d437961df805d281
data/.autotest ADDED
@@ -0,0 +1,14 @@
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/.gemtest ADDED
File without changes
data/.gitignore ADDED
@@ -0,0 +1,42 @@
1
+ *.gem
2
+ *.rbc
3
+ *.sw[a-p]
4
+ *.tmproj
5
+ *.tmproject
6
+ *.un~
7
+ *~
8
+ .DS_Store
9
+ .Spotlight-V100
10
+ .Trashes
11
+ ._*
12
+ .bundle
13
+ .config
14
+ .directory
15
+ .elc
16
+ .redcar
17
+ .yardoc
18
+ .rvmrc
19
+ /.emacs.desktop
20
+ /.emacs.desktop.lock
21
+ Desktop.ini
22
+ Gemfile.lock
23
+ Icon?
24
+ InstalledFiles
25
+ Session.vim
26
+ Thumbs.db
27
+ \#*\#
28
+ _yardoc
29
+ auto-save-list
30
+ coverage
31
+ doc/
32
+ lib/bundler/man
33
+ pkg
34
+ pkg/*
35
+ rdoc
36
+ spec/reports
37
+ test/tmp
38
+ test/version_tmp
39
+ tmp
40
+ tmtags
41
+ tramp
42
+ /.idea
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ rvm:
2
+ - 2.0.0
3
+ - 2.1.0
4
+ - 1.9.3
5
+ - jruby-19mode
6
+ - rbx
data/.yardopts ADDED
@@ -0,0 +1,7 @@
1
+ --no-private
2
+ --markup markdown
3
+ -
4
+ README.md
5
+ CHANGELOG.md
6
+ LICENSE
7
+ EXAMPLES.md
data/CHANGELOG.md ADDED
@@ -0,0 +1,99 @@
1
+ # Changelog
2
+
3
+ * Document all methods
4
+ * Re-organize modules under Api to match organization in LinkedIn's REST
5
+ API documentation
6
+
7
+ ## 0.4.4 - Jan 11, 2014
8
+
9
+ * Group share add
10
+ * Readme updates
11
+
12
+ ## 0.4.3
13
+
14
+ ## 0.4.2
15
+
16
+ ## 0.4.1
17
+
18
+ ## 0.4.0 - May 30, 2013
19
+
20
+ * Add capability to ask for desired permissions from linked in api
21
+ * Add option to specify a proxy
22
+ * Bump hashie version
23
+ * fix the permission param passing
24
+ * fix to be able to pass the permission scope
25
+ * Manipulating comments/likes for network_updates ('shares')
26
+ * Methods to work with comments/likes for share
27
+ * Added a method to get a user's shares
28
+ * Added current user's shares as an option (client.shares)
29
+ * Readme Typos
30
+
31
+ ## 0.2.x - March x, 2010
32
+
33
+ * Removed Crack as a dependency, Nokogiri FTW
34
+
35
+ ## 0.2.1 - March 1, 2010
36
+
37
+ * Big dependency clean up, only OAuth and Nokogiri are really needed.
38
+
39
+ * Use Nokogiri for xml generation (thanks Leonid Shevtsov - leonid-shevtsov)
40
+
41
+ * Like and Likes supported
42
+
43
+ * Escape querystring args
44
+
45
+ * General coding cleanup
46
+
47
+ * Added Languages, Skills, Publications, Patents and Phone Numbers (thanks Tadas Tamošauskas - medwezys)
48
+
49
+ * Extra fields added to profile (thanks Tadas Tamošauskas - medwezys)
50
+
51
+ * public\_profile\_field added to Profile (thanks troysteinbauer)
52
+
53
+ * Added recommendations (thanks Erol)
54
+
55
+ * Added current-share
56
+
57
+ * Added default\_profile\__fields config option
58
+
59
+ ## 0.1.7 - February 5, 2010
60
+
61
+ * New group join status support JGRP from Terry Ray
62
+
63
+ ## 0.1.6 - January 20, 2010
64
+
65
+ * Fixed bug with network status update connection collections - thanks Terry Ray
66
+
67
+ ## 0.1.5 - January 13, 2010
68
+
69
+ * Added education and profile fields missing from updated LinkedIn docs
70
+
71
+ ## 0.1.4 - January 13, 2010
72
+
73
+ * Applied patch for position end month/year from @holman
74
+
75
+ ## 0.1.3 - December 24, 2009
76
+
77
+ * Added configure block for easier initialization of consumer token, secret
78
+
79
+ ## 0.1.1 - December 8, 2009
80
+
81
+ * Applied patch from [nfo](http://github.com/nfo) to fix error handling
82
+
83
+ ## 0.1.0 - November 25, 2009
84
+
85
+ * Network updates API support
86
+
87
+ * Search API support
88
+
89
+ * Updates API support
90
+
91
+ ## 0.0.2 - November 25, 2009
92
+
93
+ * Swapped out Crack for ROXML for prettier object access
94
+
95
+ * Added more tests for Profile API
96
+
97
+ ## 0.0.1 - November 24, 2009
98
+
99
+ * Initial release
data/EXAMPLES.md ADDED
@@ -0,0 +1,202 @@
1
+ # Linkedin Gem Examples
2
+
3
+ ## OAuth 1.0a Authentication
4
+
5
+ Here's an example of authenticating with the LinkedIn API
6
+
7
+ ```ruby
8
+ require 'rubygems'
9
+ require 'linkedin'
10
+
11
+ # get your api keys at https://www.linkedin.com/secure/developer
12
+ client = LinkedIn::Client.new('your_consumer_key', 'your_consumer_secret')
13
+
14
+ # If you want to use one of the scopes from linkedin you have to pass it in at this point
15
+ # You can learn more about it here: http://developer.linkedin.com/documents/authentication
16
+ request_token = client.request_token({}, :scope => "r_basicprofile r_emailaddress")
17
+
18
+ rtoken = request_token.token
19
+ rsecret = request_token.secret
20
+
21
+ # to test from your desktop, open the following url in your browser
22
+ # and record the pin it gives you
23
+ request_token.authorize_url
24
+ => "https://api.linkedin.com/uas/oauth/authorize?oauth_token=<generated_token>"
25
+
26
+ # then fetch your access keys
27
+ client.authorize_from_request(rtoken, rsecret, pin)
28
+ => ["OU812", "8675309"] # <= save these for future requests
29
+
30
+ # or authorize from previously fetched access keys
31
+ client.authorize_from_access("OU812", "8675309")
32
+
33
+ # you're now free to move about the cabin, call any API method
34
+ ```
35
+
36
+
37
+ ## Profile
38
+
39
+ Here are some examples of accessing a user's profile
40
+
41
+ ```ruby
42
+ # AUTHENTICATE FIRST found in examples/authenticate.rb
43
+
44
+ # client is a LinkedIn::Client
45
+
46
+ # get the profile for the authenticated user
47
+ client.profile
48
+
49
+ # get a profile for someone found in network via ID
50
+ client.profile(:id => 'gNma67_AdI')
51
+
52
+ # get a profile for someone via their public profile url
53
+ client.profile(:url => 'http://www.linkedin.com/in/netherland')
54
+
55
+ # provides the ability to access authenticated user's company field in the profile
56
+ user = client.profile(:fields => %w(positions))
57
+ companies = user.positions.all.map{|t| t.company}
58
+ # Example: most recent company can be accessed via companies[0]
59
+
60
+ # Example of a multi-email search against the special email search API
61
+ account_exists = client.profile(:email => 'email=yy@zz.com,email=xx@yy.com', :fields => ['id'])
62
+ ```
63
+
64
+
65
+ ## Sending a Message
66
+
67
+ Here's an example of sending a message to two recipients
68
+
69
+ ```ruby
70
+ # AUTHENTICATE FIRST found in examples/authenticate.md
71
+
72
+ # client is a LinkedIn::Client
73
+
74
+ # send a message to a person in your network. you will need to authenticate the
75
+ # user and ask for the "w_messages" permission.
76
+ response = client.send_message("subject", "body", ["person_1_id", "person_2_id"])
77
+ ```
78
+
79
+
80
+ ## User's Network
81
+
82
+ Here are some examples of accessing network updates and connections of
83
+ the authenticated user
84
+
85
+ ``` ruby
86
+ # AUTHENTICATE FIRST found in examples/authenticate.rb
87
+
88
+ # client is a LinkedIn::Client
89
+
90
+ # get network updates for the authenticated user
91
+ client.network_updates
92
+
93
+ # get profile picture changes
94
+ client.network_updates(:type => 'PICT')
95
+
96
+ # view connections for the currently authenticated user
97
+ client.connections
98
+
99
+ # get the original picture-url for one of the connections
100
+ client.picture_urls(:id => 'id_of_connection')
101
+
102
+ # get the image over https instead of http
103
+ client.picture_urls(:id => 'id_of_connection', :secure => "true")
104
+ ```
105
+ ## Update User's Status
106
+
107
+ Here's an example of updating the current user's status
108
+
109
+ ```ruby
110
+ # AUTHENTICATE FIRST found in examples/authenticate.rb
111
+
112
+ # client is a LinkedIn::Client
113
+
114
+ # update status for the authenticated user
115
+ client.add_share(:comment => 'is playing with the LinkedIn Ruby gem')
116
+ ```
117
+
118
+
119
+ ## Sinatra App
120
+
121
+ Here's an example sinatra application that performs authentication,
122
+ after which some info about the authenticated user can be retrieved.
123
+
124
+ ```ruby
125
+ require "rubygems"
126
+ require "haml"
127
+ require "sinatra"
128
+ require "linkedin"
129
+
130
+ enable :sessions
131
+
132
+ helpers do
133
+ def login?
134
+ !session[:atoken].nil?
135
+ end
136
+
137
+ def profile
138
+ linkedin_client.profile unless session[:atoken].nil?
139
+ end
140
+
141
+ def connections
142
+ linkedin_client.connections unless session[:atoken].nil?
143
+ end
144
+
145
+ private
146
+ def linkedin_client
147
+ client = LinkedIn::Client.new(settings.api, settings.secret)
148
+ client.authorize_from_access(session[:atoken], session[:asecret])
149
+ client
150
+ end
151
+
152
+ end
153
+
154
+ configure do
155
+ # get your api keys at https://www.linkedin.com/secure/developer
156
+ set :api, "your_api_key"
157
+ set :secret, "your_secret"
158
+ end
159
+
160
+ get "/" do
161
+ haml :index
162
+ end
163
+
164
+ get "/auth" do
165
+ client = LinkedIn::Client.new(settings.api, settings.secret)
166
+ request_token = client.request_token(:oauth_callback => "http://#{request.host}:#{request.port}/auth/callback")
167
+ session[:rtoken] = request_token.token
168
+ session[:rsecret] = request_token.secret
169
+
170
+ redirect client.request_token.authorize_url
171
+ end
172
+
173
+ get "/auth/logout" do
174
+ session[:atoken] = nil
175
+ redirect "/"
176
+ end
177
+
178
+ get "/auth/callback" do
179
+ client = LinkedIn::Client.new(settings.api, settings.secret)
180
+ if session[:atoken].nil?
181
+ pin = params[:oauth_verifier]
182
+ atoken, asecret = client.authorize_from_request(session[:rtoken], session[:rsecret], pin)
183
+ session[:atoken] = atoken
184
+ session[:asecret] = asecret
185
+ end
186
+ redirect "/"
187
+ end
188
+
189
+
190
+ __END__
191
+ @@index
192
+ -if login?
193
+ %p Welcome #{profile.first_name}!
194
+ %a{:href => "/auth/logout"} Logout
195
+ %p= profile.headline
196
+ %br
197
+ %div= "You have #{connections.total} connections!"
198
+ -connections.all.each do |c|
199
+ %div= "#{c.first_name} #{c.last_name} - #{c.headline}"
200
+ -else
201
+ %a{:href => "/auth"} Login using LinkedIn
202
+ ```
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'http://rubygems.org'
2
+
3
+ platforms :jruby do
4
+ gem 'jruby-openssl', '~> 0.7'
5
+ end
6
+
7
+ platforms :rbx do
8
+ gem 'rubysl'
9
+ end
10
+
11
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2009 Wynn Netherland & Matthew Kirk
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # LinkedIn
2
+
3
+ Ruby wrapper for the [LinkedIn API](http://developer.linkedin.com). The LinkedIn gem provides an easy-to-use wrapper for LinkedIn's REST APIs.
4
+
5
+ Travis CI : [![Build Status](https://secure.travis-ci.org/hexgnu/linkedin.png)](http://travis-ci.org/hexgnu/linkedin)
6
+
7
+ ## Installation
8
+
9
+ gem install linkedin
10
+
11
+ ## Documentation
12
+
13
+ [http://rdoc.info/gems/linkedin](http://rdoc.info/gems/linkedin)
14
+
15
+ ## Usage
16
+
17
+ [View the Examples](EXAMPLES.md)
18
+
19
+ ## Changelog
20
+
21
+ [View the Changelog](CHANGELOG.md)
22
+
23
+ ## TODO
24
+
25
+ * Update and correct test suite
26
+ * Change to Faraday for authentication
27
+ * Implement Messaging APIs
28
+
29
+ ## Note on Patches/Pull Requests
30
+
31
+ * Fork the project.
32
+ * Make your feature addition or bug fix.
33
+ * Add tests for it. This is important so I don't break it in a
34
+ future version unintentionally.
35
+ * Make sure your test doesn't just check of instance of LinkedIn::Mash :smile:.
36
+ * Commit, do not mess with rakefile, version, or history.
37
+ (if you want to have your own version, that is fine but
38
+ bump version in a commit by itself I can ignore when I pull)
39
+ * Send me a pull request. Bonus points for topic branches.
40
+
41
+ ## Copyright
42
+
43
+ Copyright (c) 2013-Present [Matt Kirk](http://matthewkirk.com) 2009-11 [Wynn Netherland](http://wynnnetherland.com). See LICENSE for details.