Class: Fiddler::Ticket
- Inherits:
-
Object
- Object
- Fiddler::Ticket
- Includes:
- ActiveAttr::Model
- Defined in:
- lib/fiddler/ticket.rb
Class Method Summary collapse
-
.all(conditions = {}) ⇒ Object
Search the tickets with the given conditions.
-
.create(options) ⇒ Object
Creates a new ticket with the given options, it will not save the ticket.
-
.get(id) ⇒ Object
Gets the ticket with given id.
Instance Method Summary collapse
-
#comment(comment, opt = {}) ⇒ Object
Add a comment to a ticket Example: tix = Ticket.get(1000) tix.comment(“This is a comment”, :time_worked => 45, :cc => ‘[email protected]’).
- #correspond(comment, opt = {}) ⇒ Object
- #histories ⇒ Object
-
#requestor_array ⇒ Object
make the setting and getting of requestors easier.
- #requestor_array=(requestor_array) ⇒ Object
- #save ⇒ Object
- #steal ⇒ Object
- #take ⇒ Object
- #untake ⇒ Object
Class Method Details
.all(conditions = {}) ⇒ Object
Search the tickets with the given conditions
164 165 166 167 168 169 170 171 172 173 |
# File 'lib/fiddler/ticket.rb', line 164 def all(conditions={}) tickets = [] url = "search/ticket" request_hash = Fiddler::Formatters::SearchRequestFormatter.format(conditions) unless request_hash.empty? response = Fiddler::ConnectionManager.get(url,request_hash) tickets = Fiddler::Parsers::TicketParser.parse_multiple(response) end tickets end |
.create(options) ⇒ Object
Creates a new ticket with the given options, it will not save the ticket
179 180 |
# File 'lib/fiddler/ticket.rb', line 179 def create() end |
.get(id) ⇒ Object
Gets the ticket with given id
153 154 155 156 157 158 |
# File 'lib/fiddler/ticket.rb', line 153 def get(id) url = "ticket/#{id}" response = Fiddler::ConnectionManager.get(url) ticket = Fiddler::Parsers::TicketParser.parse_single(response) ticket end |
Instance Method Details
#comment(comment, opt = {}) ⇒ Object
Add a comment to a ticket Example:
tix = Ticket.get(1000)
tix.comment("This is a comment", :time_worked => 45, :cc => '[email protected]')
Attachments
tix.comment("This is a comment", :attachments => "/tmp/filename.txt")
Attachment as a file descriptor
tix.correspond("This is a comment", :attachments => File.new("/tmp/filename.txt"))
Attachment as a ActionDispatch::Http::UploadedFile instance
tix.comment("This is a comment", :attachments => [params[:attachment_1], params[:attachment_2]])
66 67 68 |
# File 'lib/fiddler/ticket.rb', line 66 def comment(comment, opt = {}) reply('Comment', comment, opt) end |
#correspond(comment, opt = {}) ⇒ Object
70 71 72 |
# File 'lib/fiddler/ticket.rb', line 70 def correspond(comment, opt = {}) reply('Correspond', comment, opt) end |
#histories ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/fiddler/ticket.rb', line 32 def histories if @histories == nil url = "ticket/#{id}/history" response = Fiddler::ConnectionManager.get(url, {:format => "l"}) @histories = Fiddler::Parsers::HistoryParser.parse_multiple(response) end @histories end |
#requestor_array ⇒ Object
make the setting and getting of requestors easier
42 43 44 |
# File 'lib/fiddler/ticket.rb', line 42 def requestor_array self.requestors.split(",").collect { |x| x.strip } end |
#requestor_array=(requestor_array) ⇒ Object
46 47 48 49 50 |
# File 'lib/fiddler/ticket.rb', line 46 def requestor_array=(requestor_array) if requestor_array.is_a?(Array) self.requestors = requestor_array.join(", ") end end |
#save ⇒ Object
86 87 88 |
# File 'lib/fiddler/ticket.rb', line 86 def save id == "ticket/new" ? create : update end |
#steal ⇒ Object
74 75 76 |
# File 'lib/fiddler/ticket.rb', line 74 def steal change_ownership "Steal" end |
#take ⇒ Object
78 79 80 |
# File 'lib/fiddler/ticket.rb', line 78 def take change_ownership "Take" end |
#untake ⇒ Object
82 83 84 |
# File 'lib/fiddler/ticket.rb', line 82 def untake change_ownership "Untake" end |