lib/provider/ticket.rb in ticketmaster-zendesk-0.1.2 vs lib/provider/ticket.rb in ticketmaster-zendesk-0.2.2

- old
+ new

@@ -5,10 +5,11 @@ class Ticket < TicketMaster::Provider::Base::Ticket # declare needed overloaded methods here SEARCH_API = ZendeskAPI::Search API = ZendeskAPI::Ticket + USER_API = ZendeskAPI::User def initialize(*object) return super(object.first) if object.first.is_a? Hash if object.first args = object.first @@ -52,11 +53,15 @@ end end def self.find_all(*options) project_id = options.first - SEARCH_API.find(:all, :params => {:query => "status:open"}).collect { |ticket| self.new([ticket, project_id])} + SEARCH_API.find(:all, :params => {:query => "status:open"}).collect do |ticket| + ticket.requester_id = requestor(ticket) + ticket.assignee_id = assignee(ticket) + self.new([ticket, project_id]) + end end def self.find_by_id(project_id, ticket_id) self.new [API.find(ticket_id), project_id] end @@ -73,9 +78,18 @@ if options.first.is_a? Fixnum Comment.find(project_id, id, [options.first]).first elsif options.first.is_a? Hash Comment.find_by_attributes(project_id, id, options.first).first end + end + + private + def self.requestor(ticket) + USER_API.find(ticket.requester_id).email + end + + def self.assignee(ticket) + USER_API.find(ticket.assignee_id).email end end end