class DoneDone::IssueTracker

Constants

HELPER_METHODS

Attributes

_debug[R]
_http_helper[R]
response[R]

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

Public Class Methods

api_methods() click to toggle source
# File lib/donedone/issue_tracker.rb, line 8
def self.api_methods
  instance_methods(false) - HELPER_METHODS
end
new(domain, username, password=nil, options = {}) click to toggle source

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

# 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

Public Instance Methods

create_comment(project_id, order_number, comment, options={}) click to toggle source

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.

# 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={}) click to toggle source

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
# 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) click to toggle source

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.

# 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) click to toggle source

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

# 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) click to toggle source

Get all issues in a project project_id - project id

# 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) click to toggle source

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

# 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) click to toggle source

Get all people in a project project_id - project id

# 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) click to toggle source

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

# 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_levels() click to toggle source

Get priority levels

# File lib/donedone/issue_tracker.rb, line 47
def priority_levels
  api Constant.url_for('PRIORITY_LEVELS')
end
projects(load_with_issues=false) click to toggle source

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.

# 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
result() click to toggle source
# File lib/donedone/issue_tracker.rb, line 33
def result
  response ?  JSON.parse( response.body ) : ""
end
update_issue(project_id, order_number, options={}) click to toggle source

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

# 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

Private Instance Methods

api(method_url, options={}) click to toggle source
Perform generic API calling

This is the base method for all IssueTracker API calls.

method_url - IssueTracker method URL
data - optional POST form data
attachemnts - optional list of file paths
update - flag to indicate if this is a PUT operation
# File lib/donedone/issue_tracker.rb, line 202
def api(method_url, options={})
  data = options[:data]
  attachments = options[:attachments]
  update = options.has_key?(:update) ? options[:update] : false
  post = options.has_key?(:post) ? options[:post] : false

  @response = nil
  files = {}
  request_method = nil

  if attachments
    debug { "attachments; using post" }
    request_method = :post
    attachments.each_with_index do |attachment, index|
      files["attachment-#{index}"] = attachment
    end
  else
    request_method = :get
  end

  if update
    debug { "using put" }
    request_method = :put
  end

  if post
    debug { "using post" }
    request_method = :post
  end

  params = { :debug => _debug }
  params[:data] = data if data
  params[:files] = files unless files.empty?

  @response = _http_helper.send(request_method, method_url, params)
  return result
rescue Exception => e
  warn e.message
  warn e.backtrace.inspect
  return ""
end
debug() { || ... } click to toggle source
# File lib/donedone/issue_tracker.rb, line 244
def debug
  puts(yield) if _debug && block_given?
end