Class: TaskMapper::Provider::Bugherd::Ticket

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

Overview

Ticket class for taskmapper-bugherd

Constant Summary collapse

API =

The class to access the api’s tickets

BugherdAPI::Task
STATUS =
%w{new todo active declined fixed closed}
PRIORITY =
%w{- critical important normal minor}

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*object) ⇒ Ticket

declare needed overloaded methods here



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/provider/ticket.rb', line 12

def initialize(*object)
  if object.first
    object = object.first
    @system_data = {:client => object}
    unless object.is_a? Hash
      hash = {:id => object.id,
              :status_id => object.status_id,
              :priority_id => object.priority_id,
              :assigned_to_id => object.assigned_to_id,
              :created_at => object.created_at,
              :updated_at => object.updated_at,
              :description => object.description}
    else
      hash = object
    end
    super hash
  end
end

Class Method Details

.search(project_id, options = {}, limit = 1000) ⇒ Object



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

def self.search(project_id, options = {}, limit= 1000) 
  API.find(:all, :params => {:project_id => project_id}).map do |task|
    self.new task
  end
end

Instance Method Details

#assigneeObject



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

def assignee
  user = BugherdAPI::User.find(:all).select do |bugherd_user|
    bugherd_user.id == self[:assigned_to_id]
  end.first
  "#{user.name} #{user.surname}"
end

#priorityObject



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

def priority
  self[:priority_id].nil? ? "" : PRIORITY[self[:priority_id]]
end

#project_idObject



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

def project_id
  self.system_data[:client].prefix_options[:project_id]
end

#statusObject



31
32
33
# File 'lib/provider/ticket.rb', line 31

def status
  STATUS[self[:status_id]]
end