lib/firstjob_api/publication.rb in firstjob_api-1.0.6 vs lib/firstjob_api/publication.rb in firstjob_api-1.0.7

- old
+ new

@@ -49,21 +49,30 @@ def url "#{FirstjobApi.base_uri}/jobs/#{slug}" end - def postulants + def get_postulants # Get postulants response = FirstjobApi.post("/api/get_applicants_job", FirstjobApi.options.merge( body: FirstjobApi.body.merge({job_id: @id, slug: @slug}).to_json ) ) response_body = HttpParser.parse_json_response(response) # load results - @postulantes = response_body["postulantes"] - return @postulantes + if response_body && response_body["postulaciones"] + @postulantes = response_body["postulaciones"]["postulantes"] + else + # In case the API changes... fallback to response body + @postulantes = response_body + end + return response + end + + def postulants + @postulantes || get_postulants && @postulantes end def destroy response = FirstjobApi.post("/api/doregister_job", FirstjobApi.options.merge(