Module: HawatelSearchJobs::Api::Upwork
- Extended by:
- Helpers::Base
- Defined in:
- lib/hawatel_search_jobs/api/upwork.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
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/hawatel_search_jobs/api/upwork.rb', line 56 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 = send_request({:keywords => args[:query_key], :offset => args[:page]*page_size, :settings => args[:settings], :page_size => page_size}) if result['error'] error_handling(result) else set_attributes({:result => result, :page => args[:page], :keywords => args[:query_key], :page_size => page_size}) end end |
.search(args) ⇒ Hash<OpenStruct>
Search jobs based on specified keywords
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/hawatel_search_jobs/api/upwork.rb', line 31 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['error'] error_handling(result) else set_attributes({:result => result, :page => 0, :keywords => keywords, :page_size => page_size}) end end |