linkedin 0.1.7 → 0.2.1

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.
Files changed (66) hide show
  1. data/.autotest +14 -0
  2. data/.document +5 -0
  3. data/.gitignore +25 -0
  4. data/Gemfile +3 -0
  5. data/README.markdown +12 -7
  6. data/Rakefile +10 -33
  7. data/VERSION +1 -1
  8. data/changelog.markdown +38 -0
  9. data/examples/authenticate.rb +1 -1
  10. data/lib/linked_in/api_standard_profile_request.rb +14 -6
  11. data/lib/linked_in/authorization_helpers.rb +48 -0
  12. data/lib/linked_in/base.rb +13 -0
  13. data/lib/linked_in/birthdate.rb +21 -0
  14. data/lib/linked_in/client.rb +86 -146
  15. data/lib/linked_in/company.rb +9 -7
  16. data/lib/linked_in/connections.rb +14 -5
  17. data/lib/linked_in/country.rb +7 -5
  18. data/lib/linked_in/current_share.rb +56 -0
  19. data/lib/linked_in/education.rb +40 -14
  20. data/lib/linked_in/error.rb +19 -8
  21. data/lib/linked_in/group.rb +30 -7
  22. data/lib/linked_in/languages.rb +28 -0
  23. data/lib/linked_in/likes.rb +23 -0
  24. data/lib/linked_in/location.rb +11 -6
  25. data/lib/linked_in/message.rb +20 -0
  26. data/lib/linked_in/network.rb +10 -5
  27. data/lib/linked_in/patents.rb +42 -0
  28. data/lib/linked_in/people.rb +16 -8
  29. data/lib/linked_in/person.rb +7 -0
  30. data/lib/linked_in/phone_number.rb +29 -0
  31. data/lib/linked_in/position.rb +45 -14
  32. data/lib/linked_in/profile.rb +81 -28
  33. data/lib/linked_in/publications.rb +40 -0
  34. data/lib/linked_in/recipient.rb +7 -0
  35. data/lib/linked_in/recipients.rb +18 -0
  36. data/lib/linked_in/recommendations.rb +30 -0
  37. data/lib/linked_in/request_helpers.rb +76 -0
  38. data/lib/linked_in/short_profile.rb +13 -0
  39. data/lib/linked_in/skill.rb +33 -0
  40. data/lib/linked_in/to_xml_helpers.rb +53 -0
  41. data/lib/linked_in/update.rb +21 -9
  42. data/lib/linked_in/url_resource.rb +24 -6
  43. data/lib/linkedin.rb +58 -59
  44. data/linkedin.gemspec +52 -0
  45. data/spec/cases/client_spec.rb +281 -0
  46. data/spec/cases/linkedin_spec.rb +37 -0
  47. data/spec/cases/oauth_spec.rb +109 -0
  48. data/{test → spec}/fixtures/blank.xml +0 -0
  49. data/{test → spec}/fixtures/connections.xml +0 -0
  50. data/{test → spec}/fixtures/error.xml +0 -0
  51. data/spec/fixtures/likes.xml +18 -0
  52. data/spec/fixtures/mailbox_items.xml +16 -0
  53. data/{test → spec}/fixtures/network_status_with_group.xml +3 -3
  54. data/{test → spec}/fixtures/network_statuses.xml +18 -0
  55. data/{test → spec}/fixtures/picture_updates.xml +0 -0
  56. data/{test → spec}/fixtures/profile.xml +0 -0
  57. data/{test → spec}/fixtures/profile_full.xml +57 -0
  58. data/{test → spec}/fixtures/profile_with_positions.xml +0 -0
  59. data/{test → spec}/fixtures/search.xml +2 -2
  60. data/spec/fixtures/shares.xml +12 -0
  61. data/{test → spec}/fixtures/status.xml +0 -0
  62. data/spec/spec_helper.rb +49 -0
  63. metadata +160 -76
  64. data/test/client_test.rb +0 -124
  65. data/test/oauth_test.rb +0 -117
  66. data/test/test_helper.rb +0 -51
