class GreenhouseIo::Client
Constants
- PERMITTED_OPTIONS
Attributes
api_token[RW]
link[RW]
rate_limit[RW]
rate_limit_remaining[RW]
Public Class Methods
new(api_token = nil)
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 11 def initialize(api_token = nil) @api_token = api_token || GreenhouseIo.configuration.api_token end
Public Instance Methods
activity_feed(id, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 31 def activity_feed(id, options = {}) get_from_harvest_api "/candidates/#{id}/activity_feed", options end
all_scorecards(id = nil, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 59 def all_scorecards(id = nil, options = {}) get_from_harvest_api "/scorecards/#{id}", options end
applications(id = nil, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 43 def applications(id = nil, options = {}) get_from_harvest_api "/applications#{path_id(id)}", options end
candidates(id = nil, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 27 def candidates(id = nil, options = {}) get_from_harvest_api "/candidates#{path_id(id)}", options end
create_candidate_note(candidate_id, note_hash, on_behalf_of)
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 35 def create_candidate_note(candidate_id, note_hash, on_behalf_of) post_to_harvest_api( "/candidates/#{candidate_id}/activity_feed/notes", note_hash, { 'On-Behalf-Of' => on_behalf_of.to_s } ) end
current_offer_for_application(id, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 51 def current_offer_for_application(id, options = {}) get_from_harvest_api "/applications/#{id}/offers/current_offer", options end
departments(id = nil, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 23 def departments(id = nil, options = {}) get_from_harvest_api "/departments#{path_id(id)}", options end
job_post(id, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 75 def job_post(id, options = {}) get_from_harvest_api "/jobs/#{id}/job_post", options end
jobs(id = nil, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 67 def jobs(id = nil, options = {}) get_from_harvest_api "/jobs#{path_id(id)}", options end
offers(id = nil, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 19 def offers(id = nil, options = {}) get_from_harvest_api "/offers#{path_id(id)}", options end
offers_for_application(id, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 47 def offers_for_application(id, options = {}) get_from_harvest_api "/applications/#{id}/offers", options end
offices(id = nil, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 15 def offices(id = nil, options = {}) get_from_harvest_api "/offices#{path_id(id)}", options end
scheduled_interviews(id, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 63 def scheduled_interviews(id, options = {}) get_from_harvest_api "/applications/#{id}/scheduled_interviews", options end
scorecards(id, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 55 def scorecards(id, options = {}) get_from_harvest_api "/applications/#{id}/scorecards", options end
sources(id = nil, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 83 def sources(id = nil, options = {}) get_from_harvest_api "/sources#{path_id(id)}", options end
stages(id, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 71 def stages(id, options = {}) get_from_harvest_api "/jobs/#{id}/stages", options end
users(id = nil, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 79 def users(id = nil, options = {}) get_from_harvest_api "/users#{path_id(id)}", options end
Private Instance Methods
get_from_harvest_api(url, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 97 def get_from_harvest_api(url, options = {}) response = get_response(url, { :query => permitted_options(options), :basic_auth => basic_auth }) set_headers_info(response.headers) if response.code == 200 parse_json(response) else raise GreenhouseIo::Error.new(response.code) end end
path_id(id = nil)
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 89 def path_id(id = nil) "/#{id}" unless id.nil? end
permitted_options(options)
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 93 def permitted_options(options) options.select { |key, value| PERMITTED_OPTIONS.include? key } end
post_to_harvest_api(url, body, headers)
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 112 def post_to_harvest_api(url, body, headers) response = post_response(url, { :body => JSON.dump(body), :basic_auth => basic_auth, :headers => headers }) set_headers_info(response.headers) if response.code == 200 parse_json(response) else raise GreenhouseIo::Error.new(response.code) end end
set_headers_info(headers)
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 128 def set_headers_info(headers) self.rate_limit = headers['x-ratelimit-limit'].to_i self.rate_limit_remaining = headers['x-ratelimit-remaining'].to_i self.link = headers['link'].to_s end