Class: Zendesk2::UpdateTicket
- Inherits:
-
Object
- Object
- Zendesk2::UpdateTicket
- Includes:
- Request
- Defined in:
- lib/zendesk2/update_ticket.rb
Instance Attribute Summary
Attributes included from Request
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Request
#call, cistern_included, #data, #delete!, #error!, #find!, #html_url_for, included, #mock_response, #page, #page_params!, #page_params?, #pluralize, #real, #real_request, #request_body, #request_params, #request_path, #resources, #response, #timestamp, #url_for
Class Method Details
.accepted_attributes ⇒ Object
9 10 11 |
# File 'lib/zendesk2/update_ticket.rb', line 9 def self.accepted_attributes Zendesk2::CreateTicket.accepted_attributes + ['comment'] end |
Instance Method Details
#mock ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# 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 ⇒ Object
17 18 19 |
# File 'lib/zendesk2/update_ticket.rb', line 17 def ticket_id params.fetch('ticket').fetch('id') end |
#ticket_params ⇒ Object
13 14 15 |
# File 'lib/zendesk2/update_ticket.rb', line 13 def ticket_params @_ticket_params ||= Cistern::Hash.slice(params.fetch('ticket'), *self.class.accepted_attributes) end |