Class: TicketMaster::Provider::Fogbugz::Ticket

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

Overview

Ticket class for ticketmaster-fogbugz

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*object) ⇒ Ticket

API = Fogbugz::Ticket # The class to access the api’s tickets declare needed overloaded methods here



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

def initialize(*object)
  if object.first
    object = object.first
    unless object.is_a? Hash
      @system_data = {:client => object}
      hash = {:id => object['ixBug'],
        :title => object['sTitle'],
        :description => object['sLatestTextSummary'], 
        :status => object['sStatus'],
        :project_id => object['ixProject'],
        :resolution => nil, 
        :requestor => nil,
        :priority => object['sPriority'],
        :assignee => object['sPersonAssignedTo'],
        :created_at => nil,
        :updated_at => object['dtLastUpdated']}
    else
      hash = object
    end
    super(hash)
  end
end

Class Method Details

.create(attributes_hash) ⇒ Object



95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/provider/ticket.rb', line 95

def self.create(attributes_hash)
  warn "Fogbugz Case doesn't not handle description'" if attributes_hash.has_key? :description
  
  options = translate attributes_hash, 
    :title => :sTitle,
    :priority => :ixPriority,
    :assignee => :ixPersonAssignedTo,
    :project_id => :ixProject
  
  new_case = TicketMaster::Provider::Fogbugz.api.command(:new, options)
          
  self.new options.merge :ixBug => new_case["case"]["ixBug"]
end

.find(project_id, options) ⇒ Object



113
114
115
116
117
118
119
120
121
122
123
# File 'lib/provider/ticket.rb', line 113

def self.find(project_id, options)
  if options.first.is_a? Array
    self.find_all(project_id).select do |ticket|
      options.first.any? { |id| ticket.id == id }
    end
  elsif options.first.is_a? Hash
    self.find_by_attributes(project_id, options.first)
  else
    self.find_all(project_id)
  end
end

.find_all(project_id) ⇒ Object



133
134
135
136
137
138
139
# File 'lib/provider/ticket.rb', line 133

def self.find_all(project_id)
  tickets = []
  TicketMaster::Provider::Fogbugz.api.command(:search, :q => "project:=#{project_id}", :cols =>"dtLastUpdated,ixBug,sStatus,sTitle,sLatestTextSummary,ixProject,sProject,sPersonAssignedTo,sPriority").each do |ticket|
    tickets << ticket[1]["case"]
  end
  tickets.flatten.map { |xticket| self.new xticket }
end

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



129
130
131
# File 'lib/provider/ticket.rb', line 129

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

.find_by_id(project_id, id) ⇒ Object



125
126
127
# File 'lib/provider/ticket.rb', line 125

def self.find_by_id(project_id, id)
  self.find_all(project_id).select { |ticket| ticket.id == id }.first
end

Instance Method Details

#assigneeObject



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

def assignee
  self['sPersonAssignedTo']
end

#comment(*options) ⇒ Object



90
91
92
93
# File 'lib/provider/ticket.rb', line 90

def comment(*options)
  nil
  warn "Fogbugz API doesn't support comments"
end

#comments(*options) ⇒ Object



85
86
87
88
# File 'lib/provider/ticket.rb', line 85

def comments(*options)
  []
  warn "Fogbugz API doesn't support comments"
end

#created_atObject



73
74
75
# File 'lib/provider/ticket.rb', line 73

def created_at
  nil
end

#descriptionObject



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

def description 
  self['LatestTextSummary']
end

#idObject



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

def id
  self['ixBug'].to_i
end

#priorityObject



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

def priority
  self['sPriority']
end

#project_idObject



49
50
51
# File 'lib/provider/ticket.rb', line 49

def project_id
  self['ixProject'].to_i
end

#requestorObject



61
62
63
# File 'lib/provider/ticket.rb', line 61

def requestor
  nil
end

#resolutionObject



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

def resolution
  nil
end

#saveObject



109
110
111
# File 'lib/provider/ticket.rb', line 109

def save
  !update_case.has_key?("error")  
end

#statusObject



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

def status
  self['sStatus']
end

#titleObject



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

def title
  self['sTitle']
end

#title=(val) ⇒ Object



41
42
43
# File 'lib/provider/ticket.rb', line 41

def title=(val)
  self['sTitle'] = val
end

#updated_atObject



81
82
83
# File 'lib/provider/ticket.rb', line 81

def updated_at
  Time.parse(self['dtLastUpdated'])
end