workable 2.1.0 → 2.2.0

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: f79182d801ebc90eb4f72ff018f5963b67d6e619
4
- data.tar.gz: 84d6252a9b5f2cbe24254b0bea3997908c77188e
3
+ metadata.gz: 00c9c45350f524e1d18031f7d20666e40d4a9302
4
+ data.tar.gz: 0250bd9e919ddc827ce4e55e7c815d92276fa8a0
5
5
  SHA512:
6
- metadata.gz: bc72c0fbb34291527fd66ebdce1e02c53edd6af4f040989d9f0207e8b0a09b7582c728e8d4f5f904956930b50d279ade62cc97da3419b5219ccee3ace483cdb9
7
- data.tar.gz: 599d72ac71fa533f05f4ad8d4ad041a50c5c413c923f84267a49d219e9c4e2364b4fe3a5ab94b872a7c74a8a8f983d32d13366031b85a9e790a6e2c7d7b444a8
6
+ metadata.gz: 829b209a894014d59465119e3bae09aeb640dc065cc71ac92683f2382199b3ffb36449c7d66fe4cfe830c76970a2f0d0eb86155e3058f2b56a63c3d615642737
7
+ data.tar.gz: a156cdc5e1b037cedd6934787c8e39116798bb145edaa476878c5d5d9426a3910dc02cdf1b3cff7c2c69f11e9b2d12f669b0aa16d0e03ff70634519b25027480
@@ -4,11 +4,10 @@ cache: bundler
4
4
 
5
5
  rvm:
6
6
  - 2.1.10
7
- - 2.2.7
8
- - 2.3.4
9
- - 2.4.1
10
- - jruby-head
11
- - ruby-head
7
+ - 2.2.8
8
+ - 2.3.5
9
+ - 2.4.2
10
+ - jruby-9.1.6.0
12
11
 
13
12
  # https://github.com/travis-ci/travis-ci/issues/5861
14
13
  before_install:
