Class: Workable::Client
- Inherits:
-
Object
- Object
- Workable::Client
- Defined in:
- lib/workable/client.rb
Instance Method Summary collapse
-
#about ⇒ Object
return information about your account.
-
#copy(candidate_id, member_id, shortcode, stage = nil) ⇒ Object
copy a candidate to another job.
-
#create_comment(candidate_id, member_id, comment_text, policy = [], attachment = nil) ⇒ Object
create a comment on the candidate’s timeline.
-
#create_job_candidate(candidate, shortcode, stage_slug = nil) ⇒ Hash
create new candidate for given job.
-
#create_rating(candidate_id, member_id, comment, score) ⇒ Object
creates a rating for a candidate.
-
#disqualify(candidate_id, member_id, reason = nil) ⇒ Object
disqualify a candidate.
-
#initialize(options = {}) ⇒ Client
constructor
set access to workable and data transformation methods.
-
#job_application_form(shortcode) ⇒ Object
application form questions for job.
-
#job_candidate(shortcode, id) ⇒ Object
return the full object of a specific candidate.
-
#job_candidates(shortcode, params = {}) ⇒ Object
list candidates for given job.
-
#job_details(shortcode) ⇒ Object
request detailed information about job.
-
#job_members(shortcode) ⇒ Object
return a collection of job’s members.
-
#job_questions(shortcode) ⇒ Object
list of questions for job.
-
#job_recruiters(shortcode) ⇒ Object
return a collection of the job’s external recruiters.
-
#jobs(params = {}) ⇒ Object
request posted jobs.
-
#members ⇒ Object
returns a collection of your account members.
-
#move(candidate_id, member_id, stage) ⇒ Object
moves a candidate to another stage.
-
#recruiters ⇒ Object
returns a collection of your account external recruiters.
-
#relocate(candidate_id, member_id, shortcode, stage = nil) ⇒ Object
moves a candidate to another job.
-
#revert(candidate_id, member_id) ⇒ Object
revert a candidate’s disqualification.
-
#stages ⇒ Object
returns a collection of your recruitment pipeline stages.
Constructor Details
#initialize(options = {}) ⇒ Client
set access to workable and data transformation methods
30 31 32 33 34 35 |
# File 'lib/workable/client.rb', line 30 def initialize( = {}) @api_key = .fetch(:api_key) { configuration_error 'Missing api_key argument' } @subdomain = .fetch(:subdomain) { configuration_error 'Missing subdomain argument' } @transform_to = Transformation.new([:transform_to]) @transform_from = Transformation.new([:transform_from]) end |
Instance Method Details
#about ⇒ Object
return information about your account
38 39 40 |
# File 'lib/workable/client.rb', line 38 def about get_request('') end |
#copy(candidate_id, member_id, shortcode, stage = nil) ⇒ Object
copy a candidate to another job
176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/workable/client.rb', line 176 def copy(candidate_id, member_id, shortcode, stage = nil) body = { member_id: member_id, target_job_shortcode: shortcode, target_stage: stage } response = post_request("candidates/#{candidate_id}/copy") do |request| request.body = body.to_json end @transform_to.apply(:candidate, response['candidate']) end |
#create_comment(candidate_id, member_id, comment_text, policy = [], attachment = nil) ⇒ Object
create a comment on the candidate’s timeline
144 145 146 147 148 149 150 |
# File 'lib/workable/client.rb', line 144 def create_comment(candidate_id, member_id, comment_text, policy = [], = nil) comment = { body: comment_text, policy: policy, attachment: } post_request("candidates/#{candidate_id}/comments") do |request| request.body = { member_id: member_id, comment: comment }.to_json end end |
#create_job_candidate(candidate, shortcode, stage_slug = nil) ⇒ Hash
create new candidate for given job
126 127 128 129 130 131 132 133 134 |
# File 'lib/workable/client.rb', line 126 def create_job_candidate(candidate, shortcode, stage_slug = nil) shortcode = "#{shortcode}/#{stage_slug}" if stage_slug response = post_request("jobs/#{shortcode}/candidates") do |request| request.body = @transform_from.apply(:candidate, candidate).to_json end @transform_to.apply(:candidate, response['candidate']) end |
#create_rating(candidate_id, member_id, comment, score) ⇒ Object
creates a rating for a candidate
224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/workable/client.rb', line 224 def (candidate_id, member_id, comment, score) body = { member_id: member_id, comment: comment, score: score } post_request("candidates/#{candidate_id}/ratings") do |request| request.body = body.to_json end end |
#disqualify(candidate_id, member_id, reason = nil) ⇒ Object
disqualify a candidate
156 157 158 159 160 |
# File 'lib/workable/client.rb', line 156 def disqualify(candidate_id, member_id, reason = nil) post_request("candidates/#{candidate_id}/disqualify") do |request| request.body = { member_id: member_id, disqualification_reason: reason }.to_json end end |
#job_application_form(shortcode) ⇒ Object
application form questions for job
83 84 85 |
# File 'lib/workable/client.rb', line 83 def job_application_form(shortcode) @transform_to.apply(:question, get_request("jobs/#{shortcode}/application_form")) end |
#job_candidate(shortcode, id) ⇒ Object
return the full object of a specific candidate
115 116 117 |
# File 'lib/workable/client.rb', line 115 def job_candidate(shortcode, id) @transform_to.apply(:candidate, get_request("jobs/#{shortcode}/candidates/#{id}")['candidate']) end |
#job_candidates(shortcode, params = {}) ⇒ Object
list candidates for given job
108 109 110 |
# File 'lib/workable/client.rb', line 108 def job_candidates(shortcode, params = {}) build_collection("jobs/#{shortcode}/candidates", :candidate, 'candidates', params) end |
#job_details(shortcode) ⇒ Object
request detailed information about job
71 72 73 |
# File 'lib/workable/client.rb', line 71 def job_details(shortcode) @transform_to.apply(:job, get_request("jobs/#{shortcode}")) end |
#job_members(shortcode) ⇒ Object
return a collection of job’s members
89 90 91 |
# File 'lib/workable/client.rb', line 89 def job_members(shortcode) @transform_to.apply(:member, get_request("jobs/#{shortcode}/members")['members']) end |
#job_questions(shortcode) ⇒ Object
list of questions for job
77 78 79 |
# File 'lib/workable/client.rb', line 77 def job_questions(shortcode) @transform_to.apply(:question, get_request("jobs/#{shortcode}/questions")['questions']) end |
#job_recruiters(shortcode) ⇒ Object
return a collection of the job’s external recruiters
95 96 97 |
# File 'lib/workable/client.rb', line 95 def job_recruiters(shortcode) @transform_to.apply(:recruiter, get_request("jobs/#{shortcode}/recruiters")['recruiters']) end |
#jobs(params = {}) ⇒ Object
request posted jobs
65 66 67 |
# File 'lib/workable/client.rb', line 65 def jobs(params = {}) build_collection('jobs', :job, 'jobs', params) end |
#members ⇒ Object
returns a collection of your account members
43 44 45 |
# File 'lib/workable/client.rb', line 43 def members @transform_to.apply(:member, get_request('members')['members']) end |
#move(candidate_id, member_id, stage) ⇒ Object
moves a candidate to another stage
213 214 215 216 217 |
# File 'lib/workable/client.rb', line 213 def move(candidate_id, member_id, stage) post_request("candidates/#{candidate_id}/move") do |request| request.body = { member_id: member_id, target_stage: stage }.to_json end end |
#recruiters ⇒ Object
returns a collection of your account external recruiters
48 49 50 |
# File 'lib/workable/client.rb', line 48 def recruiters @transform_to.apply(:recruiter, get_request('recruiters')['recruiters']) end |
#relocate(candidate_id, member_id, shortcode, stage = nil) ⇒ Object
moves a candidate to another job
195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/workable/client.rb', line 195 def relocate(candidate_id, member_id, shortcode, stage = nil) body = { member_id: member_id, target_job_shortcode: shortcode, target_stage: stage } response = post_request("candidates/#{candidate_id}/relocate") do |request| request.body = body.to_json end @transform_to.apply(:candidate, response['candidate']) end |
#revert(candidate_id, member_id) ⇒ Object
revert a candidate’s disqualification
165 166 167 168 169 |
# File 'lib/workable/client.rb', line 165 def revert(candidate_id, member_id) post_request("candidates/#{candidate_id}/revert") do |request| request.body = { member_id: member_id }.to_json end end |
#stages ⇒ Object
returns a collection of your recruitment pipeline stages
53 54 55 |
# File 'lib/workable/client.rb', line 53 def stages @transform_to.apply(:stage, get_request('stages')['stages']) end |