Class: Fiddler::Ticket

Inherits:
Object
  • Object
show all
Defined in:
lib/fiddler/ticket.rb

Constant Summary collapse

DefaultAttributes =
%w(queue owner creator subject status priority initial_priority final_priority requestors cc admin_cc created starts started due resolved told last_updated time_estimated time_worked time_left text).inject({}){|memo, k| memo[k] = nil; memo}
RequiredAttributes =
%w(queue subject)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Ticket

Initializes a new instance of ticket object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fiddler/ticket.rb', line 12

def initialize(attributes={})
   if attributes
      @attributes = DefaultAttributes.merge(attributes)
   else
      @attributes = DefaultAttributes
   end
   @attributes.update(:id => 'ticket/new')
   @saved = false
   @histories = []  
   @new_record = true
   add_methods!
end

Instance Attribute Details

#historiesObject (readonly)

Returns the value of attribute histories.



7
8
9
# File 'lib/fiddler/ticket.rb', line 7

def histories
  @histories
end

#savedObject (readonly)

Returns the value of attribute saved.



7
8
9
# File 'lib/fiddler/ticket.rb', line 7

def saved
  @saved
end

Class Method Details

.all(conditions = {}) ⇒ Object

Search the tickets with the given conditions



58
59
60
61
62
# File 'lib/fiddler/ticket.rb', line 58

def all(conditions={})
   url = "search/ticket"
   response = Fiddler::ConnectionManager.get(url,Fiddler::Formatters::SearchRequestFormatter.format(conditions))
   ticket = Fiddler::Parsers::TicketParser.parse_multiple(response)
end

.create(options) ⇒ Object

Creates a new ticket with the given options, it will not save the ticket



68
69
# File 'lib/fiddler/ticket.rb', line 68

def create(options)
end

.find(options = {}) ⇒ Object

Find the tickets with the given options



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

def find(options={})
end

.get(id) ⇒ Object

Gets the ticket with given id



48
49
50
51
52
# File 'lib/fiddler/ticket.rb', line 48

def get(id)
   url = "ticket/#{id}"
   response = Fiddler::ConnectionManager.get(url)
   ticket = Fiddler::Parsers::TicketParser.parse_single(response)
end

.saveObject

Saves the changes to the ticket object



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

def save
end

Instance Method Details

#add_methods!Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/fiddler/ticket.rb', line 25

def add_methods!
   @attributes.each do |key, value|
      (class << self; self; end).send :define_method, key do
         return @attributes[key]
      end
      (class << self; self; end).send :define_method, "#{key}=" do |new_val|
         @attributes[key] = new_val
      end
   end
end

#descriptionObject



36
37
38
39
40
# File 'lib/fiddler/ticket.rb', line 36

def description
   @attributes.each do |key,value|
      puts "#{key} = #{value}"
   end
end