lib/zendesk2/ticket.rb in zendesk2-1.9.0 vs lib/zendesk2/ticket.rb in zendesk2-1.10.0

- old
+ new

@@ -1,5 +1,6 @@ +# frozen_string_literal: true class Zendesk2::Ticket include Zendesk2::Model extend Zendesk2::Attributes @@ -25,11 +26,12 @@ attribute :group_id, type: :integer # @return [Boolean] Is true of this ticket has been marked as a problem, false otherwise attribute :has_incidents, type: :boolean # @return [Integer] The organization of the requester attribute :organization_id, type: :integer - # @return [String] Priority, defines the urgency with which the ticket should be addressed: "urgent", "high", "normal", "low" + # @return [String] Priority, defines the urgency with which the ticket should be addressed: + # "urgent", "high", "normal", "low" attribute :priority, type: :string # @return [Integer] The problem this incident is linked to, if any attribute :problem_id, type: :integer # @return [String] The original recipient e-mail address of the ticket attribute :recipient, type: :string @@ -65,77 +67,77 @@ def save! data = if new_record? requires :subject, :description - create_attributes = self.attributes.dup + create_attributes = attributes.dup - if with_requester = (@requester || nil) && Zendesk2.stringify_keys(@requester) - create_attributes.merge!("requester" => with_requester) - end + with_requester = (@requester || nil) && Zendesk2.stringify_keys(@requester) - cistern.create_ticket("ticket" => create_attributes).body["ticket"] + with_requester && create_attributes['requester'] = with_requester + + cistern.create_ticket('ticket' => create_attributes).body['ticket'] else requires :identity - cistern.update_ticket("ticket" => self.attributes).body["ticket"] + cistern.update_ticket('ticket' => attributes).body['ticket'] end merge_attributes(data) end def destroy! requires :identity - cistern.destroy_ticket("ticket" => {"id" => self.identity}) + cistern.destroy_ticket('ticket' => { 'id' => identity }) end # Adds a ticket comment # # @param [String] text comment body # @param [Hash] options comment options # @option options [Array] :attachments Attachment to upload with comment # @option options [Boolean] :public (true) # @return [Zendesk2::TicketComment] - def comment(text, options={}) + def comment(text, options = {}) requires :identity options[:public] = true if options[:public].nil? - comment = Zendesk2.stringify_keys(options).merge("body" => text) + comment = Zendesk2.stringify_keys(options).merge('body' => text) cistern.ticket_comments.new( cistern.update_ticket( - "ticket" => { - "id" => self.identity, - "comment" => comment, + 'ticket' => { + 'id' => identity, + 'comment' => comment, } - ).body["audit"]["events"].first + ).body['audit']['events'].first ) end # @return [Array<Zendesk2::User>] All users CCD on this ticket def collaborators - self.collaborator_ids.map { |cid| self.cistern.users.get(cid) } + collaborator_ids.map { |cid| cistern.users.get(cid) } end # Update list of users to be CCD on this ticket # @param [Array<Zendesk2::User>] collaborators list of users def collaborators=(collaborators) self.collaborator_ids = collaborators.map(&:identity) end # @return [Zendesk2::TicketAudits] all audits for this ticket def audits - self.cistern.ticket_audits(ticket_id: self.identity).all + cistern.ticket_audits(ticket_id: identity).all end # @return [Zendesk2::TicketMetric] metrics for this ticket def metrics - Zendesk2::TicketMetric.new(self.cistern.get_ticket_metric("ticket_id" => self.identity).body["ticket_metric"]) + Zendesk2::TicketMetric.new(cistern.get_ticket_metric('ticket_id' => identity).body['ticket_metric']) end # @return [Array<Zendesk2::TicketComment>] all comments for this ticket def comments - self.cistern.ticket_comments(ticket_id: self.identity).all + cistern.ticket_comments(ticket_id: identity).all end end