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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4b91ad730b6dace1d2e3d1b804396ba7387fcfbc
4
- data.tar.gz: 222c7594fe699e48e6623b6c1fa9eae3acc0ca23
3
+ metadata.gz: a1d3cfa1d77f0d4855277df4b11faaf7099e108a
4
+ data.tar.gz: fb4c7d3832153599715b5fba016fbbdaa345fa7a
5
5
  SHA512:
6
- metadata.gz: 0df0f6f7ffaca68a381502a219406a0b5045d37a3c3c68ba6540b25df3dd3024152f2fb3d1fbea29f9127583da8063f1c166f47b62db1e844b9dd039efc7bd2f
7
- data.tar.gz: 533671f2963b4dc7df510008c968d5b5c4fba3aa15e4bd3aa9cc17f336cc8aa391aeb415d38c70902c276ddaa2968fdc3c28bf35390271816c0aa1fe29b23d55
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
@@ -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
- _response.body.send method, *args, &block
15
+ _body.send method, *args, &block
15
16
  end
16
17
  end
17
18
  end
@@ -1,3 +1,3 @@
1
1
  module LinkedIn
2
- VERSION = '0.0.18'
2
+ VERSION = '0.0.19'
3
3
  end
@@ -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 'LinkedIn2 Gem v0.0.16'
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: ''
@@ -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.18
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-14 00:00:00.000000000 Z
12
+ date: 2014-10-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oauth2