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



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/cb/clients/job_api.rb', line 40

def self.find_by_criteria(criteria)
  my_api = Cb::Utils::Api.new()
  params = my_api.class.criteria_to_hash(criteria)
  json_hash = my_api.cb_get(Cb.configuration.uri_job_find, :query => params)

  if json_hash.has_key?('ResponseJob')
    if json_hash['ResponseJob'].has_key?('Job')
      job = CbJob.new(json_hash['ResponseJob']['Job'])
    end
    my_api.append_api_responses(job, json_hash['ResponseJob'])
  end
  my_api.append_api_responses(job, json_hash)

  return job
end

.find_by_did(did) ⇒ Object



56
57
58
59
60
# File 'lib/cb/clients/job_api.rb', line 56

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:



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# 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()
  json_hash = my_api.cb_get(Cb.configuration.uri_job_search, :query => args)

  jobs = Array.new
  if !json_hash['ResponseJobSearch'].nil? && !json_hash['ResponseJobSearch']['Results'].nil?
    job_results = json_hash['ResponseJobSearch']['Results']['JobSearchResult']
    job_results = [job_results] if !job_results.is_a?(Array)
    job_results.each { |job_hash| jobs.push(CbJob.new(job_hash)) }
    my_api.append_api_responses(jobs, json_hash['ResponseJobSearch'])

    if response_has_search_metadata?(json_hash['ResponseJobSearch'])
      my_api.append_api_responses(jobs, json_hash['ResponseJobSearch']['SearchMetaData']['SearchLocations']['SearchLocation'])
    end
  end

  my_api.append_api_responses(jobs, json_hash)

  return jobs
end