Module: HawatelSearchJobs::Api::Xing
- Extended by:
- Helpers::Base
- Defined in:
- lib/hawatel_search_jobs/api/xing.rb
Constant Summary collapse
- DEFAULT =
{ :keywords => '', :location => '', :company => '' }
- RESULT_LIMIT =
25
Class Method Summary collapse
-
.page(args) ⇒ Hash<OpenStruct>
Show next page of results.
-
.search(args) ⇒ Hash<OpenStruct>
Search jobs based on specified keywords.
Class Method Details
.page(args) ⇒ Hash<OpenStruct>
Show next page of results
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/hawatel_search_jobs/api/xing.rb', line 57 def page(args) args[:page] = 0 if args[:page].nil? 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 result = XingApi::Job.search(args[:query_key], {:limit => page_size, :offset => args[:page]*page_size}) set_attributes({:result => result, :page => args[:page], :keywords => args[:query_key], :page_size => page_size}) rescue XingApi::Error => e {:code => e.status_code, :msg => e.text} end |
.search(args) ⇒ Hash<OpenStruct>
Search jobs based on specified keywords
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/hawatel_search_jobs/api/xing.rb', line 32 def search(args) args[:query] = DEFAULT.merge(args[:query]) if args[:query] keywords = args[:query][:keywords] 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 result = send_request({:keywords => keywords, :offset => 0, :settings => args[:settings], :page_size => page_size}) if !result[:code] set_attributes({:result => result, :page => 0, :keywords => keywords, :page_size => page_size}) else OpenStruct.new({:code => 501, :msg => 'incorrect settings'}) end end |