workable 0.1.0 → 0.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: f5b055057eaa9673cc11ff001494e2de8f474202
4
- data.tar.gz: debfe438f1b676c201e150a3df03f912e18ebb49
3
+ metadata.gz: 7eaebf59a51c6219ca5f278a91b99226b043fa1d
4
+ data.tar.gz: f41c7493529160c2d7e134b0aeb1d3284b5218e2
5
5
  SHA512:
6
- metadata.gz: dd0315dec1bd07662e96a22213263121e7306b481662326689e0bce5817999f08f74477e2877c781d043d920a8dbd2e251335374741b833ca53ec27c46b4e4d0
7
- data.tar.gz: 7458b826e7359bd25ad50fabe5c88921c3e687523748664cfd982874f0b77b318de697621dbfdb7ddaccef75cb709ce08f50af8ec7a80496a9d37d70b2bec6cb
6
+ metadata.gz: 840612f71285030a314ab414b8facd077e0cbc8eac8076353a8ab4a4b835c954c9000d9454ceda93b19b0cf97b7154fad33e95ff109a27f2d72196217b3a8cd7
7
+ data.tar.gz: 3231f81122c3170a0d461eed5c95733b0cd9fe85381ced8834eacb1988d873bcf65e7e5497d21f1e5bdab5e72b6eec72afd05bccb6837b63c80c4ff924cb6172
data/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ ## 0.2.0
2
+
3
+ - stages, job_questions and filtering candidates by stages #1 (@mpapis)
4
+ - return `Workable::Errors::RequestToLong` in case of 503 http error #2 (@mpapis)
5
+
6
+ ## 0.1.0
7
+
8
+ - initial release
data/README.md CHANGED
@@ -3,6 +3,8 @@
3
3
  [![Code Climate](https://codeclimate.com/github/emq/workable/badges/gpa.svg)](https://codeclimate.com/github/emq/workable)
4
4
  [![Build Status](https://travis-ci.org/emq/workable.svg?branch=master)](https://travis-ci.org/emq/workable)
5
5
  [![Coverage Status](https://coveralls.io/repos/emq/workable/badge.png?branch=master)](https://coveralls.io/r/emq/workable?branch=master)
6
+ [![Gem Version](https://badge.fury.io/rb/workable.svg)](http://badge.fury.io/rb/workable)
7
+ [![Dependency Status](https://gemnasium.com/emq/workable.svg)](https://gemnasium.com/emq/workable)
6
8
 
7
9
  Dead-simple Ruby API client for [workable.com][1]. No extra runtime dependencies. Ruby >= 1.9.3.
8
10
 
@@ -35,20 +37,25 @@ Internal interface / api is in early stage, so far you can:
35
37
 
36
38
  ``` ruby
37
39
  client = Workable::Client.new(api_key: 'api_key', subdomain: 'your_subdomain')
40
+
41
+ # takes optional phase argument (string): 'published' (default), 'draft', 'closed' or 'archived'
38
42
  client.jobs # => [#<Workable::Job>, #<Workable::Job>]
39
43
 
40
44
  shortcode = 'job_shortcode'
41
45
 
42
46
  # API queries are not cached (at all) - it's up to you to cache results one way or another
43
47
 
44
- client.job_details(shortcode) # => #<Workable::Job>
45
- client.job_candidates(shortcode) # => Array of hashes
48
+ client.stages # => Array of hashes
49
+ client.job_details(shortcode) # => #<Workable::Job>
50
+ client.job_questions(shortcode) # => Array of hashes
51
+ client.job_candidates(shortcode, stage_slug) # => Array of hashes (skip stage_slug for all stages)
46
52
 
47
53
  # Possible errors (each one inherits from Workable::Errors::WorkableError)
48
54
  Workable::Errors::InvalidConfiguration # missing api_key / subdomain
49
- Workable::Errors::NotAuthorized # wrong api key
55
+ Workable::Errors::NotAuthorized # wrong api key
50
56
  Workable::Errors::InvalidResponse # something when wrong during the request?
51
- Workable::Errors::NotFound # 404 from workable
57
+ Workable::Errors::NotFound # 404 from workable
58
+ Workable::Errors::RequestToLong # When the requested result takes to long to calculate, try limiting your query
52
59
  ```
53
60
 
54
61
  ## Missing/Todo
@@ -15,10 +15,19 @@ module Workable
15
15
  Job.new(get_request"jobs/#{shortcode}")
16
16
  end
17
17
 
18
- def job_candidates(shortcode)
18
+ def job_candidates(shortcode, stage_slug = nil)
19
+ shortcode = "#{shortcode}/#{stage_slug}" unless stage_slug.nil?
19
20
  get_request("jobs/#{shortcode}/candidates")['candidates']
20
21
  end
21
22
 
23
+ def job_questions(shortcode)
24
+ get_request("jobs/#{shortcode}/questions")['questions']
25
+ end
26
+
27
+ def stages
28
+ get_request("stages")['stages']
29
+ end
30
+
22
31
  private
23
32
 
24
33
  attr_reader :api_key, :subdomain
@@ -47,6 +56,8 @@ module Workable
47
56
  raise Errors::NotAuthorized, response.body
48
57
  when 404
49
58
  raise Errors::NotFound, response.body
59
+ when 503
60
+ raise Errors::RequestToLong, response.body
50
61
  when proc { |code| code != 200 }
51
62
  raise Errors::InvalidResponse, "Response code: #{response.code}"
52
63
  end
@@ -5,5 +5,6 @@ module Workable
5
5
  class NotAuthorized < WorkableError; end
6
6
  class InvalidResponse < WorkableError; end
7
7
  class NotFound < WorkableError; end
8
+ class RequestToLong < WorkableError; end
8
9
  end
9
10
  end
@@ -1,3 +1,3 @@
1
1
  module Workable
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/spec/fixtures.rb CHANGED
@@ -115,3 +115,24 @@ def job_candidates_json_fixture
115
115
  ]
116
116
  })
117
117
  end
118
+
119
+ def stages_json_fixture
120
+ JSON.generate({"stages" => [
121
+ {"slug"=>"sourced", "name"=>"Sourced", "kind"=>"sourced", "position"=>1},
122
+ {"slug"=>"applied", "name"=>"Applied", "kind"=>"applied", "position"=>2},
123
+ {"slug"=>"soft-talk", "name"=>"Soft Talk", "kind"=>"interview", "position"=>3},
124
+ {"slug"=>"wait", "name"=>"Wait", "kind"=>"shortlisted", "position"=>4},
125
+ {"slug"=>"assessment", "name"=>"Assessment", "kind"=>"assessment", "position"=>5},
126
+ {"slug"=>"review", "name"=>"Review", "kind"=>"assessment", "position"=>6},
127
+ {"slug"=>"tech-talk", "name"=>"Tech Talk", "kind"=>"interview", "position"=>7},
128
+ {"slug"=>"prepare", "name"=>"Prepare", "kind"=>"interview", "position"=>8},
129
+ {"slug"=>"ready", "name"=>"Ready", "kind"=>"shortlisted", "position"=>9},
130
+ {"slug"=>"later", "name"=>"Later", "kind"=>"shortlisted", "position"=>10}
131
+ ]})
132
+ end
133
+
134
+ def job_questions_json_fixture
135
+ JSON.generate({"questions" => [
136
+ {"key"=>"fe8", "body"=>"How many fingers do you have?", "type"=>"free_text"}
137
+ ]})
138
+ end
@@ -58,6 +58,18 @@ describe Workable::Client do
58
58
  end
59
59
  end
60
60
 
61
+ describe '#job_questions' do
62
+ let(:client){ described_class.new(api_key: 'test', subdomain: 'subdomain') }
63
+
64
+ it 'returns questions for given job' do
65
+ stub_request(:get, "https://www.workable.com/spi/v2/accounts/subdomain/jobs/03FF356C8B/questions")
66
+ .to_return(status: 200, body: job_questions_json_fixture, headers: {})
67
+
68
+ expect(client.job_questions('03FF356C8B')).to be_kind_of(Array)
69
+ end
70
+
71
+ end
72
+
61
73
  describe '#candidates' do
62
74
  let(:client){ described_class.new(api_key: 'test', subdomain: 'subdomain') }
63
75
 
@@ -67,6 +79,25 @@ describe Workable::Client do
67
79
 
68
80
  expect(client.job_candidates('03FF356C8B')).to be_kind_of(Array)
69
81
  end
82
+
83
+ it 'raises exception on to long requests' do
84
+ stub_request(:get, "https://www.workable.com/spi/v2/accounts/subdomain/jobs?phase=published")
85
+ .to_return(status: 503, body: '{"error":"Not authorized"}', headers: {})
86
+
87
+ expect { client.jobs }.to raise_error(Workable::Errors::RequestToLong)
88
+ end
89
+
90
+ end
91
+
92
+ describe '#stages' do
93
+ let(:client){ described_class.new(api_key: 'test', subdomain: 'subdomain') }
94
+
95
+ it 'returns array of stages' do
96
+ stub_request(:get, "https://www.workable.com/spi/v2/accounts/subdomain/stages")
97
+ .to_return(status: 200, body: stages_json_fixture, headers: {})
98
+
99
+ expect(client.stages).to be_kind_of(Array)
100
+ end
70
101
  end
71
102
 
72
103
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafał Wojsznis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-05 00:00:00.000000000 Z
11
+ date: 2015-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -90,6 +90,7 @@ files:
90
90
  - ".gitignore"
91
91
  - ".rspec"
92
92
  - ".travis.yml"
93
+ - CHANGELOG.md
93
94
  - Gemfile
94
95
  - LICENSE.txt
95
96
  - README.md
@@ -124,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
125
  version: '0'
125
126
  requirements: []
126
127
  rubyforge_project:
127
- rubygems_version: 2.4.5
128
+ rubygems_version: 2.4.6
128
129
  signing_key:
129
130
  specification_version: 4
130
131
  summary: Dead-simple Ruby API client for workable.com