class TicketAbstractorClient::Base::Ticket
Attributes
attachments[R]
changes[R]
comments[R]
communications_stack[RW]
endpoint[RW]
fields[RW]
project[RW]
status[R]
ticket_id[RW]
Public Class Methods
new(opts = {})
click to toggle source
# File lib/ticket_abstractor_client/base/ticket.rb, line 7 def initialize(opts = {}) opts = opts.with_indifferent_access @ticket_id = opts[:ticket_id] @fields = opts.fetch(:fields, {}).with_indifferent_access @endpoint = opts[:endpoint] || raise(Errors::TicketArgumentError, 'Endpoint is not given') @project = opts[:project] @communications_stack = opts[:communications_stack] || [] @attachments ||= [] @comments ||= [] initialize_changes! mark_changes! end
Protected Class Methods
not_implemented(method_name)
click to toggle source
# File lib/ticket_abstractor_client/base/ticket.rb, line 67 def self.not_implemented(method_name) raise Errors::NotImplementedError, "#{self}##{__method__} is not implemented" end
Public Instance Methods
add_attachment(attachment)
click to toggle source
# File lib/ticket_abstractor_client/base/ticket.rb, line 20 def add_attachment(attachment) self.class.not_implemented __method__ end
add_comment(comment)
click to toggle source
# File lib/ticket_abstractor_client/base/ticket.rb, line 24 def add_comment(comment) self.class.not_implemented __method__ end
any_changes?()
click to toggle source
# File lib/ticket_abstractor_client/base/ticket.rb, line 28 def any_changes? @changes.values.any? { |value| value.is_a?(Fixnum) ? !value.zero? : value.present? } end
reset_changes!()
click to toggle source
# File lib/ticket_abstractor_client/base/ticket.rb, line 32 def reset_changes! initialize_changes! end
status=(status)
click to toggle source
# File lib/ticket_abstractor_client/base/ticket.rb, line 36 def status=(status) return if @status == status @changes[:new_status] = true @status = status end
sync!()
click to toggle source
# File lib/ticket_abstractor_client/base/ticket.rb, line 42 def sync! self.class.not_implemented __method__ end
to_hash()
click to toggle source
# File lib/ticket_abstractor_client/base/ticket.rb, line 46 def to_hash { ticket_id: self.ticket_id, status: self.status, updated_at: self.updated_at, fields: self.fields, comments: self.comments.map(&:to_hash), attachments: self.attachments.map(&:to_hash) } end
to_json()
click to toggle source
# File lib/ticket_abstractor_client/base/ticket.rb, line 57 def to_json to_hash.to_json end
updated_at()
click to toggle source
# File lib/ticket_abstractor_client/base/ticket.rb, line 61 def updated_at self.class.not_implemented __method__ end
Protected Instance Methods
initialize_changes!()
click to toggle source
# File lib/ticket_abstractor_client/base/ticket.rb, line 71 def initialize_changes! @changes = { create: false, update: false, new_status: false, new_attachments: 0, new_comments: 0 } end
mark_changes!()
click to toggle source
# File lib/ticket_abstractor_client/base/ticket.rb, line 75 def mark_changes! return @changes[:create] = true if @ticket_id.blank? @changes[:update] = true if @fields.present? end