Module: OnlyofficeBugzillaHelper::Comments

Included in:
BugzillaHelper
Defined in:
lib/onlyoffice_bugzilla_helper/comments.rb

Overview

Working with comments

Instance Method Summary collapse

Instance Method Details

#add_comment(bug_id, comment) ⇒ Object

Add comment to bug

Parameters:

  • bug_id (Integer)

    id of bug

  • comment (String)

    comment to add


17
18
19
20
21
22
# File 'lib/onlyoffice_bugzilla_helper/comments.rb', line 17

def add_comment(bug_id, comment)
  req = Net::HTTP::Post.new(bug_url(bug_id, '/comment'))
  req.body = { comment: comment }.to_json
  req.add_field('Content-Type', 'text/plain')
  perform_request(req)
end

#comments(bug_id) ⇒ Hash

Returns list of bug comments.

Returns:

  • (Hash)

    list of bug comments


7
8
9
10
11
12
# File 'lib/onlyoffice_bugzilla_helper/comments.rb', line 7

def comments(bug_id)
  res = Net::HTTP.start(@url.host, @url.port, use_ssl: use_ssl?) do |http|
    http.get(bug_url(bug_id, '/comment'))
  end
  JSON.parse(res.body)['bugs'][bug_id.to_s]['comments']
end