Class: BugherdClient::Resources::V2::Task

Inherits:
Base
  • Object
show all
Defined in:
lib/bugherd_client/resources/v2/task.rb

Constant Summary collapse

PRIORITIES =
['not set', 'critical', 'important', 'normal','minor']
STATUSES =
['backlog','todo','doing','done','closed']
VALID_QUERY_KEYS =
[:page, :updated_since, :created_since, :status, :priority, :assigned_to_id, :external_id]

Constants inherited from Base

Base::DEFAULT_HEADER_ATTRS

Instance Attribute Summary

Attributes inherited from Base

#connection, #options

Instance Method Summary collapse

Methods inherited from Base

#api_methods, #converter, #initialize, #parse_response, #send_request

Constructor Details

This class inherits a constructor from BugherdClient::Resources::V2::Base

Instance Method Details

#all(project_id, filter_attributes = {}) ⇒ Object

Get a full list of tasks for a project, including archived tasks. filters: updated_since, created_since, status, priority, tag,

assigned_to_id, and external_id.

example:

client.tasks.all(45, { status: ‘backlog’ })



30
31
32
33
34
35
# File 'lib/bugherd_client/resources/v2/task.rb', line 30

def all(project_id, filter_attributes={})
  params = filter_attributes.empty? ? {} : { params: filter_attributes }
  validate_filter_attributes!(filter_attributes) unless filter_attributes.empty?
  raw_response = get_request("projects/#{project_id}/tasks", params)
  parse_response(raw_response, :tasks)
end

#create(project_id, attributes = {}) ⇒ Object

Create a new Task attributes:

description, priority, status, tag_names(Array),
requester_id or requester_email,
assigned_to_id or assigned_to_email
external_id

if status is null the Task is automatically put in the Feedback panel ‘requester_email’ can be any email address while ‘assigned_to_email’ needs to be of a current project member. Values for ‘priority’ are not set, critical, important, normal, and minor. Values for ‘status’ are backlog, todo, doing, done, and closed. Omit this field or set as ‘null’ to send tasks to the Feedback panel. External ID is an API-only field. It cannot be set from the BugHerd application, only using the API. An external ID can be used to track originating IDs from other systems in BugHerd bugs.



57
58
59
60
# File 'lib/bugherd_client/resources/v2/task.rb', line 57

def create(project_id, attributes={})
  raw_response = post_request("projects/#{project_id}/tasks", task: attributes)
  parse_response(raw_response, :task)
end

#find(project_id, task_id) ⇒ Object

List details of a task in a given project, includes all data including comments, attachments, etc.



40
41
42
43
# File 'lib/bugherd_client/resources/v2/task.rb', line 40

def find(project_id, task_id)
  raw_response = get_request("projects/#{project_id}/tasks/#{task_id}")
  parse_response(raw_response, :task)
end

#prioritiesObject



9
10
11
# File 'lib/bugherd_client/resources/v2/task.rb', line 9

def priorities
  self.class::PRIORITIES
end

#statusesObject



15
16
17
# File 'lib/bugherd_client/resources/v2/task.rb', line 15

def statuses
  self.class::STATUSES
end

#update(project_id, task_id, attributes = {}) ⇒ Object



62
63
64
65
# File 'lib/bugherd_client/resources/v2/task.rb', line 62

def update(project_id, task_id, attributes={})
  raw_response = put_request("projects/#{project_id}/tasks/#{task_id}", task: attributes)
  parse_response(raw_response, :task)
end