linkedin 0.1.7 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +14 -0
- data/.document +5 -0
- data/.gitignore +25 -0
- data/Gemfile +3 -0
- data/README.markdown +12 -7
- data/Rakefile +10 -33
- data/VERSION +1 -1
- data/changelog.markdown +38 -0
- data/examples/authenticate.rb +1 -1
- data/lib/linked_in/api_standard_profile_request.rb +14 -6
- data/lib/linked_in/authorization_helpers.rb +48 -0
- data/lib/linked_in/base.rb +13 -0
- data/lib/linked_in/birthdate.rb +21 -0
- data/lib/linked_in/client.rb +86 -146
- data/lib/linked_in/company.rb +9 -7
- data/lib/linked_in/connections.rb +14 -5
- data/lib/linked_in/country.rb +7 -5
- data/lib/linked_in/current_share.rb +56 -0
- data/lib/linked_in/education.rb +40 -14
- data/lib/linked_in/error.rb +19 -8
- data/lib/linked_in/group.rb +30 -7
- data/lib/linked_in/languages.rb +28 -0
- data/lib/linked_in/likes.rb +23 -0
- data/lib/linked_in/location.rb +11 -6
- data/lib/linked_in/message.rb +20 -0
- data/lib/linked_in/network.rb +10 -5
- data/lib/linked_in/patents.rb +42 -0
- data/lib/linked_in/people.rb +16 -8
- data/lib/linked_in/person.rb +7 -0
- data/lib/linked_in/phone_number.rb +29 -0
- data/lib/linked_in/position.rb +45 -14
- data/lib/linked_in/profile.rb +81 -28
- data/lib/linked_in/publications.rb +40 -0
- data/lib/linked_in/recipient.rb +7 -0
- data/lib/linked_in/recipients.rb +18 -0
- data/lib/linked_in/recommendations.rb +30 -0
- data/lib/linked_in/request_helpers.rb +76 -0
- data/lib/linked_in/short_profile.rb +13 -0
- data/lib/linked_in/skill.rb +33 -0
- data/lib/linked_in/to_xml_helpers.rb +53 -0
- data/lib/linked_in/update.rb +21 -9
- data/lib/linked_in/url_resource.rb +24 -6
- data/lib/linkedin.rb +58 -59
- data/linkedin.gemspec +52 -0
- data/spec/cases/client_spec.rb +281 -0
- data/spec/cases/linkedin_spec.rb +37 -0
- data/spec/cases/oauth_spec.rb +109 -0
- data/{test → spec}/fixtures/blank.xml +0 -0
- data/{test → spec}/fixtures/connections.xml +0 -0
- data/{test → spec}/fixtures/error.xml +0 -0
- data/spec/fixtures/likes.xml +18 -0
- data/spec/fixtures/mailbox_items.xml +16 -0
- data/{test → spec}/fixtures/network_status_with_group.xml +3 -3
- data/{test → spec}/fixtures/network_statuses.xml +18 -0
- data/{test → spec}/fixtures/picture_updates.xml +0 -0
- data/{test → spec}/fixtures/profile.xml +0 -0
- data/{test → spec}/fixtures/profile_full.xml +57 -0
- data/{test → spec}/fixtures/profile_with_positions.xml +0 -0
- data/{test → spec}/fixtures/search.xml +2 -2
- data/spec/fixtures/shares.xml +12 -0
- data/{test → spec}/fixtures/status.xml +0 -0
- data/spec/spec_helper.rb +49 -0
- metadata +160 -76
- data/test/client_test.rb +0 -124
- data/test/oauth_test.rb +0 -117
- data/test/test_helper.rb +0 -51
data/lib/linked_in/update.rb
CHANGED
@@ -1,11 +1,23 @@
|
|
1
1
|
module LinkedIn
|
2
|
-
class Update
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
2
|
+
class Update < LinkedIn::Base
|
3
|
+
|
4
|
+
%w[update_key update_type is_commentable?].each do |f|
|
5
|
+
define_method(f.to_sym) do
|
6
|
+
@doc.xpath("./update/#{f.gsub(/_/,'-').gsub(/\?$/,"")}").text
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def timestamp
|
11
|
+
@doc.xpath('./update/timestamp').text.to_i
|
12
|
+
end
|
13
|
+
|
14
|
+
def profile
|
15
|
+
Profile.new(Nokogiri::XML(@doc.xpath('./update/update-content/person').to_xml))
|
16
|
+
end
|
17
|
+
|
18
|
+
def likes
|
19
|
+
Likes.new(Nokogiri::XML(@doc.xpath('./update/likes').to_xml)).likes
|
20
|
+
end
|
21
|
+
|
10
22
|
end
|
11
|
-
end
|
23
|
+
end
|
@@ -1,8 +1,26 @@
|
|
1
1
|
module LinkedIn
|
2
|
-
class UrlResource
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
class UrlResource < LinkedIn::Base
|
3
|
+
|
4
|
+
def resources
|
5
|
+
@resources ||= @doc.children.inject([]) do |list, url|
|
6
|
+
list << Resource.new(url) unless url.blank?
|
7
|
+
list
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class Resource
|
12
|
+
|
13
|
+
def initialize(member_url)
|
14
|
+
@member_url = member_url
|
15
|
+
end
|
16
|
+
|
17
|
+
%w[url name].each do |f|
|
18
|
+
define_method(f.to_sym) do
|
19
|
+
@member_url.xpath("./#{f.gsub(/_/,'-')}").text
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end # resource class
|
24
|
+
|
7
25
|
end
|
8
|
-
end
|
26
|
+
end
|
data/lib/linkedin.rb
CHANGED
@@ -1,13 +1,5 @@
|
|
1
|
-
# require 'forwardable'
|
2
|
-
require 'rubygems'
|
3
|
-
|
4
|
-
gem 'oauth', '~> 0.3.5'
|
5
1
|
require 'oauth'
|
6
|
-
|
7
|
-
gem 'roxml', '~> 3.1.3'
|
8
|
-
require 'roxml'
|
9
|
-
|
10
|
-
gem 'crack', '~> 0.1.4'
|
2
|
+
require 'nokogiri'
|
11
3
|
require 'crack'
|
12
4
|
|
13
5
|
require 'cgi'
|
@@ -26,58 +18,65 @@ module LinkedIn
|
|
26
18
|
class Unauthorized < LinkedInError; end
|
27
19
|
class General < LinkedInError; end
|
28
20
|
|
29
|
-
class Unavailable
|
21
|
+
class Unavailable < StandardError; end
|
30
22
|
class InformLinkedIn < StandardError; end
|
31
|
-
class NotFound
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
def self.token
|
52
|
-
@token
|
53
|
-
end
|
54
|
-
|
55
|
-
def self.token=(token)
|
56
|
-
@token = token
|
57
|
-
end
|
58
|
-
|
59
|
-
def self.secret
|
60
|
-
@secret
|
61
|
-
end
|
62
|
-
|
63
|
-
def self.secret=(secret)
|
64
|
-
@secret = secret
|
23
|
+
class NotFound < StandardError; end
|
24
|
+
|
25
|
+
|
26
|
+
class << self
|
27
|
+
attr_accessor :token, :secret, :default_profile_fields
|
28
|
+
|
29
|
+
# config/initializers/linkedin.rb (for instance)
|
30
|
+
#
|
31
|
+
# LinkedIn.configure do |config|
|
32
|
+
# config.token = 'consumer_token'
|
33
|
+
# config.secret = 'consumer_secret'
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
# elsewhere
|
37
|
+
#
|
38
|
+
# client = LinkedIn::Client.new
|
39
|
+
def configure
|
40
|
+
yield self
|
41
|
+
true
|
42
|
+
end
|
65
43
|
end
|
44
|
+
|
66
45
|
end
|
67
46
|
|
68
|
-
directory = File.expand_path(File.dirname(__FILE__))
|
69
47
|
|
70
|
-
require
|
71
|
-
|
72
|
-
require
|
73
|
-
require
|
74
|
-
require
|
75
|
-
|
76
|
-
require
|
77
|
-
require
|
78
|
-
require
|
79
|
-
require
|
80
|
-
require
|
81
|
-
require
|
82
|
-
require
|
83
|
-
require
|
48
|
+
require 'linked_in/base'
|
49
|
+
|
50
|
+
require 'linked_in/to_xml_helpers'
|
51
|
+
require 'linked_in/request_helpers'
|
52
|
+
require 'linked_in/authorization_helpers'
|
53
|
+
|
54
|
+
require 'linked_in/api_standard_profile_request'
|
55
|
+
require 'linked_in/url_resource'
|
56
|
+
require 'linked_in/company'
|
57
|
+
require 'linked_in/country'
|
58
|
+
require 'linked_in/education'
|
59
|
+
require 'linked_in/error'
|
60
|
+
require 'linked_in/location'
|
61
|
+
require 'linked_in/position'
|
62
|
+
require 'linked_in/profile'
|
63
|
+
require 'linked_in/update'
|
64
|
+
require 'linked_in/network'
|
65
|
+
require 'linked_in/people'
|
66
|
+
require 'linked_in/connections'
|
67
|
+
require 'linked_in/client'
|
68
|
+
require 'linked_in/person'
|
69
|
+
require 'linked_in/recipient'
|
70
|
+
require 'linked_in/recipients'
|
71
|
+
require 'linked_in/message'
|
72
|
+
require 'linked_in/group'
|
73
|
+
require 'linked_in/birthdate'
|
74
|
+
require 'linked_in/recommendations'
|
75
|
+
require 'linked_in/current_share'
|
76
|
+
require 'linked_in/short_profile'
|
77
|
+
require 'linked_in/phone_number'
|
78
|
+
require 'linked_in/languages'
|
79
|
+
require 'linked_in/likes'
|
80
|
+
require 'linked_in/skill'
|
81
|
+
require 'linked_in/publications'
|
82
|
+
require 'linked_in/patents'
|
data/linkedin.gemspec
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
Gem::Specification.new do |s|
|
3
|
+
s.name = %q{linkedin}
|
4
|
+
s.version = "0.2.1"
|
5
|
+
s.platform = Gem::Platform::RUBY
|
6
|
+
|
7
|
+
s.authors = ["Wynn Netherland", "Josh Kalderimis"]
|
8
|
+
s.email = ["wynn.netherland@gmail.com", "josh.kalderimis@gmail.com"]
|
9
|
+
|
10
|
+
s.homepage = %q{http://github.com/pengwynn/linkedin}
|
11
|
+
s.summary = %q{Ruby wrapper for the LinkedIn API}
|
12
|
+
s.description = %q{Ruby wrapper for the LinkedIn API}
|
13
|
+
|
14
|
+
s.date = %q{2010-03-01}
|
15
|
+
|
16
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
17
|
+
s.extra_rdoc_files = ["README.markdown", "LICENSE"]
|
18
|
+
|
19
|
+
s.files = `git ls-files`.split("\n")
|
20
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
|
+
s.require_paths = ["lib"]
|
23
|
+
|
24
|
+
if s.respond_to? :specification_version then
|
25
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
26
|
+
s.specification_version = 3
|
27
|
+
|
28
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
29
|
+
s.add_runtime_dependency(%q<oauth>, ["~> 0.4.0"])
|
30
|
+
s.add_runtime_dependency(%q<crack>, ["~> 0.1.4"])
|
31
|
+
s.add_runtime_dependency(%q<nokogiri>, ["~> 1.4.4"])
|
32
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.4.0"])
|
33
|
+
s.add_development_dependency(%q<rake>, ["~> 0.8.7"])
|
34
|
+
s.add_development_dependency(%q<webmock>, ["~> 1.6.0"])
|
35
|
+
else
|
36
|
+
s.add_dependency(%q<oauth>, ["~> 0.4.0"])
|
37
|
+
s.add_dependency(%q<crack>, ["~> 0.1.4"])
|
38
|
+
s.add_dependency(%q<nokogiri>, ["~> 1.4.4"])
|
39
|
+
s.add_dependency(%q<rspec>, ["~> 2.4.0"])
|
40
|
+
s.add_dependency(%q<rake>, ["~> 0.8.7"])
|
41
|
+
s.add_dependency(%q<webmock>, ["~> 1.6.0"])
|
42
|
+
end
|
43
|
+
else
|
44
|
+
s.add_dependency(%q<oauth>, ["~> 0.4.0"])
|
45
|
+
s.add_dependency(%q<crack>, ["~> 0.1.4"])
|
46
|
+
s.add_dependency(%q<nokogiri>, ["~> 1.4.4"])
|
47
|
+
s.add_dependency(%q<rspec>, ["~> 2.4.0"])
|
48
|
+
s.add_dependency(%q<rake>, ["~> 0.8.7"])
|
49
|
+
s.add_dependency(%q<webmock>, ["~> 1.6.0"])
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
@@ -0,0 +1,281 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LinkedIn::Client do
|
4
|
+
context "when hitting the LinkedIn API" do
|
5
|
+
before(:each) do
|
6
|
+
LinkedIn.token = nil
|
7
|
+
LinkedIn.secret = nil
|
8
|
+
LinkedIn.default_profile_fields = nil
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:client) do
|
12
|
+
client = LinkedIn::Client.new('token', 'secret')
|
13
|
+
consumer = OAuth::Consumer.new('token', 'secret', {:site => 'https://api.linkedin.com'})
|
14
|
+
client.stub(:consumer).and_return(consumer)
|
15
|
+
client.authorize_from_access('atoken', 'asecret')
|
16
|
+
client
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should retrieve a profile for the authenticated user" do
|
20
|
+
stub_get("/v1/people/~", "profile_full.xml")
|
21
|
+
client.profile.first_name.should == 'Wynn'
|
22
|
+
client.profile.last_name.should == 'Netherland'
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should retrieve location information" do
|
26
|
+
stub_get("/v1/people/~", "profile_full.xml")
|
27
|
+
client.profile.location.name.should == 'Dallas/Fort Worth Area'
|
28
|
+
client.profile.location.country.should == 'us'
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should retrieve positions from a profile" do
|
32
|
+
stub_get("/v1/people/~", "profile_full.xml")
|
33
|
+
|
34
|
+
client.profile.positions.size.should == 4
|
35
|
+
client.profile.positions.first.company.name.should == 'Orrka'
|
36
|
+
client.profile.positions.first.is_current.should == 'true'
|
37
|
+
|
38
|
+
hp = client.profile.positions[2]
|
39
|
+
hp.title.should == 'Solution Architect'
|
40
|
+
hp.id.should == '4891362'
|
41
|
+
hp.start_month.should == 10
|
42
|
+
hp.start_year.should == 2004
|
43
|
+
hp.end_month.should == 6
|
44
|
+
hp.end_year.should == 2007
|
45
|
+
hp.is_current.should == 'false'
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should retrieve education information from a profile" do
|
49
|
+
stub_get("/v1/people/~", "profile_full.xml")
|
50
|
+
|
51
|
+
education = client.profile.educations.first
|
52
|
+
education.start_month.should == 8
|
53
|
+
education.start_year.should == 1994
|
54
|
+
education.end_month.should == 5
|
55
|
+
education.end_year.should == 1998
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should retrieve information about a profiles connections" do
|
59
|
+
stub_get("/v1/people/~", "profile_full.xml")
|
60
|
+
|
61
|
+
client.profile.connections.size.should == 146
|
62
|
+
client.profile.connections.first.first_name.should == "Ali"
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should retrieve a profiles member_url_resources" do
|
66
|
+
stub_get("/v1/people/~", "profile_full.xml")
|
67
|
+
|
68
|
+
client.profile.member_url_resources.size.should == 2
|
69
|
+
client.profile.member_url_resources.first.url.should == 'http://orrka.com'
|
70
|
+
client.profile.member_url_resources.first.name.should == 'My Company'
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should retrieve a profiles connections api_standard_profile_request" do
|
74
|
+
stub_get("/v1/people/~", "profile_full.xml")
|
75
|
+
|
76
|
+
p1 = client.profile.connections.first
|
77
|
+
p1.api_standard_profile_request.url.should == 'http://api.linkedin.com/v1/people/3YNlBdusZ5:full'
|
78
|
+
p1.api_standard_profile_request.headers[:name].should == 'x-li-auth-token'
|
79
|
+
p1.api_standard_profile_request.headers[:value].should == 'name:lui9'
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should retrieve a profile for a member by id" do
|
83
|
+
stub_get("/v1/people/id=gNma67_AdI", "profile.xml")
|
84
|
+
|
85
|
+
profile = client.profile(:id => "gNma67_AdI")
|
86
|
+
profile.first_name.should == 'Wynn'
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should retrieve a site_standard_profile_request" do
|
90
|
+
stub_get("/v1/people/~", "profile.xml")
|
91
|
+
|
92
|
+
client.profile.site_standard_profile_request.should == "http://www.linkedin.com/profile?viewProfile=&key=3559698&authToken=yib-&authType=name"
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should retrieve a profile for a member by url" do
|
96
|
+
stub_get("/v1/people/url=http%3A%2F%2Fwww.linkedin.com%2Fin%2Fnetherland", "profile.xml")
|
97
|
+
|
98
|
+
profile = client.profile(:url => "http://www.linkedin.com/in/netherland")
|
99
|
+
profile.last_name.should == 'Netherland'
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should accept field selectors when retrieving a profile" do
|
103
|
+
stub_get("/v1/people/~:(first-name,last-name)", "profile.xml")
|
104
|
+
|
105
|
+
profile = client.profile(:fields => [:first_name, :last_name])
|
106
|
+
profile.first_name.should == 'Wynn'
|
107
|
+
profile.last_name.should == 'Netherland'
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should retrieve connections for the authenticated user" do
|
111
|
+
stub_get("/v1/people/~/connections", "connections.xml")
|
112
|
+
|
113
|
+
cons = client.connections
|
114
|
+
cons.size.should == 146
|
115
|
+
cons.last.last_name.should == 'Yuchnewicz'
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should perform a search by keyword" do
|
119
|
+
stub_get("/v1/people?keywords=github", "search.xml")
|
120
|
+
|
121
|
+
results = client.search(:keywords => 'github')
|
122
|
+
results.start.should == 0
|
123
|
+
results.count.should == 10
|
124
|
+
results.profiles.first.first_name.should == 'Zach'
|
125
|
+
results.profiles.first.last_name.should == 'Inglis'
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should perform a search by multiple keywords" do
|
129
|
+
stub_get("/v1/people?keywords=ruby+rails", "search.xml")
|
130
|
+
|
131
|
+
results = client.search(:keywords => ["ruby", "rails"])
|
132
|
+
results.start.should == 0
|
133
|
+
results.count.should == 10
|
134
|
+
results.profiles.first.first_name.should == 'Zach'
|
135
|
+
results.profiles.first.last_name.should == 'Inglis'
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should perform a search by name" do
|
139
|
+
stub_get("/v1/people?name=Zach+Inglis", "search.xml")
|
140
|
+
|
141
|
+
results = client.search(:name => "Zach Inglis")
|
142
|
+
results.start.should == 0
|
143
|
+
results.count.should == 10
|
144
|
+
results.profiles.first.first_name.should == 'Zach'
|
145
|
+
results.profiles.first.last_name.should == 'Inglis'
|
146
|
+
end
|
147
|
+
|
148
|
+
it "should update a user's current status" do
|
149
|
+
stub_put("/v1/people/~/current-status", "blank.xml")
|
150
|
+
|
151
|
+
client.update_status("Testing out the LinkedIn API").code.should == "200"
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should post to a user's network stream" do
|
155
|
+
stub_post("/v1/people/~/person-activities", "blank.xml")
|
156
|
+
|
157
|
+
client.update_network("Testing out the LinkedIn API").code.should == "201"
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should clear a user's current status" do
|
161
|
+
stub_delete("/v1/people/~/current-status", "blank.xml")
|
162
|
+
|
163
|
+
client.clear_status.should == "200"
|
164
|
+
end
|
165
|
+
|
166
|
+
it "should retrieve the authenticated user's current status" do
|
167
|
+
stub_get("/v1/people/~/current-status", "status.xml")
|
168
|
+
|
169
|
+
client.current_status.should == "New blog post: What makes a good API wrapper? http://wynnnetherland.com/2009/11/what-makes-a-good-api-wrapper/"
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should retrieve status updates for the authenticated user's network" do
|
173
|
+
stub_get("/v1/people/~/network?type=STAT", "network_statuses.xml")
|
174
|
+
|
175
|
+
stats = client.network_statuses
|
176
|
+
stats.updates.first.timestamp.should == 1259179809524
|
177
|
+
stats.updates.first.should be_is_commentable
|
178
|
+
stats.updates.first.profile.id.should == "19408512"
|
179
|
+
stats.updates.first.profile.first_name.should == 'Vahid'
|
180
|
+
stats.updates.first.profile.connections.first.id.should == "28072758"
|
181
|
+
stats.updates.first.profile.connections.first.last_name.should == 'Varone'
|
182
|
+
stats.updates.first.likes.size.should == 2
|
183
|
+
stats.updates.first.likes.last.profile.first_name.should == 'Napoleon'
|
184
|
+
stats.updates.last.likes.should be_empty
|
185
|
+
end
|
186
|
+
|
187
|
+
it "should retrieve network updates" do
|
188
|
+
stub_get("/v1/people/~/network?type=PICT", "picture_updates.xml")
|
189
|
+
|
190
|
+
stats = client.network_updates(:type => "PICT")
|
191
|
+
stats.updates.size.should == 4
|
192
|
+
stats.updates.last.profile.headline.should == "Creative Director for Intridea"
|
193
|
+
end
|
194
|
+
|
195
|
+
it "should send a message to recipients" do
|
196
|
+
stub_post("/v1/people/~/mailbox", "mailbox_items.xml")
|
197
|
+
|
198
|
+
recipients = ["~", "abcdefg"]
|
199
|
+
subject = "Congratulations on your new position."
|
200
|
+
body = "You're certainly the best person for the job!"
|
201
|
+
|
202
|
+
client.send_message(subject, body, recipients).should == "201"
|
203
|
+
|
204
|
+
expect_post("/v1/people/~/mailbox", "mailbox_items.xml")
|
205
|
+
end
|
206
|
+
|
207
|
+
it "should share a link" do
|
208
|
+
stub_post("/v1/people/~/shares", "blank.xml")
|
209
|
+
|
210
|
+
client.share({
|
211
|
+
:comment => "Testing out the LinkedIn API",
|
212
|
+
:title => "Share",
|
213
|
+
:url => "http://www.linkedin.com",
|
214
|
+
:image_url => "http://www.linkedin.com/pretty_logo.jpg"
|
215
|
+
}).code.should == "201"
|
216
|
+
|
217
|
+
expect_post("/v1/people/~/shares", "shares.xml")
|
218
|
+
end
|
219
|
+
|
220
|
+
it "should retrieve language information from a profile" do
|
221
|
+
stub_get("/v1/people/~", "profile_full.xml")
|
222
|
+
|
223
|
+
language = client.profile.languages.last
|
224
|
+
language.name.should == "Klingon"
|
225
|
+
language.id.to_i.should == 72
|
226
|
+
end
|
227
|
+
|
228
|
+
it "should retrieve skills from a profile" do
|
229
|
+
stub_get("/v1/people/~", "profile_full.xml")
|
230
|
+
|
231
|
+
skill = client.profile.skills.last
|
232
|
+
skill.name.should == "Union negotiations"
|
233
|
+
skill.id.to_i.should == 38
|
234
|
+
end
|
235
|
+
|
236
|
+
it "should retrieve phone_number from a profile" do
|
237
|
+
stub_get("/v1/people/~", "profile_full.xml")
|
238
|
+
|
239
|
+
pn = client.profile.phone_numbers.last
|
240
|
+
|
241
|
+
pn.phone_type.should == "mobile"
|
242
|
+
pn.phone_number.should == "+444444444444"
|
243
|
+
end
|
244
|
+
|
245
|
+
it "should retrieve publications from a profile" do
|
246
|
+
stub_get("/v1/people/~", "profile_full.xml")
|
247
|
+
|
248
|
+
publication = client.profile.publications.last
|
249
|
+
|
250
|
+
publication.id.to_i.should == 31
|
251
|
+
publication.title.should == "How to host an awesome podcast"
|
252
|
+
publication.date.should == Date.civil(y=2006,m=8,d=1)
|
253
|
+
end
|
254
|
+
|
255
|
+
it "should retrieve patents from a profile" do
|
256
|
+
stub_get("/v1/people/~", "profile_full.xml")
|
257
|
+
|
258
|
+
patent = client.profile.patents.last
|
259
|
+
|
260
|
+
patent.id.to_i.should == 51
|
261
|
+
patent.title.should == "Time machine"
|
262
|
+
patent.date.should == Date.civil(y=2008,m=7,d=23)
|
263
|
+
end
|
264
|
+
|
265
|
+
it "should retrieve likes for a network update" do
|
266
|
+
stub_get("/v1/people/~/network/updates/key=gNma67_AdI/likes","likes.xml")
|
267
|
+
|
268
|
+
likes = client.likes("gNma67_AdI")
|
269
|
+
likes.size.should == 2
|
270
|
+
likes.first.profile.first_name.should == "George"
|
271
|
+
end
|
272
|
+
|
273
|
+
it "should put a like to a network update" do
|
274
|
+
stub_put("/v1/people/~/network/updates/key=gNma67_AdI/is-liked","blank.xml", 201)
|
275
|
+
|
276
|
+
result = client.like("gNma67_AdI")
|
277
|
+
result.code.should == "201"
|
278
|
+
end
|
279
|
+
|
280
|
+
end
|
281
|
+
end
|