ezlinkedin 0.2.2 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ezlinkedin/api/query_methods.rb +1 -1
- data/lib/ezlinkedin/client.rb +1 -0
- data/lib/ezlinkedin/request.rb +0 -2
- data/lib/ezlinkedin/search.rb +58 -0
- data/lib/ezlinkedin/version.rb +1 -1
- data/lib/ezlinkedin.rb +1 -0
- data/spec/api_spec.rb +23 -17
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 026514954030db6836bac2efd36665279e3f3c3e
|
4
|
+
data.tar.gz: ad1c5b6f9db60dcbcffc3858657e799abc6f9717
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc0bf270a371ce6d82bba6a1c983dcb233cb024844768280aad2b9595cdfb7940a0d7dd957428270c70b7165daaec6a9d9d340b1b6cca588d0391f935cad1dac
|
7
|
+
data.tar.gz: 87ec5eb125cc43d65dc446394598143770a30ac507f7a00000bb321822ca6bcd2f18ff60fb32b1bb6596dc1523db8ce14b5684bdd9b313fb5407c35948989a2d
|
data/lib/ezlinkedin/client.rb
CHANGED
data/lib/ezlinkedin/request.rb
CHANGED
@@ -0,0 +1,58 @@
|
|
1
|
+
module EzLinkedin
|
2
|
+
module Search
|
3
|
+
|
4
|
+
#
|
5
|
+
# Search linkedin based on keywords or fields
|
6
|
+
# @param options [Hash or String] Hash of search criteria or
|
7
|
+
# a string of keyword(s).
|
8
|
+
# In order to specify fields for a resource(companies or people):
|
9
|
+
# pass in the fields as a hash of arrays.
|
10
|
+
# client.search(:people => ['id', 'first-name'], fields: ['num-results'])
|
11
|
+
# client.search(:companies => ['id', 'name'])
|
12
|
+
# @param type="people" [String or symbol] :people or :company search?
|
13
|
+
#
|
14
|
+
# @return [Mash] hash of results
|
15
|
+
def search(options, type="people")
|
16
|
+
path = "/#{type.to_s}-search"
|
17
|
+
|
18
|
+
if options.is_a?(Hash)
|
19
|
+
if type_fields = options.delete(type.to_sym)
|
20
|
+
if type != 'people'
|
21
|
+
path += ":(companies:(#{type_fields.join(',')})#{search_fields(options)})"
|
22
|
+
else
|
23
|
+
path += ":(people:(#{type_fields.join(',')})#{search_fields(options)})"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
path += configure_fields(options)
|
27
|
+
elsif options.is_a?(String)
|
28
|
+
path += configure_fields({keywords: options})
|
29
|
+
options = {}
|
30
|
+
end
|
31
|
+
|
32
|
+
Mash.from_json(get(path, options))
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def search_fields(options)
|
38
|
+
if fields = options.delete(:fields)
|
39
|
+
",#{fields.join(',')}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def configure_fields(options)
|
44
|
+
path = ""
|
45
|
+
options.each do |k, v|
|
46
|
+
key = format_for_query(k.to_s)
|
47
|
+
path += "#{key}=#{URI::encode(v)}"
|
48
|
+
options.delete(k)
|
49
|
+
end
|
50
|
+
path = "?#{path}" unless path.empty?
|
51
|
+
path
|
52
|
+
end
|
53
|
+
|
54
|
+
def format_for_query(key)
|
55
|
+
key.gsub("_", "-")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/lib/ezlinkedin/version.rb
CHANGED
data/lib/ezlinkedin.rb
CHANGED
data/spec/api_spec.rb
CHANGED
@@ -45,29 +45,35 @@ describe EzLinkedin::Api do
|
|
45
45
|
# client.share_likes("network_update_key").should be_an_instance_of(EzLinkedin::Mash)
|
46
46
|
# end
|
47
47
|
#
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
48
|
+
it "should be able to search with a keyword if given a String" do
|
49
|
+
stub_request(:get, "https://api.linkedin.com/v1/people-search?keywords=business").to_return(:body => "{}")
|
50
|
+
client.search("business").should be_an_instance_of(EzLinkedin::Mash)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should be able to search with an option" do
|
54
|
+
stub_request(:get, "https://api.linkedin.com/v1/people-search?first-name=Javan").to_return(:body => "{}")
|
55
|
+
client.search(:first_name => "Javan").should be_an_instance_of(EzLinkedin::Mash)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should be able to search with an option and fetch specific fields" do
|
59
|
+
stub_request(:get, "https://api.linkedin.com/v1/people-search:(people:(id,first-name),num-results)?first-name=Javan").to_return(
|
60
|
+
:body => "{}")
|
61
|
+
client.search(:first_name => "Javan", :people => ["id", "first-name"], :fields => ['num-results']).should be_an_instance_of(EzLinkedin::Mash)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should be able to search companies" do
|
65
|
+
stub_request(:get, "https://api.linkedin.com/v1/company-search:(companies:(id,name),num-results)?keywords=apple").to_return(
|
66
|
+
:body => "{}")
|
67
|
+
client.search({:keywords => "apple", :company => ["id", "name"], :fields => ['num-results']}, "company").should be_an_instance_of(EzLinkedin::Mash)
|
68
|
+
end
|
69
|
+
|
64
70
|
it "should be able to post a share" do
|
65
71
|
stub_request(:post, "https://api.linkedin.com/v1/people/~/shares").to_return(:body => "", :status => 201)
|
66
72
|
response = client.post_share({:comment => "Testing, 1, 2, 3"})
|
67
73
|
response.body.should == nil
|
68
74
|
response.code.should == "201"
|
69
75
|
end
|
70
|
-
|
76
|
+
|
71
77
|
# it "should be able to comment on network update" do
|
72
78
|
# stub_request(:post, "https://api.linkedin.com/v1/people/~/network/updates/key=SOMEKEY/update-comments").to_return(
|
73
79
|
# :body => "", :status => 201)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ezlinkedin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- akonwi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oauth
|
@@ -187,6 +187,7 @@ files:
|
|
187
187
|
- lib/ezlinkedin/errors.rb
|
188
188
|
- lib/ezlinkedin/mash.rb
|
189
189
|
- lib/ezlinkedin/request.rb
|
190
|
+
- lib/ezlinkedin/search.rb
|
190
191
|
- lib/ezlinkedin/version.rb
|
191
192
|
- spec/api_spec.rb
|
192
193
|
- spec/client_spec.rb
|