class GreenhouseIo::JobBoard
Attributes
api_token[RW]
organization[RW]
Public Class Methods
new(api_token = nil, default_options = {})
click to toggle source
# File lib/greenhouse_io/api/job_board.rb, line 8 def initialize(api_token = nil, default_options = {}) @api_token = api_token || GreenhouseIo.configuration.api_token @organization = default_options.delete(:organization) || GreenhouseIo.configuration.organization end
Public Instance Methods
apply_to_job(job_form_hash)
click to toggle source
# File lib/greenhouse_io/api/job_board.rb, line 37 def apply_to_job(job_form_hash) post_to_job_board_api('/applications', { :body => job_form_hash, :basic_auth => basic_auth }) end
department(id, options = {})
click to toggle source
# File lib/greenhouse_io/api/job_board.rb, line 25 def department(id, options = {}) get_from_job_board_api("/boards/#{ query_organization(options) }/embed/department", query: { id: id }) end
departments(options = {})
click to toggle source
# File lib/greenhouse_io/api/job_board.rb, line 21 def departments(options = {}) get_from_job_board_api("/boards/#{ query_organization(options) }/embed/departments") end
job(id, options = {})
click to toggle source
# File lib/greenhouse_io/api/job_board.rb, line 33 def job(id, options = {}) get_from_job_board_api("/boards/#{ query_organization(options) }/embed/job", query: { id: id, questions: options[:questions] }) end
jobs(options = {})
click to toggle source
# File lib/greenhouse_io/api/job_board.rb, line 29 def jobs(options = {}) get_from_job_board_api("/boards/#{ query_organization(options) }/embed/jobs", query: { content: options[:content] }) end
office(id, options = {})
click to toggle source
# File lib/greenhouse_io/api/job_board.rb, line 17 def office(id, options = {}) get_from_job_board_api("/boards/#{ query_organization(options) }/embed/office", query: { id: id }) end
offices(options = {})
click to toggle source
# File lib/greenhouse_io/api/job_board.rb, line 13 def offices(options = {}) get_from_job_board_api("/boards/#{ query_organization(options) }/embed/offices") end
Private Instance Methods
get_from_job_board_api(url, options = {})
click to toggle source
# File lib/greenhouse_io/api/job_board.rb, line 48 def get_from_job_board_api(url, options = {}) response = get_response(url, options) if response.code == 200 parse_json(response) else raise GreenhouseIo::Error.new(response.code) end end
post_to_job_board_api(url, options)
click to toggle source
# File lib/greenhouse_io/api/job_board.rb, line 57 def post_to_job_board_api(url, options) response = post_response(url, options) if response.code == 200 response.include?("success") ? parse_json(response) : raise(GreenhouseIo::Error.new(response["reason"])) else raise GreenhouseIo::Error.new(response.code) end end
query_organization(options_hash)
click to toggle source
# File lib/greenhouse_io/api/job_board.rb, line 43 def query_organization(options_hash) org = options_hash[:organization] || @organization org.nil? ? (raise GreenhouseIo::Error.new("organization can't be blank")) : org end