class Zendesk2::UpdateTicket
Public Class Methods
accepted_attributes()
click to toggle source
# File lib/zendesk2/update_ticket.rb, line 9 def self.accepted_attributes Zendesk2::CreateTicket.accepted_attributes + ['comment'] end
Public Instance Methods
mock()
click to toggle source
# File lib/zendesk2/update_ticket.rb, line 21 def mock comment = params.fetch('ticket').delete('comment') body = find!(:tickets, ticket_id).merge!(ticket_params) if comment comment_id = cistern.serial_id comment_data = cistern.data[:ticket_comments][comment_id] = { 'id' => comment_id, 'type' => 'Comment', 'author_id' => cistern.current_user['id'], 'body' => comment['body'], 'html_body' => "<p>#{comment['body']}</p>", 'public' => comment['public'].nil? ? true : comment['public'], 'trusted' => comment['trusted'].nil? ? true : comment['trusted'], 'attachments' => comment['attachments'] || [], 'ticket_id' => ticket_id, } audit_id = cistern.serial_id audit = { 'id' => audit_id, 'ticket_id' => ticket_id, 'created_at' => Time.now, 'author_id' => cistern.current_user['id'], 'via' => { 'channel' => 'api', 'source' => { 'form' => {}, 'to' => {}, 'rel' => nil, }, }, 'metadata' => { 'system' => { 'client' => Zendesk2::USER_AGENT, 'ip_address' => '127.0.0.1', 'location' => 'Oakland, CA, United States', 'latitude' => 37.83449999999999, 'longitude' => -122.2647, }, 'custom' => {}, }, 'events' => [comment_data], } data[:ticket_audits][audit_id] = audit end mock_response( 'ticket' => body, 'audit' => audit ) end
ticket_id()
click to toggle source
# File lib/zendesk2/update_ticket.rb, line 17 def ticket_id params.fetch('ticket').fetch('id') end
ticket_params()
click to toggle source
# File lib/zendesk2/update_ticket.rb, line 13 def ticket_params @_ticket_params ||= Cistern::Hash.slice(params.fetch('ticket'), *self.class.accepted_attributes) end