Class: DoneDone::IssueTracker

Inherits:
Object
  • Object
show all
Defined in:
lib/donedone/issue_tracker.rb

Constant Summary collapse

HELPER_METHODS =
[:response, :result]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(domain, username, password = nil, options = {}) ⇒ IssueTracker

_debug - print debug messages domain - company’s DoneDone domain username - DoneDone username password - DoneDone password



27
28
29
30
31
# File 'lib/donedone/issue_tracker.rb', line 27

def initialize(domain, username, password=nil, options = {})
  @_debug = options.has_key?(:debug) ? options[:debug] : false
  @_http_helper = options[:http_helper] || DoneDone::Http.new(domain, username, password)
  @response = nil
end

Instance Attribute Details

#responseObject (readonly)

Provide access to the DoneDone IssueTracker API. See www.getdonedone.com/api for complete documentation for the API.



16
17
18
# File 'lib/donedone/issue_tracker.rb', line 16

def response
  @response
end

Class Method Details

.api_methodsObject



8
9
10
# File 'lib/donedone/issue_tracker.rb', line 8

def self.api_methods
  instance_methods(false) - HELPER_METHODS
end

Instance Method Details

#create_comment(project_id, order_number, comment, options = {}) ⇒ Object

Create Comment on issue project_id - project id issue_id - issue id comment - comment string people_to_cc_ids - a string of people to be CCed on this comment, delimited by comma attachments - list of absolute file path.



132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/donedone/issue_tracker.rb', line 132

def create_comment(project_id, order_number, comment, options={})
  people_to_cc_ids=options[:people_to_cc_ids]
  attachments=options[:attachments]

  data = {'comment' => comment}
  data['people_to_cc_ids']= people_to_cc_ids if people_to_cc_ids

  params = {:data => data, :update => false, :post => true}
  params[:attachments] = attachments if attachments
  api Constant.url_for('COMMENT', project_id, order_number), params
  !result.empty? ? result["CommentURL"] : nil
end

#create_issue(project_id, title, priority_id, resolver_id, tester_id, options = {}) ⇒ Object

Create Issue project_id - project id title - required title. priority_id - priority levels resolver_id - person assigned to solve this issue tester_id - person assigned to test and verify if a issue is resolved description - optional description of the issue tags - a string of tags delimited by comma watcher_id - a string of people’s id delimited by comma attachments - list of file paths



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/donedone/issue_tracker.rb', line 102

def create_issue( project_id, title, priority_id, resolver_id, tester_id, options={})
  description=options[:description]
  tags=options[:tags]
  watcher_id=options[:watcher_id]
  attachments=options[:attachments]

  data = {
    'title' => title,
    'priority_level_id' => priority_id,
    'resolver_id' => resolver_id,
    'tester_id' => tester_id,
  }

  data['description'] = description if description
  data['tags'] = tags if tags
  data['watcher_ids'] = watcher_id if watcher_id

  params = {:data => data, :update => false, :post => true}
  params[:attachments] = attachments if attachments
  api Constant.url_for('CREATE_ISSUE', project_id), params
  !result.empty? ? result["IssueID"] : nil
end

#issue(project_id, issue_id) ⇒ Object

Note: You can use this to check if an issue exists as well, since it will return a 404 if the issue does not exist.



82
83
84
# File 'lib/donedone/issue_tracker.rb', line 82

def issue(project_id, issue_id)
  api Constant.url_for('ISSUE', project_id, issue_id)
end

#issue_exist?(project_id, issue_id) ⇒ Boolean

Check if an issue exists project_id - project id issue_id - issue id

Returns:

  • (Boolean)


66
67
68
69
# File 'lib/donedone/issue_tracker.rb', line 66

def issue_exist?(project_id, issue_id)
  api Constant.url_for('DOES_ISSUE_EXIST', project_id, issue_id)
  !result.empty? ? result["IssueExists"] : false
end

#issues_in_project(project_id) ⇒ Object

Get all issues in a project project_id - project id



59
60
61
# File 'lib/donedone/issue_tracker.rb', line 59

def issues_in_project project_id
  api Constant.url_for('ISSUES_IN_PROJECT', project_id)
end

#people_for_issue_assignment(project_id, issue_id) ⇒ Object

Get a list of people that cane be assigend to an issue



87
88
89
# File 'lib/donedone/issue_tracker.rb', line 87

def people_for_issue_assignment(project_id, issue_id)
  api Constant.url_for('PEOPLE_FOR_ISSUE_ASSIGNMENT', project_id, issue_id)
end

#people_in_project(project_id) ⇒ Object

Get all people in a project project_id - project id



53
54
55
# File 'lib/donedone/issue_tracker.rb', line 53

def people_in_project project_id
  api Constant.url_for('PEOPLE_IN_PROJECT', project_id)
end

#potential_statuses_for_issue(project_id, issue_id) ⇒ Object

Get potential statuses for issue Note: If you are an admin, you’ll get both all allowed statuses as well as ALL statuses back from the server project_id - project id issue_id - issue id



76
77
78
# File 'lib/donedone/issue_tracker.rb', line 76

def potential_statuses_for_issue( project_id, issue_id)
  api Constant.url_for('POTENTIAL_STATUSES_FOR_ISSUE', project_id, issue_id)
end

#priority_levelsObject

Get priority levels



47
48
49
# File 'lib/donedone/issue_tracker.rb', line 47

def priority_levels
  api Constant.url_for('PRIORITY_LEVELS')
end

#projects(load_with_issues = false) ⇒ Object

Get all Projects with the API enabled load_with_issues - Passing true will deep load all of the projects as well as all of their active issues.



41
42
43
44
# File 'lib/donedone/issue_tracker.rb', line 41

def projects(load_with_issues=false)
  url = load_with_issues ? Constant.url_for('PROJECTS_WITH_ISSUES') : Constant.url_for('PROJECTS')
  api url
end

#resultObject



33
34
35
# File 'lib/donedone/issue_tracker.rb', line 33

def result
  response ?  JSON.parse( response.body ) : ""
end

#update_issue(project_id, order_number, options = {}) ⇒ Object

project_id - project id order_number - issue id title - required title priority_id - priority levels resolver_id - person assigned to solve this issue tester_id - person assigned to test and verify if a issue is resolved description - optional description of the issue tags - a string of tags delimited by comma state_id - a valid state that this issue can transition to attachments - list of file paths



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/donedone/issue_tracker.rb', line 166

def update_issue(project_id, order_number, options={})
  title=options[:title]
  priority_id=options[:priority_id]
  resolver_id=options[:resolver_id]
  tester_id=options[:tester_id]
  description=options[:description]
  tags=options[:tags]
  state_id=options[:state_id]
  attachments=options[:attachments]

  data = {}
  data['title'] = title if title
  data['priority_level_id'] = priority_id if priority_id
  data['resolver_id'] = resolver_id if resolver_id

  data['tester_id'] = tester_id if tester_id
  data['description'] = description if description
  data['tags'] = tags if tags
  data['state_id'] = state_id if state_id

  params = {:update => true}
  params[:data] = data unless data.empty?
  params[:attachments] = attachments if attachments
  api Constant.url_for('ISSUE', project_id, order_number), params
  !result.empty? ? result["IssueURL"] : nil
end