Sha256: b1b0dd5a7ef874020bdeba4732c90ede30e6d8d9d9b487a9eb98e868125c4061

Contents?: true

Size: 936 Bytes

Versions: 3

Compression:

Stored size: 936 Bytes

Contents

# encoding: utf-8
module Jiralicious
  ##
  # Provides the interface to access the JQL search functionality.
  # Uses the same syntax as Rest interface for JQL criteria.
  #
  def search(jql, options = {})
    options[:start_at] ||= 0
    options[:max_results] ||= 50
    options[:fields] = [options[:fields]] if options[:fields].is_a? String
    options[:fields] ||= ["*navigable"]

    request_body = {
      :jql => jql,
      :startAt => options[:start_at],
      :maxResults => options[:max_results],
      :fields => options[:fields]
    }.to_json

    handler = Proc.new do |response|
      if response.code == 200
        Jiralicious::SearchResult.new(response)
      else
        raise Jiralicious::JqlError.new(response['errorMessages'].join('\n'))
      end
    end

    Jiralicious.session.request(
      :post,
      "#{Jiralicious.rest_path}/search",
      :body => request_body,
      :handler => handler
    )
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jiralicious-0.3.0 lib/jiralicious/search.rb
jiralicious-0.2.2 lib/jiralicious/search.rb
jiralicious-0.2.1 lib/jiralicious/search.rb