@@ -1,3 +1,9 @@
1
+ ## 2.2.0
2
+
3
+ Date: 2017-11-09
4
+
5
+ - manage candidates endpoints support [#12](https://github.com/emq/workable/pull/12) (@aquateen)
6
+
1
7
  ## 2.1.0
2
8
 
3
9
  Date: 2017-06-19
data/README.md CHANGED
@@ -56,6 +56,8 @@ shortcode = client.jobs.first["shortcode"]
56
56
 
57
57
  client.stages # => Array of hashes
58
58
  client.recruiters # => Array of hashes
59
+ client.members # => Array of hashes
60
+
59
61
  client.job_details(shortcode) # => Hash
60
62
  client.job_questions(shortcode) # => Array of hashes
61
63
  client.job_application_form(shortcode) # => Hash
@@ -68,6 +70,15 @@ client.job_candidates(shortcode, :stage => stage_slug, :limit => 100) # => Array
68
70
 
69
71
  client.create_job_candidate(candidate, shortcode, stage_slug) # => Hash (stage_slug is optional)
70
72
 
73
+ # managing candidates
74
+ client.disqualify(candidate_id, member_id, reason)
75
+ client.revert(candidate_id, member_id) # reverts disqualification
76
+ client.copy(candidate_id, member_id, shortcode, stage)
77
+ client.relocate(candidate_id, member_id, shortcode, stage)
78
+ client.move(candidate_id, member_id, stage)
79
+ client.create_rating(candidate_id, member_id, comment, score)
80
+ client.create_comment(candidate_id, member_id, comment_text, attachment)
81
+
71
82
  # Possible errors (each one inherits from Workable::Errors::WorkableError)
72
83
  Workable::Errors::InvalidConfiguration # missing api_key / subdomain
73
84
  Workable::Errors::NotAuthorized # wrong api key
@@ -4,6 +4,7 @@ require 'net/http'
4
4
  require 'date'
5
5
  require 'ostruct'
6
6
  require 'cgi'
7
+ require 'forwardable'
7
8
 
8
9
  require_relative 'workable/version'
9
10
  require_relative 'workable/errors'
@@ -133,6 +133,106 @@ module Workable
133
133
  @transform_to.apply(:candidate, response['candidate'])
134
134
  end
135
135
 
136
+ # create a comment on the candidate's timeline
137
+ # @param candidate_id [String] the candidate's id
138
+ # @param member_id [String] id of the member leaving the comment
139
+ # @param comment_text [String] the comment's text
140
+ # @param policy [String] option to set the view rights of the comment
141
+ # @param attachment [Hash] optional attachment for the comment
142
+ # @param attachment :name [String] filename of the attachment
143
+ # @param attachment :data [String] payload of the attachment, encoded in base64
144
+ def create_comment(candidate_id, member_id, comment_text, policy = [], attachment = nil)
145
+ comment = { body: comment_text, policy: policy, attachment: attachment }
146
+
147
+ post_request("candidates/#{candidate_id}/comments") do |request|
148
+ request.body = { member_id: member_id, comment: comment }.to_json
149
+ end
150
+ end
151
+
152
+ # disqualify a candidate
153
+ # @param candidate_id [String] the candidate's id
154
+ # @param member_id [String] id of the member performing the disqualification
155
+ # @param reason [String] why the candidate should be disqualified
156
+ def disqualify(candidate_id, member_id, reason = nil)
157
+ post_request("candidates/#{candidate_id}/disqualify") do |request|
158
+ request.body = { member_id: member_id, disqualification_reason: reason }.to_json
159
+ end
160
+ end
161
+
162
+ # revert a candidate's disqualification
163
+ # @param candidate_id [String] the candidate's id
164
+ # @param member_id [String] id of the member reverting the disqualification
165
+ def revert(candidate_id, member_id)
166
+ post_request("candidates/#{candidate_id}/revert") do |request|
167
+ request.body = { member_id: member_id }.to_json
168
+ end
169
+ end
170
+
171
+ # copy a candidate to another job
172
+ # @param candidate_id [String] the candidate's id
173
+ # @param member_id [String] id of the member performing the copy
174
+ # @param shortcode [String] shortcode of the job that the candidate will be copied to
175
+ # @param stage [String] stage the candidate should be copied to
176
+ def copy(candidate_id, member_id, shortcode, stage = nil)
177
+ body = {
178
+ member_id: member_id,
179
+ target_job_shortcode: shortcode,
180
+ target_stage: stage
181
+ }
182
+
183
+ response = post_request("candidates/#{candidate_id}/copy") do |request|
184
+ request.body = body.to_json
185
+ end
186
+
187
+ @transform_to.apply(:candidate, response['candidate'])
188
+ end
189
+
190
+ # moves a candidate to another job
191
+ # @param candidate_id [Number|String] the candidate's id
192
+ # @param member_id [Number|String] id of the member performing the relocation
193
+ # @param shortcode [String] shortcode of the job that the candidate will be moved to
194
+ # @param stage [String] stage the candidate should be moved to
195
+ def relocate(candidate_id, member_id, shortcode, stage = nil)
196
+ body = {
197
+ member_id: member_id,
198
+ target_job_shortcode: shortcode,
199
+ target_stage: stage
200
+ }
201
+
202
+ response = post_request("candidates/#{candidate_id}/relocate") do |request|
203
+ request.body = body.to_json
204
+ end
205
+
206
+ @transform_to.apply(:candidate, response['candidate'])
207
+ end
208
+
209
+ # moves a candidate to another stage
210
+ # @param candidate_id [String] the candidate's id
211
+ # @param member_id [String] id of the member performing the move
212
+ # @param stage [String] stage the candidate should be moved to
213
+ def move(candidate_id, member_id, stage)
214
+ post_request("candidates/#{candidate_id}/move") do |request|
215
+ request.body = { member_id: member_id, target_stage: stage }.to_json
216
+ end
217
+ end
218
+
219
+ # creates a rating for a candidate
220
+ # @param candidate_id [String] the candidate's id
221
+ # @param member_id [String] id of the member adding the rating
222
+ # @param comment [String] a comment about the scoring of the candidate
223
+ # @param score [String] one of 'negative', 'positive', or 'definitely'
224
+ def create_rating(candidate_id, member_id, comment, score)
225
+ body = {
226
+ member_id: member_id,
227
+ comment: comment,
228
+ score: score
229
+ }
230
+
231
+ post_request("candidates/#{candidate_id}/ratings") do |request|
232
+ request.body = body.to_json
233
+ end
234
+ end
235
+
136
236
  private
137
237
 
138
238
  attr_reader :api_key, :subdomain
@@ -177,7 +277,7 @@ module Workable
177
277
  when 204, 205
178
278
  nil
179
279
  when 200...300
180
- JSON.parse(response.body)
280
+ JSON.parse(response.body) if !response.body.to_s.empty?
181
281
  when 401
182
282
  fail Errors::NotAuthorized, JSON.parse(response.body)['error']
183
283
  when 404
@@ -1,3 +1,3 @@
1
1
  module Workable
2
- VERSION = '2.1.0'
2
+ VERSION = '2.2.0'
3
3
  end
@@ -41,14 +41,22 @@ def members_json_fixture
41
41
  read_fixture 'members.json'
42
42
  end
43
43
 
44
- def new_candiate_hash_fixture
44
+ def new_candidate_hash_fixture
45
45
  JSON.parse(read_fixture('new_candidate.json'))
46
46
  end
47
47
 
48
- def new_candiate_response_json_fixture
48
+ def new_candidate_response_json_fixture
49
49
  read_fixture 'new_candidate_response.json'
50
50
  end
51
51
 
52
+ def copy_candidate_response_json_fixture
53
+ read_fixture 'copy_candidate_response.json'
54
+ end
55
+
56
+ def relocate_candidate_response_json_fixture
57
+ read_fixture 'relocate_candidate_response.json'
58
+ end
59
+
52
60
  def read_fixture(filename)
53
61
  File.read File.expand_path("../fixtures/#{filename}", __FILE__)
54
62
  end
@@ -0,0 +1,6 @@
1
+ {
2
+ "candidate": {
3
+ "id": "123456",
4
+ "url": "https://www.workable.com/spi/v3/accounts/subdomain/candidates/123456"
5
+ }
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "candidate": {
3
+ "id": "123456",
4
+ "url": "https://www.workable.com/spi/v3/accounts/subdomain/candidates/123456"
5
+ }
6
+ }
@@ -148,11 +148,11 @@ describe Workable::Client do
148
148
  expect(form).to be_kind_of(Hash)
149
149
  expect(form.has_key?('questions')).to eq true
150
150
  expect(form['form_fields'][0]).to eq({
151
- 'key' => 'phone',
152
- 'label' => 'Phone',
153
- 'type' => 'string',
154
- 'required' => true
155
- })
151
+ 'key' => 'phone',
152
+ 'label' => 'Phone',
153
+ 'type' => 'string',
154
+ 'required' => true
155
+ })
156
156
 
