linkedin2 0.0.18 → 0.0.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/linkedin/api/companies.rb +31 -1
- data/lib/linkedin/response.rb +3 -2
- data/lib/linkedin/version.rb +1 -1
- data/spec/api/companies_spec.rb +29 -0
- data/spec/faraday_middleware/error_response_spec.rb +1 -1
- data/spec/fixtures/requests/company-search/by_keywords_options_with_fields.yml +1 -1
- data/spec/fixtures/requests/company-search/by_single_keywords_option.yml +1 -1
- data/spec/fixtures/requests/company-search/by_single_keywords_option_with_facets_to_return.yml +1 -1
- data/spec/fixtures/requests/company-search/by_single_keywords_option_with_pagination.yml +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1d3cfa1d77f0d4855277df4b11faaf7099e108a
|
4
|
+
data.tar.gz: fb4c7d3832153599715b5fba016fbbdaa345fa7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edd75565e4d88b823179dc43096425f415951935d42dca5314943ca9d2ee786f63ba31fe16e3a273cd5985a54cc142539d1f59071bd9d1e9b0f277092d395ef1
|
7
|
+
data.tar.gz: 4e2f0ea2bd8dc08213071dd4472d069092c4d9afa68387792ccb077aa41ecd113c697a0351fa4b03246fe11162421dd82d8437c7a0f6801b119060361fe21a6a
|
@@ -21,6 +21,36 @@ module LinkedIn
|
|
21
21
|
|
22
22
|
execute root, opts.merge(selector: selector)
|
23
23
|
end
|
24
|
+
|
25
|
+
# to call this,
|
26
|
+
# client.company_search 'nike', fields: company_api_fields
|
27
|
+
# https://api.linkedin.com/v1/company-search?keywords=nike
|
28
|
+
#
|
29
|
+
# client.company_search 'nike', 'footwear', fields: company_api_fields
|
30
|
+
# https://api.linkedin.com/v1/company-search?keywords=nike%20footwear
|
31
|
+
#
|
32
|
+
# client.company_search 'nike', 'footwear', 'kobe', 'yellow', filter: 'hq-only=true', fields: company_api_fields
|
33
|
+
# https://api.linkedin.com/v1/company-search?keywords=nike%20footwear%20kobe%20yellow&hq-only=true
|
34
|
+
|
35
|
+
def company_search(*keywords, filter: nil, **opts)
|
36
|
+
|
37
|
+
opts[:params] = {} if opts[:params].blank?
|
38
|
+
opts[:params].merge! keywords: keywords.compact.join(' ')
|
39
|
+
|
40
|
+
unless filter.blank?
|
41
|
+
filter.each do |filt|
|
42
|
+
new_filt = Hash[*filt.to_s.split('=')] unless filter.respond_to? :keys
|
43
|
+
opts[:params].merge! new_filt
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
unless opts[:facets].blank?
|
48
|
+
facets = Hash['facets', opts[:facets]]
|
49
|
+
opts[:params].merge! facets
|
50
|
+
end
|
51
|
+
|
52
|
+
execute 'company-search', opts
|
53
|
+
end
|
24
54
|
end
|
25
55
|
end
|
26
|
-
end
|
56
|
+
end
|
data/lib/linkedin/response.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
module LinkedIn
|
2
2
|
class Response
|
3
|
-
attr_reader :_response
|
3
|
+
attr_reader :_response, :_body
|
4
4
|
|
5
5
|
def initialize(response)
|
6
6
|
@_response = response
|
7
|
+
@_body = response.body
|
7
8
|
end
|
8
9
|
|
9
10
|
def _status
|
@@ -11,7 +12,7 @@ module LinkedIn
|
|
11
12
|
end
|
12
13
|
|
13
14
|
def method_missing(method, *args, &block)
|
14
|
-
|
15
|
+
_body.send method, *args, &block
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
data/lib/linkedin/version.rb
CHANGED
data/spec/api/companies_spec.rb
CHANGED
@@ -25,6 +25,35 @@ describe LinkedIn::API::Companies, vcr: { cassette_name: 'companies' } do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
describe '#company_search' do
|
29
|
+
it 'fetches company profiles by a search term', vcr: { cassette_name: 'company-search/by_single_keywords_option' } do
|
30
|
+
expect(subject.company_search('apple')['companies']['values'].any? { |h| h.name.include? 'Apple' }).to be true
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'fetches company profiles with fields included in the request', vcr: { cassette_name: 'company-search/by_keywords_options_with_fields' } do
|
34
|
+
|
35
|
+
expect(subject.company_search('apple', fields: [{'companies' => ['id', 'name', 'industries', 'description', 'specialties']}, 'num-results'])['companies']['values'].any? { |h| h.name.include? 'Apple' }).to be true
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'fetches company profiles with pagination', vcr: { cassette_name: 'company-search/by_single_keywords_option_with_pagination' } do
|
39
|
+
|
40
|
+
companies = (subject.company_search('apple', filter: ["count=5", "start=5"]))
|
41
|
+
|
42
|
+
expect(companies['companies']['_count']).to eq 5
|
43
|
+
expect(companies['companies']['_start']).to eq 5
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'fetches company profiles and returns facets', vcr: { cassette_name: 'company-search/by_single_keywords_option_with_facets_to_return' } do
|
47
|
+
|
48
|
+
companies = (subject.company_search('apple', facets: 'industry'))
|
49
|
+
|
50
|
+
expect(companies['companies']['values'].any? { |h| h.name.include? 'Apple' }).to be true
|
51
|
+
expect(companies['facets']['_total']).to eq 1
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
28
57
|
context 'todo' do
|
29
58
|
it "should load correct company data" do
|
30
59
|
pending
|
@@ -21,7 +21,7 @@ describe LinkedIn::FaradayMiddleware::ErrorResponse, vcr: { cassette_name: 'inva
|
|
21
21
|
|
22
22
|
it 'includes the Faraday request/response object for further introspection by the consumer' do
|
23
23
|
expect { subject.profile }.to raise_error do |error|
|
24
|
-
error.request.headers['User-Agent'].should eq
|
24
|
+
error.request.headers['User-Agent'].should eq "LinkedIn2 Gem v#{LinkedIn::VERSION}"
|
25
25
|
error.response.headers['server'].should eq 'Apache-Coyote/1.1'
|
26
26
|
end
|
27
27
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://api.linkedin.com/v1/company-search:(companies:(id,name,industries,description,specialties),num-results)?keywords=apple
|
5
|
+
uri: https://api.linkedin.com/v1/company-search:(companies:(id,name,industries,description,specialties),num-results)?keywords=apple&oauth2_access_token=AQUJwEF40pJUbVxsW_mujQ3QCiXvlTnMFk55SlfVPYRcAPdsn1oE1Hm8Ldlc61o57k96i04ufG81KFdPJIOSJswXsGyZ0tk9IMZea8sfNXMGMnZgikQJUQPkmRVYVw9BP1qH9tp7hJF32DQtzkBB_NE8xPASPVgXVWbbntChGyYqqDvF1p8
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://api.linkedin.com/v1/company-search?keywords=apple
|
5
|
+
uri: https://api.linkedin.com/v1/company-search?keywords=apple&oauth2_access_token=AQUJwEF40pJUbVxsW_mujQ3QCiXvlTnMFk55SlfVPYRcAPdsn1oE1Hm8Ldlc61o57k96i04ufG81KFdPJIOSJswXsGyZ0tk9IMZea8sfNXMGMnZgikQJUQPkmRVYVw9BP1qH9tp7hJF32DQtzkBB_NE8xPASPVgXVWbbntChGyYqqDvF1p8
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
data/spec/fixtures/requests/company-search/by_single_keywords_option_with_facets_to_return.yml
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://api.linkedin.com/v1/company-search?facets=industry&keywords=apple
|
5
|
+
uri: https://api.linkedin.com/v1/company-search?facets=industry&keywords=apple&oauth2_access_token=AQUJwEF40pJUbVxsW_mujQ3QCiXvlTnMFk55SlfVPYRcAPdsn1oE1Hm8Ldlc61o57k96i04ufG81KFdPJIOSJswXsGyZ0tk9IMZea8sfNXMGMnZgikQJUQPkmRVYVw9BP1qH9tp7hJF32DQtzkBB_NE8xPASPVgXVWbbntChGyYqqDvF1p8
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://api.linkedin.com/v1/company-search?count=5&keywords=apple&start=5
|
5
|
+
uri: https://api.linkedin.com/v1/company-search?count=5&keywords=apple&oauth2_access_token=AQUJwEF40pJUbVxsW_mujQ3QCiXvlTnMFk55SlfVPYRcAPdsn1oE1Hm8Ldlc61o57k96i04ufG81KFdPJIOSJswXsGyZ0tk9IMZea8sfNXMGMnZgikQJUQPkmRVYVw9BP1qH9tp7hJF32DQtzkBB_NE8xPASPVgXVWbbntChGyYqqDvF1p8&start=5
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linkedin2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Breznak
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-10-
|
12
|
+
date: 2014-10-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: oauth2
|