@@ -1,124 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ClientTest < Test::Unit::TestCase
4
- context "when hitting the LinkedIn API" do
5
- setup do
6
- @linkedin = LinkedIn::Client.new('token', 'secret')
7
- consumer = OAuth::Consumer.new('token', 'secret', {:site => 'https://api.linkedin.com'})
8
- @linkedin.stubs(:consumer).returns(consumer)
9
-
10
- @linkedin.authorize_from_access('atoken', 'asecret')
11
- end
12
-
13
- should "retrieve a profile for the authenticated user" do
14
- stub_get("/v1/people/~", "profile_full.xml")
15
- p = @linkedin.profile
16
- p.first_name.should == 'Wynn'
17
- p.last_name.should == 'Netherland'
18
- p.positions.size.should == 4
19
- p.positions.first.company.name.should == 'Orrka'
20
-
21
- hp = p.positions[2]
22
- hp.start_month.should == 10
23
- hp.start_year.should == 2004
24
- hp.end_month.should == 6
25
- hp.end_year.should == 2007
26
-
27
- education = p.education.first
28
- education.start_month.should == 8
29
- education.start_year.should == 1994
30
- education.end_month.should == 5
31
- education.end_year.should == 1998
32
-
33
- p.connections.size.should == 146
34
- p.connections.first.first_name.should == "Ali"
35
- end
36
-
37
- should "retrieve a profile for a member by id" do
38
- stub_get("/v1/people/id=gNma67_AdI", "profile.xml")
39
- p = @linkedin.profile(:id => "gNma67_AdI")
40
- p.first_name.should == 'Wynn'
41
- end
42
-
43
- should "retrieve a profile for a member by url" do
44
- stub_get("/v1/people/url=http%3A%2F%2Fwww.linkedin.com%2Fin%2Fnetherland", "profile.xml")
45
- p = @linkedin.profile(:url => "http://www.linkedin.com/in/netherland")
46
- p.last_name.should == 'Netherland'
47
- end
48
-
49
- should "accept field selectors when retrieving a profile" do
50
- stub_get("/v1/people/~:(first-name,last-name)", "profile.xml")
51
- p = @linkedin.profile(:fields => [:first_name, :last_name])
52
- p.first_name.should == 'Wynn'
53
- p.last_name.should == 'Netherland'
54
- end
55
-
56
- should "retrieve connections for the authenticated user" do
57
- stub_get("/v1/people/~/connections", "connections.xml")
58
- cons = @linkedin.connections
59
- cons.size.should == 146
60
- cons.last.last_name.should == 'Yuchnewicz'
61
- end
62
-
63
- should "perform a search by keyword" do
64
- stub_get("/v1/people?keywords=github", "search.xml")
65
- results = @linkedin.search(:keywords => 'github')
66
- results.start == 0
67
- results.count == 10
68
- results.profiles.first.first_name.should == 'Zach'
69
- results.profiles.first.last_name.should == 'Inglis'
70
- end
71
-
72
- should "perform a search by multiple keywords" do
73
- stub_get("/v1/people?keywords=ruby+rails", "search.xml")
74
- results = @linkedin.search(:keywords => ["ruby", "rails"])
75
- results.start == 0
76
- results.count == 10
77
- results.profiles.first.first_name.should == 'Zach'
78
- results.profiles.first.last_name.should == 'Inglis'
79
- end
80
-
81
- should "perform a search by name" do
82
- stub_get("/v1/people?name=Zach+Inglis", "search.xml")
83
- results = @linkedin.search(:name => "Zach Inglis")
84
- results.start == 0
85
- results.count == 10
86
- results.profiles.first.first_name.should == 'Zach'
87
- results.profiles.first.last_name.should == 'Inglis'
88
- end
89
-
90
- should "update a user's current status" do
91
- stub_put("/v1/people/~/current-status", "blank.xml")
92
- @linkedin.update_status("Testing out the LinkedIn API")
93
- end
94
-
95
- should "clear a user's current status" do
96
- stub_delete("/v1/people/~/current-status", "blank.xml")
97
- @linkedin.clear_status
98
- end
99
-
100
- should "retrieve the authenticated user's current status" do
101
- stub_get("/v1/people/~/current-status", "status.xml")
102
- @linkedin.current_status.should == "New blog post: What makes a good API wrapper? http://wynnnetherland.com/2009/11/what-makes-a-good-api-wrapper/"
103
- end
104
-
105
- should "retrieve status updates for the authenticated user's network" do
106
- stub_get("/v1/people/~/network?type=STAT", "network_statuses.xml")
107
- stats = @linkedin.network_statuses
108
- stats.updates.first.profile.id.should == "19408512"
109
- stats.updates.first.profile.first_name.should == 'Vahid'
110
- stats.updates.first.profile.connections.first.id.should == "28072758"
111
- stats.updates.first.profile.connections.first.last_name.should == 'Varone'
112
-
113
- end
114
-
115
- should "retrieve network updates" do
116
- stub_get("/v1/people/~/network?type=PICT", "picture_updates.xml")
117
- stats = @linkedin.network_updates(:type => "PICT")
118
- stats.updates.size.should == 4
119
- stats.updates.last.profile.headline.should == "Creative Director for Intridea"
120
- end
121
-
122
- end
123
-
124
- end
@@ -1,117 +0,0 @@
1
- require 'test_helper'
2
-
3
- class OAuthTest < Test::Unit::TestCase
4
- should "initialize with consumer token and secret" do
5
- linkedin = LinkedIn::Client.new('token', 'secret')
6
-
7
- linkedin.ctoken.should == 'token'
8
- linkedin.csecret.should == 'secret'
9
- end
10
-
11
- should "set authorization path to '/uas/oauth/authorize' by default" do
12
- linkedin = LinkedIn::Client.new('token', 'secret')
13
- linkedin.consumer.options[:authorize_path].should == '/uas/oauth/authorize'
14
- end
15
-
16
- should "have a consumer" do
17
- consumer = mock('oauth consumer')
18
- options = {
19
- :request_token_path => "/uas/oauth/requestToken",
20
- :access_token_path => "/uas/oauth/accessToken",
21
- :authorize_path => "/uas/oauth/authorize",
22
- :site => 'https://api.linkedin.com'
23
- }
24
- OAuth::Consumer.expects(:new).with('token', 'secret', options).returns(consumer)
25
- linkedin = LinkedIn::Client.new('token', 'secret')
26
-
27
- linkedin.consumer.should == consumer
28
- end
29
-
30
- should "have a request token from the consumer" do
31
- options = {
32
- :request_token_path => "/uas/oauth/requestToken",
33
- :access_token_path => "/uas/oauth/accessToken",
34
- :authorize_path => "/uas/oauth/authorize",
35
- :site => 'https://api.linkedin.com'
36
- }
37
- consumer = mock('oauth consumer')
38
- request_token = mock('request token')
39
- consumer.expects(:get_request_token).returns(request_token)
40
- OAuth::Consumer.expects(:new).with('token', 'secret', options).returns(consumer)
41
- linkedin = LinkedIn::Client.new('token', 'secret')
42
-
43
- linkedin.request_token.should == request_token
44
- end
45
-
46
- context "set_callback_url" do
47
- should "clear request token and set the callback url" do
48
- consumer = mock('oauth consumer')
49
- request_token = mock('request token')
50
- options = {
51
- :request_token_path => "/uas/oauth/requestToken",
52
- :access_token_path => "/uas/oauth/accessToken",
53
- :authorize_path => "/uas/oauth/authorize",
54
- :site => 'https://api.linkedin.com'
55
- }
56
- OAuth::Consumer.
57
- expects(:new).
58
- with('token', 'secret', options).
59
- returns(consumer)
60
-
61
- linkedin = LinkedIn::Client.new('token', 'secret')
62
-
63
- consumer.
64
- expects(:get_request_token).
65
- with({:oauth_callback => 'http://myapp.com/oauth_callback'})
66
-
67
- linkedin.set_callback_url('http://myapp.com/oauth_callback')
68
- end
69
- end
70
-
71
- should "be able to create access token from request token, request secret and verifier" do
72
- linkedin = LinkedIn::Client.new('token', 'secret')
73
- consumer = OAuth::Consumer.new('token', 'secret', {:site => 'https://api.linkedin.com'})
74
- linkedin.stubs(:consumer).returns(consumer)
75
-
76
- access_token = mock('access token', :token => 'atoken', :secret => 'asecret')
77
- request_token = mock('request token')
78
- request_token.
79
- expects(:get_access_token).
80
- with(:oauth_verifier => 'verifier').
81
- returns(access_token)
82
-
83
- OAuth::RequestToken.
84
- expects(:new).
85
- with(consumer, 'rtoken', 'rsecret').
86
- returns(request_token)
87
-
88
- linkedin.authorize_from_request('rtoken', 'rsecret', 'verifier')
89
- linkedin.access_token.class.should be(OAuth::AccessToken)
90
- linkedin.access_token.token.should == 'atoken'
91
- linkedin.access_token.secret.should == 'asecret'
92
- end
93
-
94
- should "be able to create access token from access token and secret" do
95
- linkedin = LinkedIn::Client.new('token', 'secret')
96
- consumer = OAuth::Consumer.new('token', 'secret', {:site => 'https://api.linkedin.com'})
97
- linkedin.stubs(:consumer).returns(consumer)
98
-
99
- linkedin.authorize_from_access('atoken', 'asecret')
100
- linkedin.access_token.class.should be(OAuth::AccessToken)
101
- linkedin.access_token.token.should == 'atoken'
102
- linkedin.access_token.secret.should == 'asecret'
103
- end
104
-
105
- should "be able to configure consumer token and consumer secret without passing to initialize" do
106
- LinkedIn.configure do |config|
107
- config.token = 'consumer_token'
108
- config.secret = 'consumer_secret'
109
- end
110
-
111
- linkedin = LinkedIn::Client.new
112
- linkedin.ctoken.should == 'consumer_token'
113
- linkedin.csecret.should == 'consumer_secret'
114
- end
115
-
116
-
117
- end
@@ -1,51 +0,0 @@
1
- require 'test/unit'
2
- require 'pathname'
3
- require 'rubygems'
4
-
5
- gem 'thoughtbot-shoulda', '>= 2.10.1'
6
- gem 'jnunemaker-matchy', '0.4.0'
7
- gem 'mocha', '0.9.4'
8
- gem 'fakeweb', '>= 1.2.5'
9
-
10
- require 'shoulda'
11
- require 'matchy'
12
- require 'mocha'
13
- require 'fakeweb'
14
-
15
- FakeWeb.allow_net_connect = false
16
-
17
- dir = (Pathname(__FILE__).dirname + '../lib').expand_path
18
- require dir + 'linkedin'
19
-
20
- class Test::Unit::TestCase
21
- end
22
-
23
- def fixture_file(filename)
24
- return '' if filename == ''
25
- file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
26
- File.read(file_path)
27
- end
28
-
29
- def linkedin_url(url)
30
- url =~ /^http/ ? url : "https://api.linkedin.com#{url}"
31
- end
32
-
33
- def stub_get(url, filename, status=nil)
34
- options = {:body => fixture_file(filename)}
35
- options.merge!({:status => status}) unless status.nil?
36
-
37
- FakeWeb.register_uri(:get, linkedin_url(url), options)
38
- end
39
-
40
- def stub_post(url, filename)
41
- FakeWeb.register_uri(:post, linkedin_url(url), :body => fixture_file(filename))
42
- end
43
-
44
- def stub_put(url, filename)
45
- FakeWeb.register_uri(:put, linkedin_url(url), :body => fixture_file(filename))
46
- end
47
-
48
- def stub_delete(url, filename)
49
- FakeWeb.register_uri(:delete, linkedin_url(url), :body => fixture_file(filename))
50
-
51
- end