linkedin-build 1.1.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.autotest +14 -0
- data/.gemtest +0 -0
- data/.gitignore +49 -0
- data/.rspec +1 -0
- data/.travis.yml +6 -0
- data/.yardopts +7 -0
- data/CHANGELOG.md +99 -0
- data/EXAMPLES.md +202 -0
- data/Gemfile +11 -0
- data/LICENSE +22 -0
- data/README.md +43 -0
- data/Rakefile +15 -0
- data/lib/linked_in/api.rb +38 -0
- data/lib/linked_in/api/communications.rb +44 -0
- data/lib/linked_in/api/companies.rb +129 -0
- data/lib/linked_in/api/groups.rb +115 -0
- data/lib/linked_in/api/jobs.rb +64 -0
- data/lib/linked_in/api/people.rb +73 -0
- data/lib/linked_in/api/query_helpers.rb +86 -0
- data/lib/linked_in/api/share_and_social_stream.rb +137 -0
- data/lib/linked_in/client.rb +51 -0
- data/lib/linked_in/errors.rb +29 -0
- data/lib/linked_in/helpers.rb +6 -0
- data/lib/linked_in/helpers/authorization.rb +69 -0
- data/lib/linked_in/helpers/request.rb +85 -0
- data/lib/linked_in/mash.rb +95 -0
- data/lib/linked_in/search.rb +71 -0
- data/lib/linked_in/version.rb +11 -0
- data/lib/linkedin.rb +35 -0
- data/linkedin-build.gemspec +28 -0
- data/spec/cases/api_spec.rb +308 -0
- data/spec/cases/linkedin_spec.rb +37 -0
- data/spec/cases/mash_spec.rb +113 -0
- data/spec/cases/oauth_spec.rb +178 -0
- data/spec/cases/search_spec.rb +234 -0
- data/spec/fixtures/cassette_library/LinkedIn_Api/Company_API.yml +81 -0
- data/spec/fixtures/cassette_library/LinkedIn_Api/Company_API/should_load_correct_company_data.yml +81 -0
- data/spec/fixtures/cassette_library/LinkedIn_Client/_authorize_from_request/should_return_a_valid_access_token.yml +37 -0
- data/spec/fixtures/cassette_library/LinkedIn_Client/_request_token/with_a_callback_url/should_return_a_valid_access_token.yml +37 -0
- data/spec/fixtures/cassette_library/LinkedIn_Client/_request_token/with_default_options/should_return_a_valid_request_token.yml +37 -0
- data/spec/fixtures/cassette_library/LinkedIn_Search/_search/by_company_name_option/should_perform_a_search.yml +92 -0
- data/spec/fixtures/cassette_library/LinkedIn_Search/_search/by_email_address/should_perform_a_people_search.yml +57 -0
- data/spec/fixtures/cassette_library/LinkedIn_Search/_search/by_first_name_and_last_name_options/should_perform_a_search.yml +100 -0
- data/spec/fixtures/cassette_library/LinkedIn_Search/_search/by_first_name_and_last_name_options_with_fields/should_perform_a_search.yml +114 -0
- data/spec/fixtures/cassette_library/LinkedIn_Search/_search/by_keywords_string_parameter/should_perform_a_search.yml +52 -0
- data/spec/fixtures/cassette_library/LinkedIn_Search/_search/by_multiple_email_address/should_perform_a_multi-email_search.yml +59 -0
- data/spec/fixtures/cassette_library/LinkedIn_Search/_search/by_single_keywords_option/should_perform_a_search.yml +52 -0
- data/spec/fixtures/cassette_library/LinkedIn_Search/_search/by_single_keywords_option_with_pagination/should_perform_a_search.yml +43 -0
- data/spec/fixtures/cassette_library/LinkedIn_Search/_search/email_search_returns_unauthorized/should_raise_an_unauthorized_error.yml +59 -0
- data/spec/fixtures/cassette_library/LinkedIn_Search/_search_company/by_keywords_options_with_fields/should_perform_a_search.yml +43 -0
- data/spec/fixtures/cassette_library/LinkedIn_Search/_search_company/by_keywords_string_parameter/should_perform_a_company_search.yml +80 -0
- data/spec/fixtures/cassette_library/LinkedIn_Search/_search_company/by_single_keywords_option/should_perform_a_company_search.yml +80 -0
- data/spec/fixtures/cassette_library/LinkedIn_Search/_search_company/by_single_keywords_option_with_facets_to_return/should_return_a_facet.yml +80 -0
- data/spec/fixtures/cassette_library/LinkedIn_Search/_search_company/by_single_keywords_option_with_pagination/should_perform_a_search.yml +74 -0
- data/spec/helper.rb +34 -0
- metadata +282 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe LinkedIn do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
LinkedIn.token = nil
|
7
|
+
LinkedIn.secret = nil
|
8
|
+
LinkedIn.default_profile_fields = nil
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should be able to set the consumer token and consumer secret" do
|
12
|
+
LinkedIn.token = 'consumer_token'
|
13
|
+
LinkedIn.secret = 'consumer_secret'
|
14
|
+
|
15
|
+
LinkedIn.token.should == 'consumer_token'
|
16
|
+
LinkedIn.secret.should == 'consumer_secret'
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should be able to set the default profile fields" do
|
20
|
+
LinkedIn.default_profile_fields = ['educations', 'positions']
|
21
|
+
|
22
|
+
LinkedIn.default_profile_fields.should == ['educations', 'positions']
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should be able to set the consumer token and consumer secret via a configure block" do
|
26
|
+
LinkedIn.configure do |config|
|
27
|
+
config.token = 'consumer_token'
|
28
|
+
config.secret = 'consumer_secret'
|
29
|
+
config.default_profile_fields = ['educations', 'positions']
|
30
|
+
end
|
31
|
+
|
32
|
+
LinkedIn.token.should == 'consumer_token'
|
33
|
+
LinkedIn.secret.should == 'consumer_secret'
|
34
|
+
LinkedIn.default_profile_fields.should == ['educations', 'positions']
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe LinkedIn::Mash do
|
4
|
+
|
5
|
+
describe ".from_json" do
|
6
|
+
it "should convert a json string to a Mash" do
|
7
|
+
json_string = "{\"name\":\"Josh Kalderimis\"}"
|
8
|
+
mash = LinkedIn::Mash.from_json(json_string)
|
9
|
+
|
10
|
+
mash.should have_key('name')
|
11
|
+
mash.name.should == 'Josh Kalderimis'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#convert_keys" do
|
16
|
+
let(:mash) do
|
17
|
+
LinkedIn::Mash.new({
|
18
|
+
'firstName' => 'Josh',
|
19
|
+
'LastName' => 'Kalderimis',
|
20
|
+
'_key' => 1234,
|
21
|
+
'id' => 1345,
|
22
|
+
'_total' => 1234,
|
23
|
+
'values' => {},
|
24
|
+
'numResults' => 'total_results'
|
25
|
+
})
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should convert camal cased hash keys to underscores" do
|
29
|
+
mash.should have_key('first_name')
|
30
|
+
mash.should have_key('last_name')
|
31
|
+
end
|
32
|
+
|
33
|
+
# this breaks data coming back from linkedIn
|
34
|
+
it "converts _key to id if there is an id column" do
|
35
|
+
mash._key.should == 1234
|
36
|
+
mash.id.should == 1345
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'no collision' do
|
40
|
+
let(:mash) {
|
41
|
+
LinkedIn::Mash.new({
|
42
|
+
'_key' => 1234
|
43
|
+
})
|
44
|
+
|
45
|
+
}
|
46
|
+
it 'converts _key to id if there is no collision' do
|
47
|
+
mash.id.should == 1234
|
48
|
+
mash._key.should == 1234
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should convert the key _total to total" do
|
53
|
+
mash.should have_key('total')
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should convert the key values to all" do
|
57
|
+
mash.should have_key('all')
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should convert the key numResults to total_results" do
|
61
|
+
mash.should have_key('total_results')
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#timestamp' do
|
66
|
+
it "should return a valid Time if a key of timestamp exists and the value is an int" do
|
67
|
+
time_mash = LinkedIn::Mash.new({ 'timestamp' => 1297083249 })
|
68
|
+
|
69
|
+
time_mash.timestamp.should be_a_kind_of(Time)
|
70
|
+
time_mash.timestamp.to_i.should == 1297083249
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should return a valid Time if a key of timestamp exists and the value is an int which is greater than 9999999999" do
|
74
|
+
time_mash = LinkedIn::Mash.new({ 'timestamp' => 1297083249 * 1000 })
|
75
|
+
|
76
|
+
time_mash.timestamp.should be_a_kind_of(Time)
|
77
|
+
time_mash.timestamp.to_i.should == 1297083249
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should not try to convert to a Time object if the value isn't an Integer" do
|
81
|
+
time_mash = LinkedIn::Mash.new({ 'timestamp' => 'Foo' })
|
82
|
+
|
83
|
+
time_mash.timestamp.class.should be String
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "#to_date" do
|
88
|
+
let(:date_mash) do
|
89
|
+
LinkedIn::Mash.new({
|
90
|
+
'year' => 2010,
|
91
|
+
'month' => 06,
|
92
|
+
'day' => 23
|
93
|
+
})
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should return a valid Date if the keys year, month, day all exist" do
|
97
|
+
date_mash.to_date.should == Date.civil(2010, 06, 23)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "#all" do
|
102
|
+
let(:all_mash) do
|
103
|
+
LinkedIn::Mash.new({
|
104
|
+
:values => nil
|
105
|
+
})
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should return an empty array if values is nil due to no results being found for a query" do
|
109
|
+
all_mash.all.should == []
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe "LinkedIn::Client" do
|
4
|
+
|
5
|
+
let(:client) do
|
6
|
+
key = ENV['LINKED_IN_CONSUMER_KEY'] || '1234'
|
7
|
+
secret = ENV['LINKED_IN_CONSUMER_SECRET'] || '1234'
|
8
|
+
LinkedIn::Client.new(key, secret)
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#consumer" do
|
12
|
+
describe "default oauth options" do
|
13
|
+
let(:consumer) { client.consumer }
|
14
|
+
|
15
|
+
it "should return a configured OAuth consumer" do
|
16
|
+
consumer.site.should == 'https://api.linkedin.com'
|
17
|
+
consumer.request_token_url.should == 'https://api.linkedin.com/uas/oauth/requestToken'
|
18
|
+
consumer.access_token_url.should == 'https://api.linkedin.com/uas/oauth/accessToken'
|
19
|
+
consumer.authorize_url.should == 'https://www.linkedin.com/uas/oauth/authorize'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "proxy oauth options" do
|
24
|
+
let(:proxy) { "http://dummy.proxy" }
|
25
|
+
let(:consumer) do
|
26
|
+
LinkedIn::Client.new('1234', '1234', {
|
27
|
+
:proxy => proxy,
|
28
|
+
}).consumer
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should send requests though proxy" do
|
32
|
+
consumer.proxy.should eq proxy
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "different api and auth hosts options" do
|
37
|
+
let(:consumer) do
|
38
|
+
LinkedIn::Client.new('1234', '1234', {
|
39
|
+
:api_host => 'https://api.josh.com',
|
40
|
+
:auth_host => 'https://www.josh.com'
|
41
|
+
}).consumer
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should return a configured OAuth consumer" do
|
45
|
+
consumer.site.should == 'https://api.josh.com'
|
46
|
+
consumer.request_token_url.should == 'https://api.josh.com/uas/oauth/requestToken'
|
47
|
+
consumer.access_token_url.should == 'https://api.josh.com/uas/oauth/accessToken'
|
48
|
+
consumer.authorize_url.should == 'https://www.josh.com/uas/oauth/authorize'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "different oauth paths" do
|
53
|
+
let(:consumer) do
|
54
|
+
LinkedIn::Client.new('1234', '1234', {
|
55
|
+
:request_token_path => "/secure/oauth/requestToken",
|
56
|
+
:access_token_path => "/secure/oauth/accessToken",
|
57
|
+
:authorize_path => "/secure/oauth/authorize",
|
58
|
+
}).consumer
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should return a configured OAuth consumer" do
|
62
|
+
consumer.site.should == 'https://api.linkedin.com'
|
63
|
+
consumer.request_token_url.should == 'https://api.linkedin.com/secure/oauth/requestToken'
|
64
|
+
consumer.access_token_url.should == 'https://api.linkedin.com/secure/oauth/accessToken'
|
65
|
+
consumer.authorize_url.should == 'https://www.linkedin.com/secure/oauth/authorize'
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "specify oauth urls" do
|
70
|
+
let(:consumer) do
|
71
|
+
LinkedIn::Client.new('1234', '1234', {
|
72
|
+
:request_token_url => "https://api.josh.com/secure/oauth/requestToken",
|
73
|
+
:access_token_url => "https://api.josh.com/secure/oauth/accessToken",
|
74
|
+
:authorize_url => "https://www.josh.com/secure/oauth/authorize",
|
75
|
+
}).consumer
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should return a configured OAuth consumer" do
|
79
|
+
consumer.site.should == 'https://api.linkedin.com'
|
80
|
+
consumer.request_token_url.should == 'https://api.josh.com/secure/oauth/requestToken'
|
81
|
+
consumer.access_token_url.should == 'https://api.josh.com/secure/oauth/accessToken'
|
82
|
+
consumer.authorize_url.should == 'https://www.josh.com/secure/oauth/authorize'
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "use the :site option to specify the host of all oauth urls" do
|
87
|
+
let(:consumer) do
|
88
|
+
LinkedIn::Client.new('1234', '1234', {
|
89
|
+
:site => "https://api.josh.com"
|
90
|
+
}).consumer
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should return a configured OAuth consumer" do
|
94
|
+
consumer.site.should == 'https://api.josh.com'
|
95
|
+
consumer.request_token_url.should == 'https://api.josh.com/uas/oauth/requestToken'
|
96
|
+
consumer.access_token_url.should == 'https://api.josh.com/uas/oauth/accessToken'
|
97
|
+
consumer.authorize_url.should == 'https://api.josh.com/uas/oauth/authorize'
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe "#request_token" do
|
103
|
+
vcr_options = { :record => :new_episodes}
|
104
|
+
describe "with default options", vcr: vcr_options do
|
105
|
+
|
106
|
+
it "should return a valid request token" do
|
107
|
+
request_token = client.request_token
|
108
|
+
|
109
|
+
request_token.should be_a_kind_of OAuth::RequestToken
|
110
|
+
request_token.authorize_url.should include("https://www.linkedin.com/uas/oauth/authorize?oauth_token=")
|
111
|
+
|
112
|
+
a_request(:post, "https://api.linkedin.com/uas/oauth/requestToken").should have_been_made.once
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe "with a callback url", vcr: vcr_options do
|
117
|
+
|
118
|
+
it "should return a valid access token" do
|
119
|
+
request_token = client.request_token(:oauth_callback => 'http://www.josh.com')
|
120
|
+
|
121
|
+
request_token.should be_a_kind_of OAuth::RequestToken
|
122
|
+
request_token.authorize_url.should include("https://www.linkedin.com/uas/oauth/authorize?oauth_token=")
|
123
|
+
request_token.callback_confirmed?.should == true
|
124
|
+
|
125
|
+
a_request(:post, "https://api.linkedin.com/uas/oauth/requestToken").should have_been_made.once
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe "#authorize_from_request" do
|
131
|
+
let(:access_token) do
|
132
|
+
# if you remove the related casssette you will need to do the following
|
133
|
+
# authorize_from_request request manually
|
134
|
+
#
|
135
|
+
# request_token = client.request_token
|
136
|
+
# puts "token : #{request_token.token} - secret #{request_token.secret}"
|
137
|
+
# puts "auth url : #{request_token.authorize_url}"
|
138
|
+
# raise 'keep note of the token and secret'
|
139
|
+
#
|
140
|
+
client.authorize_from_request('dummy-token', 'dummy-secret', 'dummy-pin')
|
141
|
+
end
|
142
|
+
|
143
|
+
vcr_options = { :record => :new_episodes, :match_requests_on => [ :uri, :method] }
|
144
|
+
|
145
|
+
it "should return a valid access token", vcr: vcr_options do
|
146
|
+
access_token.should be_a_kind_of Array
|
147
|
+
access_token[0].should be_a_kind_of String
|
148
|
+
access_token[1].should be_a_kind_of String
|
149
|
+
|
150
|
+
a_request(:post, "https://api.linkedin.com/uas/oauth/accessToken").should have_been_made.once
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
describe "#access_token" do
|
155
|
+
let(:access_token) do
|
156
|
+
client.authorize_from_access('dummy-token', 'dummy-secret')
|
157
|
+
client.access_token
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should return a valid auth token" do
|
161
|
+
access_token.should be_a_kind_of OAuth::AccessToken
|
162
|
+
access_token.token.should be_a_kind_of String
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
describe "#authorize_from_access" do
|
167
|
+
let(:auth_token) do
|
168
|
+
client.authorize_from_access('dummy-token', 'dummy-secret')
|
169
|
+
end
|
170
|
+
|
171
|
+
it "should return a valid auth token" do
|
172
|
+
auth_token.should be_a_kind_of Array
|
173
|
+
auth_token[0].should be_a_kind_of String
|
174
|
+
auth_token[1].should be_a_kind_of String
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
@@ -0,0 +1,234 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe LinkedIn::Search do
|
4
|
+
|
5
|
+
# if you remove the related cassettes you will need to inform valid
|
6
|
+
# tokens and secrets to regenerate them
|
7
|
+
#
|
8
|
+
let(:client) do
|
9
|
+
consumer_token = ENV['LINKED_IN_CONSUMER_KEY'] || 'key'
|
10
|
+
consumer_secret = ENV['LINKED_IN_CONSUMER_SECRET'] || 'secret'
|
11
|
+
client = LinkedIn::Client.new(consumer_token, consumer_secret)
|
12
|
+
|
13
|
+
auth_token = ENV['LINKED_IN_AUTH_KEY'] || 'key'
|
14
|
+
auth_secret = ENV['LINKED_IN_AUTH_SECRET'] || 'secret'
|
15
|
+
client.authorize_from_access(auth_token, auth_secret)
|
16
|
+
client
|
17
|
+
end
|
18
|
+
|
19
|
+
vcr_options = { :record => :new_episodes}
|
20
|
+
|
21
|
+
describe "#search_company" do
|
22
|
+
|
23
|
+
describe "by keywords string parameter", vcr: vcr_options do
|
24
|
+
|
25
|
+
let(:results) do
|
26
|
+
client.search('apple', :company)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should perform a company search" do
|
30
|
+
results.companies.all.size.should == 10
|
31
|
+
results.companies.all.first.name.should == 'Apple'
|
32
|
+
results.companies.all.first.id.should == 162479
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "by single keywords option", vcr: vcr_options do
|
37
|
+
|
38
|
+
let(:results) do
|
39
|
+
options = {:keywords => 'apple'}
|
40
|
+
client.search(options, :company)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should perform a company search" do
|
44
|
+
results.companies.all.size.should == 10
|
45
|
+
results.companies.all.first.name.should == 'Apple'
|
46
|
+
results.companies.all.first.id.should == 162479
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "by single keywords option with facets to return", vcr: vcr_options do
|
51
|
+
|
52
|
+
let(:results) do
|
53
|
+
options = {:keywords => 'apple', :facets => [:industry]}
|
54
|
+
client.search(options, :company)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should return a facet" do
|
58
|
+
results.facets.all.first.buckets.all.first.name.should == 'Information Technology and Services'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "by single keywords option with pagination", vcr: vcr_options do
|
63
|
+
|
64
|
+
let(:results) do
|
65
|
+
options = {:keywords => 'apple', :start => 5, :count => 5}
|
66
|
+
client.search(options, :company)
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should perform a search" do
|
70
|
+
results.companies.all.size.should == 5
|
71
|
+
results.companies.all.first.name.should == 'iSquare - Apple Authorized Distributor in Greece & Cyprus'
|
72
|
+
results.companies.all.first.id.should == 2135525
|
73
|
+
results.companies.all.last.name.should == 'Apple Crumble'
|
74
|
+
results.companies.all.last.id.should == 1049054
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "by keywords options with fields", vcr: vcr_options do
|
79
|
+
|
80
|
+
let(:results) do
|
81
|
+
fields = [{:companies => [:id, :name, :industries, :description, :specialties]}, :num_results]
|
82
|
+
client.search({:keywords => 'apple', :fields => fields}, 'company')
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should perform a search" do
|
86
|
+
results.companies.all.first.name.should == 'Apple'
|
87
|
+
results.companies.all.first.description.should == 'Apple designs Macs, the best personal computers in the world, along with OS X, iLife, iWork and professional software. Apple leads the digital music revolution with its iPods and iTunes online store. Apple has reinvented the mobile phone with its revolutionary iPhone and App Store, and is defining the future of mobile media and computing devices with iPad.'
|
88
|
+
results.companies.all.first.id.should == 162479
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
describe "#search" do
|
95
|
+
|
96
|
+
describe "by keywords string parameter", vcr: vcr_options do
|
97
|
+
|
98
|
+
let(:results) do
|
99
|
+
client.search('github')
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should perform a search" do
|
103
|
+
results.people.all.size.should == 6
|
104
|
+
results.people.all.first.first_name.should == 'Shay'
|
105
|
+
results.people.all.first.last_name.should == 'Frendt'
|
106
|
+
results.people.all.first.id.should == 'ucXjUw4M9J'
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe "by single keywords option", vcr: vcr_options do
|
111
|
+
|
112
|
+
let(:results) do
|
113
|
+
client.search(:keywords => 'github')
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should perform a search" do
|
117
|
+
results.people.all.size.should == 6
|
118
|
+
results.people.all.first.first_name.should == 'Shay'
|
119
|
+
results.people.all.first.last_name.should == 'Frendt'
|
120
|
+
results.people.all.first.id.should == 'ucXjUw4M9J'
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe "by single keywords option with pagination", vcr: vcr_options do
|
125
|
+
|
126
|
+
let(:results) do
|
127
|
+
client.search(:keywords => 'github', :start => 5, :count => 5)
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should perform a search" do
|
131
|
+
results.people.all.size.should == 1
|
132
|
+
results.people.all.first.first_name.should == 'Satish'
|
133
|
+
results.people.all.first.last_name.should == 'Talim'
|
134
|
+
results.people.all.first.id.should == 'V1FPuGot-I'
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe "by first_name and last_name options", vcr: vcr_options do
|
139
|
+
|
140
|
+
let(:results) do
|
141
|
+
client.search(:first_name => 'Charles', :last_name => 'Garcia')
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should perform a search" do
|
145
|
+
results.people.all.size.should == 10
|
146
|
+
results.people.all.first.first_name.should == 'Charles'
|
147
|
+
results.people.all.first.last_name.should == 'Garcia, CFA'
|
148
|
+
results.people.all.first.id.should == '2zk34r8TvA'
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
describe "by email address", vcr: vcr_options do
|
153
|
+
|
154
|
+
let(:results) do
|
155
|
+
fields = ['id']
|
156
|
+
client.profile(:email => 'email=yy@zz.com', :fields => fields)
|
157
|
+
end
|
158
|
+
|
159
|
+
it "should perform a people search" do
|
160
|
+
results._total.should == 1
|
161
|
+
output = results["values"]
|
162
|
+
output.each do |record|
|
163
|
+
record.id.should == '96GVfLeWjU'
|
164
|
+
record._key.should == 'email=yy@zz.com'
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
describe "by multiple email address", vcr: vcr_options do
|
170
|
+
|
171
|
+
let(:results) do
|
172
|
+
fields = ['id']
|
173
|
+
client.profile(:email => 'email=yy@zz.com,email=xx@yy.com', :fields => fields)
|
174
|
+
end
|
175
|
+
|
176
|
+
it "should perform a multi-email search" do
|
177
|
+
results._total.should == 2
|
178
|
+
output = results["values"]
|
179
|
+
output.count.should == 2
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
describe "email search returns unauthorized", vcr: vcr_options do
|
184
|
+
|
185
|
+
it "should raise an unauthorized error" do
|
186
|
+
fields = ['id']
|
187
|
+
expect {client.profile(:email => 'email=aa@bb.com', :fields => fields)}.to raise_error(LinkedIn::Errors::UnauthorizedError)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
describe "by first_name and last_name options with fields", vcr: vcr_options do
|
192
|
+
|
193
|
+
let(:results) do
|
194
|
+
fields = [{:people => [:id, :first_name, :last_name, :public_profile_url, :picture_url]}, :num_results]
|
195
|
+
client.search(:first_name => 'Charles', :last_name => 'Garcia', :fields => fields)
|
196
|
+
end
|
197
|
+
|
198
|
+
it "should perform a search" do
|
199
|
+
first_person = results.people.all.first
|
200
|
+
results.people.all.size.should == 10
|
201
|
+
first_person.first_name.should == 'Charles'
|
202
|
+
first_person.last_name.should == 'Garcia, CFA'
|
203
|
+
first_person.id.should == '2zk34r8TvA'
|
204
|
+
first_person.picture_url.should be_nil
|
205
|
+
first_person.public_profile_url.should == 'http://www.linkedin.com/in/charlesgarcia'
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
describe "by company_name option", vcr: vcr_options do
|
210
|
+
|
211
|
+
let(:results) do
|
212
|
+
client.search(:company_name => 'IBM')
|
213
|
+
end
|
214
|
+
|
215
|
+
it "should perform a search" do
|
216
|
+
results.people.all.size.should == 6
|
217
|
+
results.people.all.first.first_name.should == 'Ryan'
|
218
|
+
results.people.all.first.last_name.should == 'Sue'
|
219
|
+
results.people.all.first.id.should == 'KHkgwBMaa-'
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
describe "#field_selector" do
|
224
|
+
it "should not modify the parameter object" do
|
225
|
+
fields = [{:people => [:id, :first_name]}]
|
226
|
+
fields_dup = fields.dup
|
227
|
+
client.send(:field_selector, fields)
|
228
|
+
fields.should eq fields_dup
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
end
|
233
|
+
|
234
|
+
end
|