157
157
  end
158
158
  end
@@ -190,7 +190,7 @@ describe Workable::Client do
190
190
  describe '#job_candidates' do
191
191
  context 'happy path' do
192
192
  let(:candidates){ client.job_candidates('03FF356C8B') }
193
- before do
193
+ before do
194
194
  stub_request(:get, 'https://www.workable.com/spi/v3/accounts/subdomain/jobs/03FF356C8B/candidates')
195
195
  .to_return(status: 200, body: job_candidates_json_fixture)
196
196
  end
@@ -233,11 +233,159 @@ describe Workable::Client do
233
233
  describe '#create_job_candidate' do
234
234
  it 'POSTs requests and parses response' do
235
235
  stub_request(:post, 'https://www.workable.com/spi/v3/accounts/subdomain/jobs/slug/candidates')
236
- .with(body: new_candiate_hash_fixture.to_json)
237
- .to_return(status: 200, body: new_candiate_response_json_fixture)
236
+ .with(body: new_candidate_hash_fixture.to_json)
237
+ .to_return(status: 200, body: new_candidate_response_json_fixture)
238
238
 
239
- candidate = client.create_job_candidate(new_candiate_hash_fixture, 'slug')
239
+ candidate = client.create_job_candidate(new_candidate_hash_fixture, 'slug')
240
240
  expect(candidate['id']).to eq('3fc9a80f')
