lib/careerbuilder/job.rb in careerbuilder-0.1.3 vs lib/careerbuilder/job.rb in careerbuilder-0.1.4
- old
+ new
@@ -7,23 +7,33 @@
end
def self.search(params)
results = Careerbuilder::Utils::Request.get(params)
- results[:jobs].map do |data|
- job = Careerbuilder::Job.new
- job.data = data
- job
+ unless results[:error] do
+ jobs = results[:jobs].map do |data|
+ job = Careerbuilder::Job.new
+ job.data = data
+ job
+ end
+ else
+ puts results[:error]
+ jobs = []
end
end
def self.find(id)
results = Careerbuilder::Utils::Request.get({job_id: id})
- if results[:jobs_count] && results[:jobs_count] > 0
- job = Careerbuilder::Job.new
- job.data = results[:jobs][0]
+ unless results[:error]
+ if results[:jobs_count] && results[:jobs_count] > 0
+ job = Careerbuilder::Job.new
+ job.data = results[:jobs][0]
+ else
+ job = nil
+ end
else
+ puts results[:error]
job = nil
end
job
end
end