linkedin 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/examples/status.rb CHANGED
@@ -3,7 +3,4 @@
3
3
  # client is a LinkedIn::Client
4
4
 
5
5
  # update status for the authenticated user
6
- client.update_status('is playing with the LinkedIn Ruby gem')
7
-
8
- # clear status for the currently logged in user
9
- client.clear_status
6
+ client.add_share(:comment => 'is playing with the LinkedIn Ruby gem')
@@ -23,11 +23,26 @@ module LinkedIn
23
23
  simple_query(path, options)
24
24
  end
25
25
 
26
+ def job(options = {})
27
+ path = jobs_path(options)
28
+ simple_query(path, options)
29
+ end
30
+
31
+ def job_bookmarks(options = {})
32
+ path = "#{person_path(options)}/job-bookmarks"
33
+ simple_query(path, options)
34
+ end
35
+
36
+ def job_suggestions(options = {})
37
+ path = "#{person_path(options)}/suggestions/job-suggestions"
38
+ simple_query(path, options)
39
+ end
40
+
26
41
  def group_memberships(options = {})
27
42
  path = "#{person_path(options)}/group-memberships"
28
43
  simple_query(path, options)
29
44
  end
30
-
45
+
31
46
  def shares(options={})
32
47
  path = "#{person_path(options)}/network/updates?type=SHAR&scope=self"
33
48
  simple_query(path, options)
@@ -55,8 +70,8 @@ module LinkedIn
55
70
  end
56
71
 
57
72
  headers = options.delete(:headers) || {}
58
- params = options.map { |k,v| "#{k}=#{v}" }.join("&")
59
- path += "?#{params}" if not params.empty?
73
+ params = to_query(options)
74
+ path += "?#{params}" if !params.empty?
60
75
 
61
76
  Mash.from_json(get(path, headers))
62
77
  end
@@ -73,17 +88,27 @@ module LinkedIn
73
88
  end
74
89
 
75
90
  def company_path(options)
76
- path = "/companies/"
77
- if id = options.delete(:id)
78
- path += "id=#{id}"
91
+ path = "/companies"
92
+
93
+ if domain = options.delete(:domain)
94
+ path += "?email-domain=#{CGI.escape(domain)}"
95
+ elsif id = options.delete(:id)
96
+ path += "/id=#{id}"
79
97
  elsif url = options.delete(:url)
80
- path += "url=#{CGI.escape(url)}"
98
+ path += "/url=#{CGI.escape(url)}"
81
99
  elsif name = options.delete(:name)
82
- path += "universal-name=#{CGI.escape(name)}"
83
- elsif domain = options.delete(:domain)
84
- path += "email-domain=#{CGI.escape(domain)}"
100
+ path += "/universal-name=#{CGI.escape(name)}"
85
101
  else
86
- path += "~"
102
+ path += "/~"
103
+ end
104
+ end
105
+
106
+ def jobs_path(options)
107
+ path = "/jobs"
108
+ if id = options.delete(:id)
109
+ path += "/id=#{id}"
110
+ else
111
+ path += "/~"
87
112
  end
88
113
  end
89
114
 
@@ -15,6 +15,12 @@ module LinkedIn
15
15
  put(path, body.to_json, "Content-Type" => "application/json")
16
16
  end
17
17
 
18
+ def add_job_bookmark(bookmark)
19
+ path = "/people/~/job-bookmarks"
20
+ body = {'job' => {'id' => bookmark}}
21
+ post(path, body.to_json, "Content-Type" => "application/json")
22
+ end
23
+
18
24
  # def share(options={})
19
25
  # path = "/people/~/shares"
20
26
  # defaults = { :visability => 'anyone' }
@@ -59,11 +59,16 @@ module LinkedIn
59
59
  end
60
60
  end
61
61
 
62
- def to_query(options)
63
- options.inject([]) do |collection, opt|
64
- collection << "#{opt[0]}=#{opt[1]}"
65
- collection
66
- end * '&'
62
+
63
+ # Stolen from Rack::Util.build_query
64
+ def to_query(params)
65
+ params.map { |k, v|
66
+ if v.class == Array
67
+ to_query(v.map { |x| [k, x] })
68
+ else
69
+ v.nil? ? escape(k) : "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"
70
+ end
71
+ }.join("&")
67
72
  end
68
73
 
69
74
  def to_uri(path, options)
@@ -3,7 +3,7 @@ module LinkedIn
3
3
  module VERSION #:nodoc:
4
4
  MAJOR = 0
5
5
  MINOR = 4
6
- PATCH = 0
6
+ PATCH = 1
7
7
  PRE = nil
8
8
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
9
9
  end
@@ -119,7 +119,7 @@ describe LinkedIn::Api do
119
119
  end
120
120
 
121
121
  it "should be able to view a company by e-mail domain" do
122
- stub_request(:get, "https://api.linkedin.com/v1/companies/email-domain=acme.com").to_return(:body => "{}")
122
+ stub_request(:get, "https://api.linkedin.com/v1/companies?email-domain=acme.com").to_return(:body => "{}")
123
123
  client.company(:domain => 'acme.com').should be_an_instance_of(LinkedIn::Mash)
124
124
  end
125
125
 
@@ -136,6 +136,32 @@ describe LinkedIn::Api do
136
136
  end
137
137
  end
138
138
 
139
+ context "Job API" do
140
+ use_vcr_cassette
141
+
142
+ it "should be able to view a job listing" do
143
+ stub_request(:get, "https://api.linkedin.com/v1/jobs/id=1586").to_return(:body => "{}")
144
+ client.job(:id => 1586).should be_an_instance_of(LinkedIn::Mash)
145
+ end
146
+
147
+ it "should be able to view its job bookmarks" do
148
+ stub_request(:get, "https://api.linkedin.com/v1/people/~/job-bookmarks").to_return(:body => "{}")
149
+ client.job_bookmarks.should be_an_instance_of(LinkedIn::Mash)
150
+ end
151
+
152
+ it "should be able to view its job suggestion" do
153
+ stub_request(:get, "https://api.linkedin.com/v1/people/~/suggestions/job-suggestions").to_return(:body => "{}")
154
+ client.job_suggestions.should be_an_instance_of(LinkedIn::Mash)
155
+ end
156
+
157
+ it "should be able to add a bookmark" do
158
+ stub_request(:post, "https://api.linkedin.com/v1/people/~/job-bookmarks").to_return(:body => "", :status => 201)
159
+ response = client.add_job_bookmark(:id => 1452577)
160
+ response.body.should == nil
161
+ response.code.should == "201"
162
+ end
163
+ end
164
+
139
165
  context "Group API" do
140
166
 
141
167
  it "should be able to list group memberships for a profile" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linkedin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-05-30 00:00:00.000000000 Z
13
+ date: 2013-06-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: hashie