241
241
  end
242
242
  end
243
+
244
+ describe '#create_comment' do
245
+ let(:candidate_id) { '123456' }
246
+ let(:member_id) { '314' }
247
+ let(:comment_text) { "Hire this person!" }
248
+ let(:body) do
249
+ {
250
+ member_id: member_id,
251
+ comment: {
252
+ body: comment_text,
253
+ policy: [],
254
+ attachment: nil
255
+ }
256
+ }
257
+ end
258
+
259
+ it 'submits POST request' do
260
+ stub = stub_request(:post, 'https://www.workable.com/spi/v3/accounts/subdomain/candidates/123456/comments')
261
+ .with(body: body.to_json)
262
+
263
+ client.create_comment(candidate_id, member_id, comment_text)
264
+ expect(stub).to have_been_requested.once
265
+ end
266
+ end
267
+
268
+ describe '#disqualify' do
269
+ let(:candidate_id) { '123456' }
270
+ let(:member_id) { '314' }
271
+ let(:reason) { 'Lacks experience.' }
272
+ let(:body) do
273
+ {
274
+ member_id: member_id,
275
+ disqualification_reason: reason
276
+ }
277
+ end
278
+
279
+ it 'submits POST request' do
280
+ stub = stub_request(:post, 'https://www.workable.com/spi/v3/accounts/subdomain/candidates/123456/disqualify')
281
+ .with(body: body.to_json)
282
+
283
+ client.disqualify(candidate_id, member_id, reason)
284
+ expect(stub).to have_been_requested.once
285
+ end
286
+ end
287
+
288
+ describe '#revert' do
289
+ let(:candidate_id) { '123456' }
290
+ let(:member_id) { '314' }
291
+ let(:body) do
292
+ { member_id: member_id }
293
+ end
294
+
295
+ it 'submits POST request' do
296
+ stub = stub_request(:post, 'https://www.workable.com/spi/v3/accounts/subdomain/candidates/123456/revert')
297
+ .with(body: body.to_json)
298
+
299
+ client.revert(candidate_id, member_id)
300
+ expect(stub).to have_been_requested.once
301
+ end
302
+ end
303
+
304
+ describe '#copy' do
305
+ let(:candidate_id) { '123456' }
306
+ let(:member_id) { '314' }
307
+ let(:shortcode) { 'GROOV005' }
308
+ let(:stage) { 'applied' }
309
+ let(:body) do
310
+ {
311
+ member_id: member_id,
312
+ target_job_shortcode: shortcode,
313
+ target_stage: stage
314
+ }
315
+ end
316
+
317
+ it 'POSTs requests and parses response' do
318
+ stub_request(:post, 'https://www.workable.com/spi/v3/accounts/subdomain/candidates/123456/copy')
319
+ .with(body: body.to_json)
320
+ .to_return(status: 201, body: copy_candidate_response_json_fixture)
321
+
322
+ candidate = client.copy(candidate_id, member_id, shortcode, stage)
323
+ expect(candidate['id']).to eq(candidate_id)
324
+ end
325
+ end
326
+
327
+ describe '#relocate' do
328
+ let(:candidate_id) { '123456' }
329
+ let(:member_id) { '314' }
330
+ let(:shortcode) { 'GROOV005' }
331
+ let(:stage) { 'applied' }
332
+ let(:body) do
333
+ {
334
+ member_id: member_id,
335
+ target_job_shortcode: shortcode,
336
+ target_stage: stage
337
+ }
338
+ end
339
+
340
+ it 'POSTs requests and parses response' do
341
+ stub_request(:post, 'https://www.workable.com/spi/v3/accounts/subdomain/candidates/123456/relocate')
342
+ .with(body: body.to_json)
343
+ .to_return(status: 201, body: relocate_candidate_response_json_fixture)
344
+
345
+ candidate = client.relocate(candidate_id, member_id, shortcode, stage)
346
+ expect(candidate['id']).to eq(candidate_id)
347
+ end
348
+ end
349
+
350
+ describe '#move' do
351
+ let(:candidate_id) { '123456' }
352
+ let(:member_id) { '314' }
353
+ let(:stage ) { 'applied' }
354
+ let(:body) do
355
+ {
356
+ member_id: member_id,
357
+ target_stage: stage
358
+ }
359
+ end
360
+
361
+ it 'submits POST request' do
362
+ stub = stub_request(:post, 'https://www.workable.com/spi/v3/accounts/subdomain/candidates/123456/move')
363
+ .with(body: body.to_json)
364
+
365
+ client.move(candidate_id, member_id, stage)
366
+ expect(stub).to have_been_requested.once
367
+ end
368
+ end
369
+
370
+ describe '#create_rating' do
371
+ let(:candidate_id) { '123456' }
372
+ let(:member_id) { '314' }
373
+ let(:comment) { 'Good, I guess' }
374
+ let(:score) { 'positive' }
375
+ let(:body) do
376
+ {
377
+ member_id: member_id,
378
+ comment: comment,
379
+ score: score
380
+ }
381
+ end
382
+
383
+ it 'submits POST request' do
384
+ stub = stub_request(:post, 'https://www.workable.com/spi/v3/accounts/subdomain/candidates/123456/ratings')
385
+ .with(body: body.to_json)
386
+
387
+ client.create_rating(candidate_id, member_id, comment, score)
388
+ expect(stub).to have_been_requested.once
389
+ end
390
+ end
243
391
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workable
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafał Wojsznis
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-06-19 00:00:00.000000000 Z
12
+ date: 2017-11-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -92,6 +92,7 @@ files:
92
92
  - lib/workable/version.rb
