Class: TaskMapper::Provider::Basecamp::Ticket
- Inherits:
-
TaskMapper::Provider::Base::Ticket
- Object
- TaskMapper::Provider::Base::Ticket
- TaskMapper::Provider::Basecamp::Ticket
- Defined in:
- lib/provider/ticket.rb
Overview
Ticket class for taskmapper-basecamp
-
status => completed (either completed or incomplete)
-
priority => position
-
title => TodoList#name - TodoItem#content (up to 100 characters)
-
resolution => completed (either completed or ”)
-
updated_at => completed_on
-
description => content
-
assignee => responsible_party_name (read-only)
-
requestor => creator_name (read-only)
-
project_id
Class Method Summary collapse
-
.create(attributes_hash) ⇒ Object
It expects a single hash.
- .find_by_attributes(project_id, attributes = {}) ⇒ Object
- .find_by_id(project_id, id) ⇒ Object
- .search(project_id, options = {}, limit = 1000) ⇒ Object
Instance Method Summary collapse
- #assignee ⇒ Object
- #comment!(attributes) ⇒ Object
- #copy_to(todo_item) ⇒ Object
- #description ⇒ Object
- #description=(desc) ⇒ Object
-
#initialize(*options) ⇒ Ticket
constructor
A new instance of Ticket.
- #priority ⇒ Object
- #priority=(pri) ⇒ Object
- #requestor ⇒ Object
- #save ⇒ Object
- #status ⇒ Object
- #title ⇒ Object
- #title=(titl) ⇒ Object
- #todo_list_id ⇒ Object
- #updated_at=(comp) ⇒ Object
Constructor Details
#initialize(*options) ⇒ Ticket
Returns a new instance of Ticket.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/provider/ticket.rb', line 16 def initialize(*) @system_data ||= {} @cache ||= {} first = .first case first when Hash super(first.to_hash) else @system_data[:client] = first super(first.attributes) end end |
Class Method Details
.create(attributes_hash) ⇒ Object
It expects a single hash
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/provider/ticket.rb', line 45 def create(attributes_hash) todo_item_hash = create_todo_item_hash attributes_hash todo_item = create_todo_item todo_item_hash return nil unless todo_item.save todo_item.project_id = attributes_hash[:project_id] todo_item.todo_list_id = todo_item_hash[:todo_list_id] self.new(todo_item) end |
.find_by_attributes(project_id, attributes = {}) ⇒ Object
35 36 37 |
# File 'lib/provider/ticket.rb', line 35 def find_by_attributes(project_id, attributes = {}) search(project_id, attributes) end |
.find_by_id(project_id, id) ⇒ Object
31 32 33 |
# File 'lib/provider/ticket.rb', line 31 def find_by_id(project_id, id) find_by_attributes(project_id, {:id => id}).first end |
.search(project_id, options = {}, limit = 1000) ⇒ Object
39 40 41 42 |
# File 'lib/provider/ticket.rb', line 39 def search(project_id, = {}, limit = 1000) tickets = todo_items(project_id).map {|ti| self.new ti.attributes.merge :project_id => project_id } search_by_attribute(tickets, , limit) end |
Instance Method Details
#assignee ⇒ Object
148 149 150 |
# File 'lib/provider/ticket.rb', line 148 def assignee self.responsible_party_name end |
#comment!(attributes) ⇒ Object
156 157 158 |
# File 'lib/provider/ticket.rb', line 156 def comment!(attributes) Comment.create id, attributes end |
#copy_to(todo_item) ⇒ Object
96 97 98 99 100 101 102 103 104 105 |
# File 'lib/provider/ticket.rb', line 96 def copy_to(todo_item) todo_item.completed = status todo_item.position = priority todo_item.name = title todo_item.content = title todo_item.completed = resolution todo_item.responsible_party_name = assignee todo_item.creator_name = requestor todo_item end |
#description ⇒ Object
140 141 142 |
# File 'lib/provider/ticket.rb', line 140 def description self.content end |
#description=(desc) ⇒ Object
144 145 146 |
# File 'lib/provider/ticket.rb', line 144 def description=(desc) self.content = desc end |
#priority ⇒ Object
120 121 122 |
# File 'lib/provider/ticket.rb', line 120 def priority self.position end |
#priority=(pri) ⇒ Object
124 125 126 |
# File 'lib/provider/ticket.rb', line 124 def priority=(pri) self.position = pri end |
#requestor ⇒ Object
152 153 154 |
# File 'lib/provider/ticket.rb', line 152 def requestor self.creator_name end |
#save ⇒ Object
107 108 109 110 |
# File 'lib/provider/ticket.rb', line 107 def save todo_item = BasecampAPI::TodoItem.find id, :params => { :todo_list_id => todo_list_id } copy_to(todo_item).save end |
#status ⇒ Object
116 117 118 |
# File 'lib/provider/ticket.rb', line 116 def status self.completed ? 'completed' : 'incomplete' end |
#title ⇒ Object
128 129 130 |
# File 'lib/provider/ticket.rb', line 128 def title self.content end |
#title=(titl) ⇒ Object
132 133 134 |
# File 'lib/provider/ticket.rb', line 132 def title=(titl) self.content = titl end |
#todo_list_id ⇒ Object
112 113 114 |
# File 'lib/provider/ticket.rb', line 112 def todo_list_id self['todo_list_id'].to_i end |
#updated_at=(comp) ⇒ Object
136 137 138 |
# File 'lib/provider/ticket.rb', line 136 def updated_at=(comp) self.completed_on = comp end |