Module: HawatelSearchJobs::Api::Reed
- Extended by:
- Helpers::Base
- Defined in:
- lib/hawatel_search_jobs/api/reed.rb
Overview
Reed.co.uk API
Constant Summary collapse
- DEFAULT =
{ :keywords => '', :location => '', }
- RESULT_LIMIT =
25
Class Method Summary collapse
-
.page(args) ⇒ Hash
Get a specific page result At the beging you have to run Reed.search method and get :key from result and pass it to the argument :query_key.
-
.search(args) ⇒ Hash
Search jobs by specific criteria.
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
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/hawatel_search_jobs/api/reed.rb', line 68 def page(args) page = args[:page].to_i || 0 page_size = args[:settings][:page_size].to_s.empty? ? RESULT_LIMIT : args[:settings][:page_size].to_i page_size = RESULT_LIMIT if page_size <= 0 || page_size > 100 if args[:query_key] #limit = result_limit(args[:query_key]) url_request = args[:query_key].gsub(/&resultsToSkip=\d+/, '') << "&resultsToSkip=#{page * page_size}" args[:query_key] = url_request search(args) end end |
.search(args) ⇒ Hash
Search jobs by specific criteria
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/hawatel_search_jobs/api/reed.rb', line 38 def search(args) args[:query] = DEFAULT.merge(args[:query]) if args[:query] args[:page_size] = args[:settings][:page_size].to_s.empty? ? RESULT_LIMIT : args[:settings][:page_size].to_i args[:page_size] = RESULT_LIMIT if args[:page_size] <= 0 || args[:page_size] > 100 if args[:query_key].nil? url_request = prepare_conn_string(args) + prepare_query(args) else url_request = args[:query_key] end response = api_request(url_request, args[:settings][:clientid]) attributes = build_jobs_table(response, url_request, args[:page_size]) OpenStruct.new(attributes) end |