Class: TaskMapper::Provider::Zendesk::Ticket

Inherits:
Base::Ticket
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(*object) ⇒ Ticket

Returns a new instance of Ticket.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/provider/ticket.rb', line 10

def initialize(*object) 
  @system_data = {}
  @cache = {}
  first = object.shift
  case first 
  when Hash
    super first.to_hash
  else
    @system_data[:client] = first
    super first.attributes
  end
end

Class Method Details

.create(options) ⇒ Object



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

def create(options)
  super translate options, {:title => :description}
end

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



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

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

.find_by_id(project_id, ticket_id) ⇒ Object



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

def find_by_id(project_id, ticket_id)
  self.new zendesk_ticket(ticket_id).attributes.merge! :project_id => project_id
end

.search(project_id) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/provider/ticket.rb', line 40

def search(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.attributes.merge! :project_id => project_id
  end
end

Instance Method Details

#created_atObject



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

def created_at
  Time.parse(self[:created_at])
end

#idObject



23
24
25
# File 'lib/provider/ticket.rb', line 23

def id 
  self.nice_id
end

#titleObject



27
28
29
# File 'lib/provider/ticket.rb', line 27

def title
  self.subject
end

#updated_atObject



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

def updated_at
  Time.parse(self[:updated_at])
end