Class: TaskMapper::Provider::Bcx::Ticket

Inherits:
TaskMapper::Provider::Base::Ticket
  • Object
show all
Defined in:
lib/provider/ticket.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*object) ⇒ Ticket

Returns a new instance of Ticket.



4
5
6
7
# File 'lib/provider/ticket.rb', line 4

def initialize(*object)
  object = object.first if object.is_a?(Array)
  super object if object.is_a?(Hash)
end

Class Method Details

.create(attributes) ⇒ Object



69
70
71
72
73
# File 'lib/provider/ticket.rb', line 69

def create(attributes)
  todo = api.create_todo attributes
  todo = Hash[todo].merge({:project_id => attributes[:project_id]})
  self.new todo
end

.find_all(project_id) ⇒ Object



56
57
58
59
60
61
# File 'lib/provider/ticket.rb', line 56

def find_all(project_id)
  todos = api.todos project_id
  todos = todos.select { |todo| todo.is_a?(Hash) }
  todos.each { |t| t.merge!({:project_id => project_id})}
  todos.collect { |todo| self.new todo }
end

.find_by_attributes(project_id, attributes = {}) ⇒ Object



52
53
54
# File 'lib/provider/ticket.rb', line 52

def find_by_attributes(project_id, attributes = {})
  search_by_attribute(self.find_all(project_id), attributes)
end

.find_by_id(project_id, ticket_id) ⇒ Object



63
64
65
66
67
# File 'lib/provider/ticket.rb', line 63

def find_by_id(project_id, ticket_id)
  todo = api.todo project_id, ticket_id
  todo = Hash[todo].merge({:project_id => project_id})
  self.new todo
end

Instance Method Details

#closeObject



33
34
35
36
# File 'lib/provider/ticket.rb', line 33

def close
  self[:completed] = true
  save
end

#created_atObject



43
44
45
46
47
48
49
# File 'lib/provider/ticket.rb', line 43

def created_at
  begin
    Time.parse(self[:created_at])
  rescue
    self[:created_at]
  end
end

#descriptionObject



9
10
11
# File 'lib/provider/ticket.rb', line 9

def description
  self[:content]
end

#description=(string) ⇒ Object



13
14
15
# File 'lib/provider/ticket.rb', line 13

def description=(string)
  self[:content] = string
end

#reopenObject



38
39
40
41
# File 'lib/provider/ticket.rb', line 38

def reopen
  self[:completed] = false
  save
end

#saveObject



29
30
31
# File 'lib/provider/ticket.rb', line 29

def save
  api.update_todo self
end

#statusObject



17
18
19
# File 'lib/provider/ticket.rb', line 17

def status
  self[:completed] ? 'closed' : 'open'
end

#updated_atObject



21
22
23
24
25
26
27
# File 'lib/provider/ticket.rb', line 21

def updated_at
  begin
    Time.parse(self[:updated_at])
  rescue
    self[:updated_at]
  end
end