Module: HawatelSearchJobs::Api::Careerbuilder

Extended by:
Helpers::Base
Defined in:
lib/hawatel_search_jobs/api/careerbuilder.rb

Overview

Carerrbuilder API

Constant Summary collapse

DEFAULT =
{
    :keywords => '',
    :location => '',
    :company  => ''
}
RESULT_LIMIT =
25

Class Method Summary collapse

Class Method Details

.page(args) ⇒ Hash

Get a specific page result At the beging you have to run search method and get :key from result and pass it to the argument :query_key

Examples:

jobs = Careerbuilder.page({:settings => {
                                :api => 'api.careerbuilder.com',
                                :version => 'v2',
                                :clientid => 'secret-code'},
                           :page => 5,
                           :query_key => 'value from :key returned by search method'})

Parameters:

  • args (Hash)

Options Hash (args):

  • :settings (Hash)

    see search

  • :page (Integer)

    page number counted from 0

  • :query_key (String)

Returns:

  • (Hash)

    Job offers from specific page



71
72
73
74
75
76
77
78
# File 'lib/hawatel_search_jobs/api/careerbuilder.rb', line 71

def page(args)
  page = args[:page].to_i || 0
  if args[:query_key]
    url_request = args[:query_key].gsub(/&PageNumber=\d+/, '') << "&PageNumber=#{page+1}"
    args[:query_key] = url_request
    search(args)
  end
end

.search(args) ⇒ Hash

Search jobs by specific criteria

Examples:

jobs = Careerbuilder.search({:settings => {
                                :api => 'api.careerbuilder.com',
                                :version => 'v2',
                                :clientid => 'secret-code'},
                             :query => {
                                :keywords => 'ruby',
                                :location => 'London',
                                :company => ''}})

Parameters:

  • args (Hash)

Options Hash (args):

  • :settings (Hash)

    search criteria

    • :api (String) - URL API (default: api.careerbuilder.com)

    • :version (String) - a version of API (default: v2)

    • :clientid (String) - Private Developer Key (see developer.careerbuilder.com)

  • :query (Hash)

    settings of API

    • :keywors (String)

    • :location (String)

    • :company (String)

Returns:

  • (Hash)

    First page of the result (see constant RESULT_LIMIT)



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/hawatel_search_jobs/api/careerbuilder.rb', line 42

def search(args)
  args[:query] = DEFAULT.merge(args[:query]) if args[:query]

  if args[:query_key].nil?
    url_request = prepare_conn_string(args) + prepare_query(args)
  else
    url_request = args[:query_key]
  end

  response = send_request(url_request)
  attributes = build_jobs_table(response, url_request)
  OpenStruct.new(attributes)
end