Class: TicketAbstractorClient::Jira::Comment

Inherits:
Base::Comment show all
Defined in:
lib/ticket_abstractor_client/jira/comment.rb

Instance Attribute Summary collapse

Attributes inherited from Base::Comment

#author, #body, #communications_stack, #data_hash, #external_created_at

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base::Comment

#set_data_hash!, #to_hash, #to_json

Constructor Details

#initialize(opts) ⇒ Comment

Returns a new instance of Comment.



20
21
22
23
24
# File 'lib/ticket_abstractor_client/jira/comment.rb', line 20

def initialize(opts)
  super(opts)
  @author_display_name = opts[:author_display_name]
  @ticket_id, @endpoint, @project = opts.values_at(:ticket_id, :endpoint, :project)
end

Instance Attribute Details

#author_display_nameObject

Returns the value of attribute author_display_name.



4
5
6
# File 'lib/ticket_abstractor_client/jira/comment.rb', line 4

def author_display_name
  @author_display_name
end

#endpointObject

Returns the value of attribute endpoint.



4
5
6
# File 'lib/ticket_abstractor_client/jira/comment.rb', line 4

def endpoint
  @endpoint
end

#projectObject

Returns the value of attribute project.



4
5
6
# File 'lib/ticket_abstractor_client/jira/comment.rb', line 4

def project
  @project
end

#ticket_idObject

Returns the value of attribute ticket_id.



4
5
6
# File 'lib/ticket_abstractor_client/jira/comment.rb', line 4

def ticket_id
  @ticket_id
end

Class Method Details

.fetch(ticket_id, endpoint) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/ticket_abstractor_client/jira/comment.rb', line 6

def self.fetch(ticket_id, endpoint)
  comments_list = Client.new(endpoint).get_comments(ticket_id: ticket_id)
  comments_list['comments'].map do |raw_comment|
    new(
      author: raw_comment['author']['name'],
      author_display_name: raw_comment['author']['displayName'],
      body: raw_comment['body'],
      external_created_at: raw_comment['created'],
      ticket_id: ticket_id,
      endpoint: endpoint
    )
  end
end

Instance Method Details

#sync!Object



26
27
28
29
30
31
32
# File 'lib/ticket_abstractor_client/jira/comment.rb', line 26

def sync!
  created_comment_hash = Client.new(@endpoint).create_comment(self)
  @author = created_comment_hash['author']['name']
  @author_display_name = created_comment_hash['author']['displayName']
  @external_created_at = created_comment_hash['created']
  self.set_data_hash!
end