93
93
  - spec/fixtures.rb
94
94
  - spec/fixtures/about.json
95
+ - spec/fixtures/copy_candidate_response.json
95
96
  - spec/fixtures/job.json
96
97
  - spec/fixtures/job_application_form.json
97
98
  - spec/fixtures/job_candidate.json
@@ -102,6 +103,7 @@ files:
102
103
  - spec/fixtures/new_candidate.json
103
104
  - spec/fixtures/new_candidate_response.json
104
105
  - spec/fixtures/recruiters.json
106
+ - spec/fixtures/relocate_candidate_response.json
105
107
  - spec/fixtures/stages.json
106
108
  - spec/lib/workable/client_spec.rb
107
109
  - spec/lib/workable/collection_spec.rb
@@ -135,6 +137,7 @@ summary: Dead-simple Ruby API client for workable.com
135
137
  test_files:
136
138
  - spec/fixtures.rb
137
139
  - spec/fixtures/about.json
140
+ - spec/fixtures/copy_candidate_response.json
138
141
  - spec/fixtures/job.json
139
142
  - spec/fixtures/job_application_form.json
140
143
  - spec/fixtures/job_candidate.json
@@ -145,6 +148,7 @@ test_files:
145
148
  - spec/fixtures/new_candidate.json
146
149
  - spec/fixtures/new_candidate_response.json
147
150
  - spec/fixtures/recruiters.json
151
+ - spec/fixtures/relocate_candidate_response.json
148
152
  - spec/fixtures/stages.json
149
153
  - spec/lib/workable/client_spec.rb
150
154
  - spec/lib/workable/collection_spec.rb