class TicketAbstractorClient::ServiceNow::Comment

Attributes

endpoint[RW]
project[RW]
ticket_id[RW]

Public Class Methods

fetch(ticket_id, endpoint, project) click to toggle source
# File lib/ticket_abstractor_client/service_now/comment.rb, line 6
def self.fetch(ticket_id, endpoint, project)
  client = Client.new(endpoint)
  response = client.get_comments(ticket_id: ticket_id, project: project)

  comments =
    response.map do |raw_comment|
      new({
        author: raw_comment['sys_created_by'],
        body: raw_comment['value'],
        external_created_at: raw_comment['sys_created_on'],
        ticket_id: ticket_id,
        endpoint: endpoint,
        project: project,
        communications_stack: client.communications_stack
      })
    end

  [comments, client.communications_stack]
end
new(opts) click to toggle source
# File lib/ticket_abstractor_client/service_now/comment.rb, line 26
def initialize(opts)
  super(opts)
  @ticket_id, @endpoint, @project = opts.values_at(:ticket_id, :endpoint, :project)
end

Public Instance Methods

sync!() click to toggle source
# File lib/ticket_abstractor_client/service_now/comment.rb, line 31
def sync!
  client = Client.new(@endpoint)
  response = client.create_comment(self)
  @communications_stack = client.communications_stack

  response
end