class GreenhouseIo::JobBoard
Constants
- BASE_URL
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 7 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 36 def apply_to_job(job_form_hash) post_to_job_board_api("#{BASE_URL}/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 24 def department(id, options = {}) get_from_job_board_api("#{BASE_URL}/boards/#{ query_organization(options) }/embed/department", { id: id }) end
departments(options = {})
click to toggle source
# File lib/greenhouse_io/api/job_board.rb, line 20 def departments(options = {}) get_from_job_board_api("#{BASE_URL}/boards/#{ query_organization(options) }/embed/departments") end
job(id, options = {})
click to toggle source
# File lib/greenhouse_io/api/job_board.rb, line 32 def job(id, options = {}) get_from_job_board_api("#{BASE_URL}/boards/#{ query_organization(options) }/embed/job", { id: id, questions: options[:questions] }) end
jobs(options = {})
click to toggle source
# File lib/greenhouse_io/api/job_board.rb, line 28 def jobs(options = {}) get_from_job_board_api("#{BASE_URL}/boards/#{ query_organization(options) }/embed/jobs", { content: options[:content] }) end
office(id, options = {})
click to toggle source
# File lib/greenhouse_io/api/job_board.rb, line 16 def office(id, options = {}) get_from_job_board_api("#{BASE_URL}/boards/#{ query_organization(options) }/embed/office", { id: id }) end
offices(options = {})
click to toggle source
# File lib/greenhouse_io/api/job_board.rb, line 12 def offices(options = {}) get_from_job_board_api("#{BASE_URL}/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 47 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 56 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 42 def query_organization(options_hash) org = options_hash[:organization] || @organization org.nil? ? (raise GreenhouseIo::Error.new("organization can't be blank")) : org end