indeed_api 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/indeed_api/search.rb +33 -0
- data/lib/indeed_api/version.rb +1 -1
- data/lib/indeed_api.rb +4 -4
- metadata +2 -1
@@ -0,0 +1,33 @@
|
|
1
|
+
module IndeedAPI
|
2
|
+
|
3
|
+
class Search
|
4
|
+
|
5
|
+
attr_reader :query, :location, :dupe_filter, :highlight, :total_results,
|
6
|
+
:start, :end, :radius, :page_number, :results
|
7
|
+
|
8
|
+
def initialize(data = {})
|
9
|
+
@query = data['query']
|
10
|
+
@location = data['location']
|
11
|
+
@dupe_filter = data['dupefilter'] == 'true'
|
12
|
+
@highlight = data['highlight'] == 'true'
|
13
|
+
@total_results = data['totalresults'].to_i
|
14
|
+
@start = data['start'].to_i
|
15
|
+
@end = data['end'].to_i
|
16
|
+
@radius = data['radius'].to_i
|
17
|
+
@page_number = data['pageNumber'].to_i
|
18
|
+
# Load the actual results
|
19
|
+
@results = []
|
20
|
+
if results = data['results']
|
21
|
+
if results = results['result']
|
22
|
+
if results.is_a?(Hash)
|
23
|
+
@results << IndeedAPI::Job.new(results)
|
24
|
+
else
|
25
|
+
@results = results.map { |jd| IndeedAPI::Job.new(jd) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
data/lib/indeed_api/version.rb
CHANGED
data/lib/indeed_api.rb
CHANGED
@@ -5,6 +5,7 @@ module IndeedAPI
|
|
5
5
|
|
6
6
|
autoload :IndeedError, File.dirname(__FILE__) + '/indeed_api/indeed_error'
|
7
7
|
autoload :Job, File.dirname(__FILE__) + '/indeed_api/job'
|
8
|
+
autoload :Search, File.dirname(__FILE__) + '/indeed_api/search'
|
8
9
|
|
9
10
|
API_VERSION = 2
|
10
11
|
|
@@ -28,10 +29,9 @@ module IndeedAPI
|
|
28
29
|
response = get('/apisearch', :query => options)
|
29
30
|
handle_errors(response)
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
results.is_a?(Hash) ? [IndeedAPI::Job.new(results)] : results.map { |jd| IndeedAPI::Job.new(jd) }
|
32
|
+
if data = response['response']
|
33
|
+
IndeedAPI::Search.new(data)
|
34
|
+
end
|
35
35
|
end
|
36
36
|
|
37
37
|
# Get an individual job - for convenience
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: indeed_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- John Crepezzi
|
@@ -46,6 +46,7 @@ extra_rdoc_files: []
|
|
46
46
|
files:
|
47
47
|
- lib/indeed_api/indeed_error.rb
|
48
48
|
- lib/indeed_api/job.rb
|
49
|
+
- lib/indeed_api/search.rb
|
49
50
|
- lib/indeed_api/version.rb
|
50
51
|
- lib/indeed_api.rb
|
51
52
|
- spec/spec_helper.rb
|