class GreenhouseIo::Client
Constants
- BASE_URL
- PERMITTED_OPTIONS
- PERMITTED_OPTIONS_PER_ENDPOINT
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 14 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 34 def activity_feed(id, options = {}) get_from_harvest_api "#{BASE_URL}/candidates/#{id}/activity_feed", options end
all_scorecards(id = nil, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 62 def all_scorecards(id = nil, options = {}) get_from_harvest_api "#{BASE_URL}/scorecards/#{id}", options end
applications(id = nil, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 46 def applications(id = nil, options = {}) get_from_harvest_api "#{BASE_URL}/applications#{path_id(id)}", options end
candidates(id = nil, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 30 def candidates(id = nil, options = {}) get_from_harvest_api "#{BASE_URL}/candidates#{path_id(id)}", options, "candidates" end
create_candidate_note(candidate_id, note_hash, on_behalf_of)
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 38 def create_candidate_note(candidate_id, note_hash, on_behalf_of) post_to_harvest_api( "#{BASE_URL}/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 54 def current_offer_for_application(id, options = {}) get_from_harvest_api "#{BASE_URL}/applications/#{id}/offers/current_offer", options end
departments(id = nil, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 26 def departments(id = nil, options = {}) get_from_harvest_api "#{BASE_URL}/departments#{path_id(id)}", options end
job_post(id, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 78 def job_post(id, options = {}) get_from_harvest_api "#{BASE_URL}/jobs/#{id}/job_post", options end
job_posts(options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 82 def job_posts(options = {}) get_from_harvest_api "#{BASE_URL}/job_posts", options end
jobs(id = nil, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 70 def jobs(id = nil, options = {}) get_from_harvest_api "#{BASE_URL}/jobs#{path_id(id)}", options end
offers(id = nil, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 22 def offers(id = nil, options = {}) get_from_harvest_api "#{BASE_URL}/offers#{path_id(id)}", options, "offers" end
offers_for_application(id, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 50 def offers_for_application(id, options = {}) get_from_harvest_api "#{BASE_URL}/applications/#{id}/offers", options end
offices(id = nil, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 18 def offices(id = nil, options = {}) get_from_harvest_api "#{BASE_URL}/offices#{path_id(id)}", options end
scheduled_interviews(id, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 66 def scheduled_interviews(id, options = {}) get_from_harvest_api "#{BASE_URL}/applications/#{id}/scheduled_interviews", options end
scorecards(id, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 58 def scorecards(id, options = {}) get_from_harvest_api "#{BASE_URL}/applications/#{id}/scorecards", options end
sources(id = nil, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 90 def sources(id = nil, options = {}) get_from_harvest_api "#{BASE_URL}/sources#{path_id(id)}", options end
stages(id, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 74 def stages(id, options = {}) get_from_harvest_api "#{BASE_URL}/jobs/#{id}/stages", options end
users(id = nil, options = {})
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 86 def users(id = nil, options = {}) get_from_harvest_api "#{BASE_URL}/users#{path_id(id)}", options end
Private Instance Methods
get_from_harvest_api(url, options = {}, endpoint = nil)
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 108 def get_from_harvest_api(url, options = {}, endpoint = nil) all_permitted_options = permitted_options(options) all_permitted_options.merge!(permitted_options_for_endpoint(options, endpoint)) if endpoint response = get_response(url, all_permitted_options) 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 96 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 100 def permitted_options(options) options.select { |key, value| PERMITTED_OPTIONS.include? key } end
permitted_options_for_endpoint(options, endpoint)
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 104 def permitted_options_for_endpoint(options, endpoint) options.select { |key, value| PERMITTED_OPTIONS_PER_ENDPOINT[endpoint].include? key } end
post_to_harvest_api(url, body, headers)
click to toggle source
# File lib/greenhouse_io/api/client.rb, line 121 def post_to_harvest_api(url, body, headers) response = post_response(url, {:body => JSON.dump(body)}, headers) if response.code == 200 parse_json(response) else raise GreenhouseIo::Error.new(response.code) end end