Class: TicketMaster::Provider::Zendesk::Ticket
- Inherits:
-
Base::Ticket
- Object
- Base::Ticket
- TicketMaster::Provider::Zendesk::Ticket
- Defined in:
- lib/provider/ticket.rb
Constant Summary collapse
- SEARCH_API =
declare needed overloaded methods here
ZendeskAPI::Search
- API =
ZendeskAPI::Ticket
- USER_API =
ZendeskAPI::User
Class Method Summary collapse
- .find(project_id, *options) ⇒ Object
- .find_all(*options) ⇒ Object
- .find_by_attributes(project_id, attributes = {}) ⇒ Object
- .find_by_id(project_id, ticket_id) ⇒ Object
Instance Method Summary collapse
- #comment(*options) ⇒ Object
- #comments(*options) ⇒ Object
- #created_at ⇒ Object
-
#initialize(*object) ⇒ Ticket
constructor
A new instance of Ticket.
- #updated_at ⇒ Object
Constructor Details
#initialize(*object) ⇒ Ticket
Returns a new instance of Ticket.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/provider/ticket.rb', line 12 def initialize(*object) return super(object.first) if object.first.is_a? Hash if object.first args = object.first object = args.shift project_id = args.shift @system_data = {:client => object} unless object.is_a? Hash hash = {:id => object.nice_id, :status => object.status_id, :title => object.subject, :created_at => object.created_at, :updated_at => object.updated_at, :description => object.description, :assignee => object.assignee_id, :requestor => object.requester_id, :priority => object.priority_id, :project_id => project_id} else hash = object end super hash end end |
Class Method Details
.find(project_id, *options) ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/provider/ticket.rb', line 45 def self.find(project_id, *) tickets = self.find_all(project_id) if [0].first.is_a? Array Ticket.find_all(self.name).select { |ticket| ticket if [0].first.any? { |ticket_id| ticket_id == ticket.id }} elsif [0].first.is_a? Hash Ticket.find_by_attributes(self.name, [0].first) else tickets end end |
.find_all(*options) ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/provider/ticket.rb', line 56 def self.find_all(*) project_id = .first 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 |
.find_by_attributes(project_id, attributes = {}) ⇒ Object
69 70 71 |
# File 'lib/provider/ticket.rb', line 69 def self.find_by_attributes(project_id, attributes = {}) search_by_attribute(self.find_all(project_id), attributes) end |
Instance Method Details
#comment(*options) ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/provider/ticket.rb', line 77 def comment(*) if .first.is_a? Fixnum Comment.find(project_id, id, [.first]).first elsif .first.is_a? Hash Comment.find_by_attributes(project_id, id, .first).first end end |
#comments(*options) ⇒ Object
73 74 75 |
# File 'lib/provider/ticket.rb', line 73 def comments(*) Comment.find(project_id, id, ) end |
#created_at ⇒ Object
37 38 39 |
# File 'lib/provider/ticket.rb', line 37 def created_at Time.parse(self[:created_at]) end |
#updated_at ⇒ Object
41 42 43 |
# File 'lib/provider/ticket.rb', line 41 def updated_at Time.parse(self[:updated_at]) end |