Module: IndeedAPI

Includes:
HTTParty
Defined in:
lib/indeed_api.rb,
lib/indeed_api/job.rb,
lib/indeed_api/search.rb,
lib/indeed_api/version.rb,
lib/indeed_api/indeed_error.rb

Defined Under Namespace

Classes: IndeedError, Job, Search

Constant Summary collapse

API_VERSION =
2
VERSION =
'0.0.4'

Class Method Summary collapse

Class Method Details

.get_job(id) ⇒ Object

Get an individual job - for convenience



38
39
40
41
# File 'lib/indeed_api.rb', line 38

def self.get_job(id)
  jobs = get_jobs([id])
  jobs.empty? ? nil : jobs.first
end

.get_jobs(*ids) ⇒ Object

Get a bunch of jobs at once



44
45
46
47
48
49
50
51
52
53
# File 'lib/indeed_api.rb', line 44

def self.get_jobs(*ids)
  options = { :publisher => self.publisher_id, :jobkeys => ids.join(','), :v => API_VERSION }
  response = get('/apigetjobs', :query => options)
  handle_errors(response)

  return [] unless results = response['response']
  return [] unless results = results['results']
  return [] unless results = results['result']
  results.is_a?(Hash) ? [IndeedAPI::Job.new(results)] : results.map { |jd| IndeedAPI::Job.new(jd) }
end

.publisher_idObject

get the publisher ID currently in use



21
22
23
# File 'lib/indeed_api.rb', line 21

def self.publisher_id
  @publisher_id
end

.publisher_id=(id) ⇒ Object

set your publisher ID - required



16
17
18
# File 'lib/indeed_api.rb', line 16

def self.publisher_id=(id)
  @publisher_id = id
end

.search_jobs(options = {}) ⇒ Object

Search the API Can specify options at ads.indeed.com/jobroll/xmlfeed



27
28
29
30
31
32
33
34
35
# File 'lib/indeed_api.rb', line 27

def self.search_jobs(options = {})
  options.merge!(:publisher => self.publisher_id, :v => API_VERSION)
  response = get('/apisearch', :query => options)
  handle_errors(response)

  if data = response['response']
    IndeedAPI::Search.new(data)
  end
end