Class: JIRA::Resource::Board

Inherits:
Base
  • Object
show all
Defined in:
lib/jira/resource/board.rb

Constant Summary

Constants inherited from Base

Base::QUERY_PARAMS_FOR_SEARCH, Base::QUERY_PARAMS_FOR_SINGLE_FETCH

Instance Attribute Summary

Attributes inherited from Base

#attrs, #client, #deleted, #expanded

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

belongs_to, belongs_to_relationships, build, collection_attributes_are_nested, collection_path, #collection_path, #delete, endpoint_name, #fetch, #has_errors?, has_many, has_one, #id, #initialize, key_attribute, #key_value, #method_missing, nested_collections, #new_record?, parse_json, #patched_url, #path_component, #respond_to?, #save, #save!, #set_attrs, #set_attrs_from_response, singular_path, #to_json, #to_s, #to_sym, #url

Constructor Details

This class inherits a constructor from JIRA::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class JIRA::Base

Class Method Details

.all(client) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# 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 = {}) ⇒ Object



27
28
29
30
31
# 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

Instance Method Details

#add_issue_to_backlog(issue) ⇒ Object



76
77
78
# 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 = {}) ⇒ Object



49
50
51
52
53
54
# 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 = {}) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# 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

#projectObject



70
71
72
73
74
# 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 = {}) ⇒ Object

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


60
61
62
63
64
65
66
67
68
# 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