Class: Cb::JobApi

Inherits:
Object
  • Object
show all
Defined in:
lib/cb/clients/job_api.rb

Class Method Summary collapse

Class Method Details

.find_by_criteria(criteria) ⇒ Object

Retrieve a job by did

For detailed information around this API please visit: http://api.careerbuilder.com/JobInfo.aspx



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/cb/clients/job_api.rb', line 35

def self.find_by_criteria(criteria)
  my_api = Cb::Utils::Api.new()
  params = my_api.class.criteria_to_hash(criteria)

  cb_response = my_api.cb_get(Cb.configuration.uri_job_find, :query => params)
  json_hash = JSON.parse(cb_response.response.body)
  job = CbJob.new(json_hash['ResponseJob']['Job'])
  my_api.append_api_responses(job, json_hash['ResponseJob'])

  return job
end

.find_by_did(did) ⇒ Object



47
48
49
50
51
# File 'lib/cb/clients/job_api.rb', line 47

def self.find_by_did(did)
  criteria = Cb::JobDetailsCriteria.new()
  criteria.did = did
  return find_by_criteria(criteria)
end

.search(*args) ⇒ Object

Run a job search against the given criteria

For detailed information around this API please visit: http://api.careerbuilder.com/JobSearchInfo.aspx



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cb/clients/job_api.rb', line 12

def self.search(*args)
    args = args[0] if args.is_a?(Array) && args.count == 1
    my_api = Cb::Utils::Api.new()
    cb_response = my_api.cb_get(Cb.configuration.uri_job_search, :query => args)
    json_hash = JSON.parse(cb_response.response.body)

    jobs = []
    unless json_hash['ResponseJobSearch']['Results'].nil?
      json_hash['ResponseJobSearch']['Results']['JobSearchResult'].each do | cur_job |
        jobs << CbJob.new(cur_job)
      end
    end
    my_api.append_api_responses(jobs, json_hash['ResponseJobSearch'])

    return jobs
end