lib/jiralicious/search.rb in jiralicious-0.0.6 vs lib/jiralicious/search.rb in jiralicious-0.1.0

- old
+ new

@@ -8,19 +8,21 @@ :jql => jql, :startAt => options[:start_at], :maxResults => options[:max_results] }.to_json - response = Jiralicious.session.perform_request do - Jiralicious::Session.post( - "#{Jiralicious.rest_path}/search", - :body => request_body - ) + handler = Proc.new do |response| + if response.code == 200 + Jiralicious::SearchResult.new(response) + else + raise Jiralicious::JqlError.new(response['errorMessages'].join('\n')) + end end - if response.code == 200 - Jiralicious::SearchResult.new(JSON.parse(response.body)) - else - raise Jiralicious::JqlError - end + Jiralicious.session.request( + :post, + "#{Jiralicious.rest_path}/search", + :body => request_body, + :handler => handler + ) end end