lib/zendesk2/client/requests/update_ticket.rb in zendesk2-0.3.0 vs lib/zendesk2/client/requests/update_ticket.rb in zendesk2-0.3.1
- old
+ new
@@ -16,10 +16,22 @@
def update_ticket(params={})
ticket_id = params.delete("id")
body = self.data[:tickets][ticket_id].merge!(params)
if comment = params["comment"]
+ comment_id = self.class.new_id
+ comment_data = self.data[:ticket_comments][comment_id] = {
+ "id" => comment_id,
+ "type" => "Comment",
+ "author_id" => 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"] || [],
+ }
+
audit_id = self.class.new_id
self.data[:ticket_audits][audit_id] = {
"id" => audit_id,
"ticket_id" => ticket_id,
"created_at" => Time.now,
@@ -40,19 +52,10 @@
"latitude" => 37.83449999999999,
"longitude" => -122.2647,
},
"custom" => {},
},
- "events" => [
- "id" => self.class.new_id,
- "type" => "Comment",
- "author_id" => 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"] || [],
- ]
+ "events" => [comment_data]
}
end
response(
:method => :put,