class JIRA::Resource::Board

Public Class Methods

all(client) click to toggle source
# File lib/jira/resource/board.rb, line 9
def self.all(client)
  path = path_base(client) + '/board'
  response = client.get(path)
  json = parse_json(response.body)
  results = json['values']

  until json['isLast']
    params = { 'startAt' => (json['startAt'] + json['maxResults']).to_s }
    response = client.get(url_with_query_params(path, params))
    json = parse_json(response.body)
    results += json['values']
  end

  results.map do |board|
    client.Board.build(board)
  end
end
find(client, key, _options = {}) click to toggle source
# File lib/jira/resource/board.rb, line 27
def self.find(client, key, _options = {})
  response = client.get(path_base(client) + "/board/#{key}")
  json = parse_json(response.body)
  client.Board.build(json)
end

Private Class Methods

path_base(client) click to toggle source
# File lib/jira/resource/board.rb, line 82
def self.path_base(client)
  client.options[:context_path] + '/rest/agile/1.0'
end

Public Instance Methods

add_issue_to_backlog(issue) click to toggle source
# File lib/jira/resource/board.rb, line 76
def add_issue_to_backlog(issue)
  client.post(path_base(client) + '/backlog/issue', { issues: [issue.id] }.to_json)
end
configuration(params = {}) click to toggle source
# File lib/jira/resource/board.rb, line 49
def configuration(params = {})
  path = path_base(client) + "/board/#{id}/configuration"
  response = client.get(url_with_query_params(path, params))
  json = self.class.parse_json(response.body)
  client.BoardConfiguration.build(json)
end
issues(params = {}) click to toggle source
# File lib/jira/resource/board.rb, line 33
def issues(params = {})
  path = path_base(client) + "/board/#{id}/issue"
  response = client.get(url_with_query_params(path, params))
  json = self.class.parse_json(response.body)
  results = json['issues']

  while (json['startAt'] + json['maxResults']) < json['total']
    params['startAt'] = (json['startAt'] + json['maxResults'])
    response = client.get(url_with_query_params(path, params))
    json = self.class.parse_json(response.body)
    results += json['issues']
  end

  results.map { |issue| client.Issue.build(issue) }
end
project() click to toggle source
# File lib/jira/resource/board.rb, line 70
def project
  response = client.get(path_base(client) + "/board/#{id}/project")
  json = self.class.parse_json(response.body)
  json['values'][0]
end
sprints(options = {}) click to toggle source

options

- state ~ future, active, closed, you can define multiple states separated by commas, e.g. state=active,closed
- maxResults ~ default: 50 (JIRA API), 1000 (this library)
- startAt ~ base index, starts at 0
# File lib/jira/resource/board.rb, line 60
def sprints(options = {})
  # options.reverse_merge!(DEFAULT_OPTIONS)
  response = client.get(path_base(client) + "/board/#{id}/sprint?#{options.to_query}")
  json = self.class.parse_json(response.body)
  json['values'].map do |sprint|
    sprint['rapidview_id'] = id
    client.Sprint.build(sprint)
  end
end

Private Instance Methods

path_base(client) click to toggle source
# File lib/jira/resource/board.rb, line 86
def path_base(client)
  self.class.path_base(client)
end