Class: TicketMaster::Provider::Fogbugz::Ticket
- Inherits:
-
Base::Ticket
- Object
- Base::Ticket
- TicketMaster::Provider::Fogbugz::Ticket
- Defined in:
- lib/provider/ticket.rb
Overview
Ticket class for ticketmaster-fogbugz
Class Method Summary collapse
- .create(attributes_hash) ⇒ Object
- .find(project_id, options) ⇒ Object
- .find_all(project_id) ⇒ Object
- .find_by_attributes(project_id, attributes = {}) ⇒ Object
- .find_by_id(project_id, id) ⇒ Object
Instance Method Summary collapse
- #assignee ⇒ Object
- #comment(*options) ⇒ Object
- #comments(*options) ⇒ Object
- #created_at ⇒ Object
- #description ⇒ Object
- #id ⇒ Object
-
#initialize(*object) ⇒ Ticket
constructor
API = Fogbugz::Ticket # The class to access the api’s tickets declare needed overloaded methods here.
- #priority ⇒ Object
- #project_id ⇒ Object
- #requestor ⇒ Object
- #resolution ⇒ Object
- #save ⇒ Object
- #status ⇒ Object
- #title ⇒ Object
- #title=(val) ⇒ Object
- #updated_at ⇒ Object
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 = translate attributes_hash, :title => :sTitle, :priority => :ixPriority, :assignee => :ixPersonAssignedTo, :project_id => :ixProject new_case = TicketMaster::Provider::Fogbugz.api.command(:new, ) self.new .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, ) if .first.is_a? Array self.find_all(project_id).select do |ticket| .first.any? { |id| ticket.id == id } end elsif .first.is_a? Hash self.find_by_attributes(project_id, .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
#assignee ⇒ Object
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(*) 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(*) [] warn "Fogbugz API doesn't support comments" end |
#created_at ⇒ Object
73 74 75 |
# File 'lib/provider/ticket.rb', line 73 def created_at nil end |
#description ⇒ Object
45 46 47 |
# File 'lib/provider/ticket.rb', line 45 def description self['LatestTextSummary'] end |
#id ⇒ Object
33 34 35 |
# File 'lib/provider/ticket.rb', line 33 def id self['ixBug'].to_i end |
#priority ⇒ Object
65 66 67 |
# File 'lib/provider/ticket.rb', line 65 def priority self['sPriority'] end |
#project_id ⇒ Object
49 50 51 |
# File 'lib/provider/ticket.rb', line 49 def project_id self['ixProject'].to_i end |
#requestor ⇒ Object
61 62 63 |
# File 'lib/provider/ticket.rb', line 61 def requestor nil end |
#resolution ⇒ Object
53 54 55 |
# File 'lib/provider/ticket.rb', line 53 def resolution nil end |
#save ⇒ Object
109 110 111 |
# File 'lib/provider/ticket.rb', line 109 def save !update_case.has_key?("error") end |
#status ⇒ Object
57 58 59 |
# File 'lib/provider/ticket.rb', line 57 def status self['sStatus'] end |
#title ⇒ Object
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_at ⇒ Object
81 82 83 |
# File 'lib/provider/ticket.rb', line 81 def updated_at Time.parse(self['dtLastUpdated']) end |